Serverless | Dec. 20, 2019

Twilio Functions: Function path now available in context object

The path of the executing Function is now available in the context object at runtime, allowing you to reconstruct the full Function URL for use in your application.

Example:

exports.handler = function(context, event, callback) {
callback(null, 'https://' + context.DOMAIN_NAME + context.PATH);
};

Full structure available from the context:

{
"PATH":"/contextpath",
"ENVIRONMENT_VARIABLE":"ENVIRONMENT_VALUE",
"ACCOUNT_SID":"ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"DOMAIN_NAME":"funny-name-1234.twil.io"
}

The context path is available in both Console-created Functions and those created via the API.

For more information about Twilio Functions, check the Runtime documentation.

Serverless Beta