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.
The unique string that we created to identify the Variable resource.
^ZV[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Account that created the Variable resource.
^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Service that the Variable resource is associated with.
^ZS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Environment in which the Variable exists.
^ZE[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The date and time in GMT when the Variable resource was created specified in ISO 8601 format.
The date and time in GMT when the Variable resource was last updated specified in ISO 8601 format.
The absolute URL of the Variable resource.
POST https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{EnvironmentSid}/Variables
application/x-www-form-urlencoded
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.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createVariable() {11const variable = await client.serverless.v112.services("ServiceSid")13.environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")14.variables.create({15key: "Key",16value: "Value",17});1819console.log(variable.sid);20}2122createVariable();
1{2"sid": "ZV00000000000000000000000000000000",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"service_sid": "ServiceSid",5"environment_sid": "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",6"key": "Key",7"value": "Value",8"date_created": "2018-11-10T20:00:00Z",9"date_updated": "2018-11-10T20:00:00Z",10"url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments/ZE00000000000000000000000000000000/Variables/ZV00000000000000000000000000000000"11}
GET https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{EnvironmentSid}/Variables/{Sid}
The SID of the Environment with the Variable resource to fetch.
^ZE[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Variable resource to fetch.
^ZV[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function fetchVariable() {11const variable = await client.serverless.v112.services("ServiceSid")13.environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")14.variables("ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")15.fetch();1617console.log(variable.sid);18}1920fetchVariable();
1{2"sid": "ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"service_sid": "ServiceSid",5"environment_sid": "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",6"key": "test-key",7"value": "test-value",8"date_created": "2018-11-10T20:00:00Z",9"date_updated": "2018-11-10T20:00:00Z",10"url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments/ZE00000000000000000000000000000000/Variables/ZV00000000000000000000000000000000"11}
GET https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{EnvironmentSid}/Variables
How many resources to return in each list page. The default is 50, and the maximum is 1000.
1
Maximum: 1000
The page token. This is provided by the API.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function listVariable() {11const variables = await client.serverless.v112.services("ServiceSid")13.environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")14.variables.list({ limit: 20 });1516variables.forEach((v) => console.log(v.sid));17}1819listVariable();
1{2"variables": [],3"meta": {4"first_page_url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments/ZE00000000000000000000000000000000/Variables?PageSize=50&Page=0",5"key": "variables",6"next_page_url": null,7"page": 0,8"page_size": 50,9"previous_page_url": null,10"url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments/ZE00000000000000000000000000000000/Variables?PageSize=50&Page=0"11}12}
POST https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{EnvironmentSid}/Variables/{Sid}
The SID of the Environment with the Variable resource to update.
^ZE[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Variable resource to update.
^ZV[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
application/x-www-form-urlencoded
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.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function updateVariable() {11const variable = await client.serverless.v112.services("ServiceSid")13.environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")14.variables("ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")15.update({ key: "Key" });1617console.log(variable.sid);18}1920updateVariable();
1{2"sid": "ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"service_sid": "ServiceSid",5"environment_sid": "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",6"key": "Key",7"value": "update-value",8"date_created": "2018-11-10T20:00:00Z",9"date_updated": "2018-11-11T20:00:00Z",10"url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments/ZE00000000000000000000000000000000/Variables/ZV00000000000000000000000000000000"11}
DELETE https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{EnvironmentSid}/Variables/{Sid}
The SID of the Environment with the Variables to delete.
^ZE[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Variable resource to delete.
^ZV[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function deleteVariable() {11await client.serverless.v112.services("ServiceSid")13.environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")14.variables("ZVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")15.remove();16}1718deleteVariable();