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
- In the Twilio Console, select Builder tools in the left sidebar.
- Select Functions & Assets, then Services.
- Select the name of the service you want to configure.
- Select the Environment variables tab.
- Select Add variable.
- Enter the Key and the Value for the variable.
- 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.