SUPPORT.TWILIO.COM END OF LIFE NOTICE: This site, support.twilio.com, is scheduled to go End of Life on February 27, 2024. All Twilio Support content has been migrated to help.twilio.com, where you can continue to find helpful Support articles, API docs, and Twilio blog content, and escalate your issues to our Support team. We encourage you to update your bookmarks and begin using the new site today for all your Twilio Support needs.

Enable and Configure Credentials and Environmental Variables with Twilio Functions

Twilio Functions, your Twilio-hosted complete runtime environment for Node.js v18 scripts, allows you to set environmental variables available to your functions at runtime. This document will walk you through how to set specific variables, as well as how to modify and delete existing variables.

Credentials Opt-In

The only built-in variables in Twilio Functions are your Credentials; your Twilio project Account SID and Auth Token. Your credentials, however, are not available by default - this option must be enabled. Here's the process:

  1. Access the Functions Configuration page in Console.
  2. Click and check Enable ACCOUNT_SID and AUTH_TOKEN.
    Config_01_400.png
  3. Click Save at the bottom of the window.

Once your credentials are enabled, any Function script on your project can easily access an initialized REST client for making Twilio API calls via the context object. For more details, please see Function Execution: Context Object (Twilio Docs).

Custom Environmental Variables

Customized environmental variables can also be added, making them available to any Functions script on your Twilio project. Variables are managed via Console:

  1. Access the Functions Configuration page in Console.
  2. Scroll to the Environmental Variables section, and modify as desired:
    Config_02_400.png
    • Click the red + (plus) icon to add a variable key and value pair.
    • Click an existing variable key or value field to edit it.
    • Existing variable value fields are hidden by default; click the value field, or the Eye icon to view them.
    • Click the grey X icon next to an existing variable key and value pair to delete it.
  3. Click Save at the bottom of the window when finished.

Once saved, environmental variables can be accessed in your Functions scripts with the context object. For more details, please see Function Execution: Environmental Variables (Twilio Docs).

Have more questions? Submit a request
Powered by Zendesk