(key: string): any
(all: boolean): any
(arguments: {
all?: boolean,
key?: string,
default?: any
}): anyThe _secret operator gets a value from the secret object. The secrets is a data object that contains sensitive information like passwords or API keys. The _secret operator can only be used in connections and requests. Secrets are read from environment variables on the server that start with LOWDEFY_SECRET_, (i.e. LOWDEFY_SECRET_SECRET_NAME). The name of the secret is the part after LOWDEFY_SECRET_. Since environment variables can only be strings, secrets can be JSON encoded, and parsed using the _json.parse method.
Arguments
string
If the _secret operator is called with a string argument, the value of the key in the secrets object is returned. If the value is not found, null is returned.
boolean
If the _secret operator is called with boolean argument true, the entire secrets object is returned.
object
all: boolean: Ifallis set totrue, the entiresecretsobject is returned. One ofallorkeyare required.key: string: The value of the key in thesecretsobject is returned. If the value is not found,null, or the specified default value is returned. One ofallorkeyare required.default: any: A value to return if thekeyis not found insecrets. By default,nullis returned if a value is not found.
Examples
Get the value of MY_SECRET from secrets:
_secret: MY_SECRET_secret:
key: MY_SECRETReturns: The value of MY_SECRET in secrets.
Get the entire secret object:
_secret: true_secret:
all: trueReturns: The entire secrets object.
Return a default value if the value is not found:
_secret:
key: MY_SECRET
default: Not so secretReturns: The value of MY_SECRET, or "Not so secret".
