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.

How do I add an environment variable to a Functions service?

Objective

This article shows you how to store a value such as an API key as an environment variable on a Functions service, so your function code can read it at runtime instead of having the value hardcoded in the function.

 

Product

Twilio Functions and Assets

 

Environment

Twilio Console

 

Procedure

  1. In the Twilio Console, select Builder tools in the left sidebar.
  2. Select Functions & Assets, then Services.
  3. Select the name of the service you want to configure.
  4. Select the Environment variables tab.
  5. Select Add variable.
  6. Enter the Key and the Value for the variable.
  7. Select Add. The variable appears in the table, with its value hidden until you choose to reveal it.

 

Additional Information

  • A key may contain only letters, numbers, hyphens, and underscores, cannot be empty, and can be up to 128 characters.
  • A value can be up to 255 characters.
  • Your functions read these values from the context object, for example context.API_KEY.
  • If the service has many variables, use the search box above the table to find one by key or value, and select the Key column header to sort the list.

 

This content was generated by AI and reviewed, edited, and verified by a human.

Have more questions? Submit a request
Powered by Zendesk