Variable
Variables are key/value pairs that you can add to a specific Environment. Use these for storing configuration like API keys rather than hardcoding them into your Functions. Environment Variables are encrypted, so they are the preferred way to store API keys, passwords, and any other secrets that your Function needs to use.
Variable properties
Resource Properties in REST API format | |
---|---|
sid
|
The unique string that we created to identify the Variable resource. |
account_sid
|
The SID of the Account that created the Variable resource. |
service_sid
|
The SID of the Service that the Variable resource is associated with. |
environment_sid
|
The SID of the Environment in which the Variable exists. |
key
|
A string by which the Variable resource can be referenced. |
value
|
A string that contains the actual value of the Variable. |
date_created
|
The date and time in GMT when the Variable resource was created specified in ISO 8601 format. |
date_updated
|
The date and time in GMT when the Variable resource was last updated specified in ISO 8601 format. |
url
|
The absolute URL of the Variable resource. |
Create a Variable resource
https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{EnvironmentSid}/Variables
Parameters
Parameters in REST API format | |
---|---|
service_sid
Path
|
The SID of the Service to create the Variable resource under. |
environment_sid
Path
|
The SID of the Environment in which the Variable resource exists. |
key
Required
|
A string by which the Variable resource can be referenced. It can be a maximum of 128 characters. |
value
Required
|
A string that contains the actual value of the Variable. It can be a maximum of 450 bytes in size. |
Example 1
Fetch a Variable resource
https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{EnvironmentSid}/Variables/{Sid}
Parameters
Parameters in REST API format | |
---|---|
service_sid
Path
|
The SID of the Service to fetch the Variable resource from. |
environment_sid
Path
|
The SID of the Environment with the Variable resource to fetch. |
sid
Path
|
The SID of the Variable resource to fetch. |
Example 1
Read multiple Variable resources
https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{EnvironmentSid}/Variables
Parameters
Parameters in REST API format | |
---|---|
service_sid
Path
|
The SID of the Service to read the Variable resources from. |
environment_sid
Path
|
The SID of the Environment with the Variable resources to read. |
Example 1
Update a Variable resource
https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{EnvironmentSid}/Variables/{Sid}
Parameters
Parameters in REST API format | |
---|---|
service_sid
Path
|
The SID of the Service to update the Variable resource under. |
environment_sid
Path
|
The SID of the Environment with the Variable resource to update. |
sid
Path
|
The SID of the Variable resource to update. |
key
Optional
|
A string by which the Variable resource can be referenced. It can be a maximum of 128 characters. |
value
Optional
|
A string that contains the actual value of the Variable. It can be a maximum of 450 bytes in size. |
Example 1
Delete a Variable resource
https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{EnvironmentSid}/Variables/{Sid}
Parameters
Parameters in REST API format | |
---|---|
service_sid
Path
|
The SID of the Service to delete the Variable resource from. |
environment_sid
Path
|
The SID of the Environment with the Variables to delete. |
sid
Path
|
The SID of the Variable resource to delete. |
Example 1
Need some help?
We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.