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.
Property nameTypePIIDescription
The unique string that we created to identify the Variable resource.
Pattern: ^ZV[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Account that created the Variable resource.
Pattern: ^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Service that the Variable resource is associated with.
Pattern: ^ZS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Environment in which the Variable exists.
Pattern: ^ZE[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
A string by which the Variable resource can be referenced.
A string that contains the actual value of the Variable.
date_createdstring<date-time>
date_updatedstring<date-time>
The absolute URL of the Variable resource.
POST https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{EnvironmentSid}/Variables
Property nameTypeRequiredPIIDescription
The SID of the Service to create the Variable resource under.
EnvironmentSidSID<ZE>required The SID of the Environment in which the Variable resource exists.
Pattern: ^ZE[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Property nameTypeRequiredPIIDescription
A string by which the Variable resource can be referenced. It can be a maximum of 128 characters.
A string that contains the actual value of the Variable. It can be a maximum of 450 bytes in size.
_22// Download the helper library from https://www.twilio.com/docs/node/install
_22const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_22// Find your Account SID and Auth Token at twilio.com/console
_22// and set the environment variables. See http://twil.io/secure
_22const accountSid = process.env.TWILIO_ACCOUNT_SID;
_22const authToken = process.env.TWILIO_AUTH_TOKEN;
_22const client = twilio(accountSid, authToken);
_22async function createVariable() {
_22 const variable = await client.serverless.v1
_22 .services("ServiceSid")
_22 .environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_22 console.log(variable.sid);
_11 "sid": "ZV00000000000000000000000000000000",
_11 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_11 "service_sid": "ServiceSid",
_11 "environment_sid": "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_11 "date_created": "2018-11-10T20:00:00Z",
_11 "date_updated": "2018-11-10T20:00:00Z",
_11 "url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments/ZE00000000000000000000000000000000/Variables/ZV00000000000000000000000000000000"
GET https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{EnvironmentSid}/Variables/{Sid}
Property nameTypeRequiredPIIDescription
The SID of the Service to fetch the Variable resource from.
EnvironmentSidSID<ZE>required The SID of the Environment with the Variable resource to fetch.
Pattern: ^ZE[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Variable resource to fetch.
Pattern: ^ZV[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
_20// Download the helper library from https://www.twilio.com/docs/node/install
_20const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_20// Find your Account SID and Auth Token at twilio.com/console
_20// and set the environment variables. See http://twil.io/secure
_20const accountSid = process.env.TWILIO_ACCOUNT_SID;
_20const authToken = process.env.TWILIO_AUTH_TOKEN;
_20const client = twilio(accountSid, authToken);
_20async function fetchVariable() {
_20 const variable = await client.serverless.v1
_20 .services("ServiceSid")
_20 .environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_20 .variables("ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_20 console.log(variable.sid);
_11 "sid": "ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_11 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_11 "service_sid": "ServiceSid",
_11 "environment_sid": "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_11 "value": "test-value",
_11 "date_created": "2018-11-10T20:00:00Z",
_11 "date_updated": "2018-11-10T20:00:00Z",
_11 "url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments/ZE00000000000000000000000000000000/Variables/ZV00000000000000000000000000000000"
GET https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{EnvironmentSid}/Variables
Property nameTypeRequiredPIIDescription
The SID of the Service to read the Variable resources from.
EnvironmentSidSID<ZE>required The SID of the Environment with the Variable resources to read.
Pattern: ^ZE[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Property nameTypeRequiredPIIDescription
How many resources to return in each list page. The default is 50, and the maximum is 1000.
Minimum: 1
Maximum: 1000
The page index. This value is simply for client state.
Minimum: 0
The page token. This is provided by the API.
_19// Download the helper library from https://www.twilio.com/docs/node/install
_19const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_19// Find your Account SID and Auth Token at twilio.com/console
_19// and set the environment variables. See http://twil.io/secure
_19const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19const authToken = process.env.TWILIO_AUTH_TOKEN;
_19const client = twilio(accountSid, authToken);
_19async function listVariable() {
_19 const variables = await client.serverless.v1
_19 .services("ServiceSid")
_19 .environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19 .variables.list({ limit: 20 });
_19 variables.forEach((v) => console.log(v.sid));
_12 "first_page_url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments/ZE00000000000000000000000000000000/Variables?PageSize=50&Page=0",
_12 "next_page_url": null,
_12 "previous_page_url": null,
_12 "url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments/ZE00000000000000000000000000000000/Variables?PageSize=50&Page=0"
POST https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{EnvironmentSid}/Variables/{Sid}
Property nameTypeRequiredPIIDescription
The SID of the Service to update the Variable resource under.
EnvironmentSidSID<ZE>required The SID of the Environment with the Variable resource to update.
Pattern: ^ZE[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Variable resource to update.
Pattern: ^ZV[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Property nameTypeRequiredPIIDescription
A string by which the Variable resource can be referenced. It can be a maximum of 128 characters.
A string that contains the actual value of the Variable. It can be a maximum of 450 bytes in size.
_20// Download the helper library from https://www.twilio.com/docs/node/install
_20const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_20// Find your Account SID and Auth Token at twilio.com/console
_20// and set the environment variables. See http://twil.io/secure
_20const accountSid = process.env.TWILIO_ACCOUNT_SID;
_20const authToken = process.env.TWILIO_AUTH_TOKEN;
_20const client = twilio(accountSid, authToken);
_20async function updateVariable() {
_20 const variable = await client.serverless.v1
_20 .services("ServiceSid")
_20 .environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_20 .variables("ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_20 .update({ key: "Key" });
_20 console.log(variable.sid);
_11 "sid": "ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_11 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_11 "service_sid": "ServiceSid",
_11 "environment_sid": "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_11 "value": "update-value",
_11 "date_created": "2018-11-10T20:00:00Z",
_11 "date_updated": "2018-11-11T20:00:00Z",
_11 "url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments/ZE00000000000000000000000000000000/Variables/ZV00000000000000000000000000000000"
DELETE https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{EnvironmentSid}/Variables/{Sid}
Property nameTypeRequiredPIIDescription
The SID of the Service to delete the Variable resource from.
EnvironmentSidSID<ZE>required The SID of the Environment with the Variables to delete.
Pattern: ^ZE[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Variable resource to delete.
Pattern: ^ZV[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
_18// Download the helper library from https://www.twilio.com/docs/node/install
_18const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18// Find your Account SID and Auth Token at twilio.com/console
_18// and set the environment variables. See http://twil.io/secure
_18const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18const authToken = process.env.TWILIO_AUTH_TOKEN;
_18const client = twilio(accountSid, authToken);
_18async function deleteVariable() {
_18 await client.serverless.v1
_18 .services("ServiceSid")
_18 .environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18 .variables("ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")