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

Additional Resources

A newspaper article

Blog

Read more about our latest product updates, product tutorials, and community projects.


Docs

See API reference documentation, quickstarts, SDKs, and multi-language code samples.

User group reactions

Events

Find upcoming events and join us virtually or in person to learn more about our products.