DocumentationFundamentals

Accessing metadata

Accessing metadata from Webhook Relay Functions

It can be useful to access metadata from the function. For example, you can access the bucket, input and output names or the IDs directly from the function. This way you can build more complex functions that can be used in different scenarios.

Accessing metadata

You can access the metadata from the function using the r.Metadata table.

Available metadata

MetadataDescription
bucket_idThe ID of the bucket
bucket_nameThe name of the bucket
input_idThe ID of the input
input_nameThe name of the input
output_idThe ID of the output
output_nameThe name of the output
output_urlThe URL of the output

Example function deciding based on bucket name

Here's an example accessing Bucket name from within the function:

local http = require("http")

local bucket_name = r.Metadata["bucket_name"]

if bucket_name == "first-bucket" then
  -- do something
  response, err = http.request("GET", "https://company-a.com")
  if err then error(err) end  
  -- exit from function  
  return
end


if bucket_name == "second-bucket" then
  -- do something
  response, err = http.request("GET", "https://company-b.com")
  if err then error(err) end
  -- exit from function  
  return
end
Did this page help you?