Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

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

variable-properties page anchor
Resource properties
sidtype: SID<ZV>
Not PII

The unique string that we created to identify the Variable resource.

Pattern:
^ZV[0-9a-fA-F]{32}$
Min length:
34
Max length:
34

account_sidtype: SID<AC>

service_sidtype: SID<ZS>

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

environment_sidtype: SID<ZE>

The SID of the Environment in which the Variable exists.

Pattern:
^ZE[0-9a-fA-F]{32}$
Min length:
34
Max length:
34

keytype: string

A string by which the Variable resource can be referenced.


valuetype: string

A string that contains the actual value of the Variable.


date_createdtype: string<date-time>

The date and time in GMT when the Variable resource was created specified in ISO 8601(link takes you to an external page) format.


date_updatedtype: string<date-time>

The date and time in GMT when the Variable resource was last updated specified in ISO 8601(link takes you to an external page) format.


urltype: string<uri>

The absolute URL of the Variable resource.


Create a Variable resource

create-a-variable-resource page anchor
POST https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{EnvironmentSid}/Variables

Parameters

create-parameters page anchor
URI parameters
ServiceSidtype: string
Path ParameterNot PII

The SID of the Service to create the Variable resource under.


EnvironmentSidtype: SID<ZE>
Path ParameterNot PII

The SID of the Environment in which the Variable resource exists.

Pattern:
^ZE[0-9a-fA-F]{32}$
Min length:
34
Max length:
34

Request body parameters
Keytype: stringRequired

A string by which the Variable resource can be referenced. It can be a maximum of 128 characters.


Valuetype: stringRequired

A string that contains the actual value of the Variable. It can be a maximum of 450 bytes in size.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_12
// Download the helper library from https://www.twilio.com/docs/node/install
_12
// Find your Account SID and Auth Token at twilio.com/console
_12
// and set the environment variables. See http://twil.io/secure
_12
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_12
const authToken = process.env.TWILIO_AUTH_TOKEN;
_12
const client = require('twilio')(accountSid, authToken);
_12
_12
client.serverless.v1.services('ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.environments('ZEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.variables
_12
.create({key: 'key', value: 'value'})
_12
.then(variable => console.log(variable.sid));

Output

_11
{
_11
"sid": "ZV00000000000000000000000000000000",
_11
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_11
"service_sid": "ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_11
"environment_sid": "ZEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_11
"key": "new-key",
_11
"value": "new-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/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments/ZE00000000000000000000000000000000/Variables/ZV00000000000000000000000000000000"
_11
}


Fetch a Variable resource

fetch-a-variable-resource page anchor
GET https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{EnvironmentSid}/Variables/{Sid}

URI parameters
ServiceSidtype: string
Path ParameterNot PII

The SID of the Service to fetch the Variable resource from.


EnvironmentSidtype: SID<ZE>
Path ParameterNot PII

The SID of the Environment with the Variable resource to fetch.

Pattern:
^ZE[0-9a-fA-F]{32}$
Min length:
34
Max length:
34

Sidtype: SID<ZV>
Path ParameterNot PII

The SID of the Variable resource to fetch.

Pattern:
^ZV[0-9a-fA-F]{32}$
Min length:
34
Max length:
34
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_12
// Download the helper library from https://www.twilio.com/docs/node/install
_12
// Find your Account SID and Auth Token at twilio.com/console
_12
// and set the environment variables. See http://twil.io/secure
_12
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_12
const authToken = process.env.TWILIO_AUTH_TOKEN;
_12
const client = require('twilio')(accountSid, authToken);
_12
_12
client.serverless.v1.services('ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.environments('ZEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.variables('ZVXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.fetch()
_12
.then(variable => console.log(variable.sid));

Output

_11
{
_11
"sid": "ZVXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_11
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_11
"service_sid": "ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_11
"environment_sid": "ZEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_11
"key": "test-key",
_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/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments/ZE00000000000000000000000000000000/Variables/ZV00000000000000000000000000000000"
_11
}


Read multiple Variable resources

read-multiple-variable-resources page anchor
GET https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{EnvironmentSid}/Variables

URI parameters
ServiceSidtype: string
Path ParameterNot PII

The SID of the Service to read the Variable resources from.


EnvironmentSidtype: SID<ZE>
Path ParameterNot PII

The SID of the Environment with the Variable resources to read.

Pattern:
^ZE[0-9a-fA-F]{32}$
Min length:
34
Max length:
34

PageSizetype: integer
Query ParameterNot PII

How many resources to return in each list page. The default is 50, and the maximum is 1000.

Minimum:
1

Pagetype: integer
Query ParameterNot PII

The page index. This value is simply for client state.

Minimum:
0

PageTokentype: string
Query ParameterNot PII

The page token. This is provided by the API.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_12
// Download the helper library from https://www.twilio.com/docs/node/install
_12
// Find your Account SID and Auth Token at twilio.com/console
_12
// and set the environment variables. See http://twil.io/secure
_12
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_12
const authToken = process.env.TWILIO_AUTH_TOKEN;
_12
const client = require('twilio')(accountSid, authToken);
_12
_12
client.serverless.v1.services('ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.environments('ZEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.variables
_12
.list({limit: 20})
_12
.then(variables => variables.forEach(v => console.log(v.sid)));

Output

_12
{
_12
"variables": [],
_12
"meta": {
_12
"first_page_url": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments/ZE00000000000000000000000000000000/Variables?PageSize=50&Page=0",
_12
"key": "variables",
_12
"next_page_url": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments/ZE00000000000000000000000000000000/Variables?PageSize=50&Page=1",
_12
"page": 0,
_12
"page_size": 50,
_12
"previous_page_url": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments/ZE00000000000000000000000000000000/Variables?PageSize=50&Page=0",
_12
"url": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments/ZE00000000000000000000000000000000/Variables?PageSize=50&Page=0"
_12
}
_12
}


Update a Variable resource

update-a-variable-resource page anchor
POST https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{EnvironmentSid}/Variables/{Sid}

URI parameters
ServiceSidtype: string
Path ParameterNot PII

The SID of the Service to update the Variable resource under.


EnvironmentSidtype: SID<ZE>
Path ParameterNot PII

The SID of the Environment with the Variable resource to update.

Pattern:
^ZE[0-9a-fA-F]{32}$
Min length:
34
Max length:
34

Sidtype: SID<ZV>
Path ParameterNot PII

The SID of the Variable resource to update.

Pattern:
^ZV[0-9a-fA-F]{32}$
Min length:
34
Max length:
34

Request body parameters
Keytype: string

A string by which the Variable resource can be referenced. It can be a maximum of 128 characters.


Valuetype: string

A string that contains the actual value of the Variable. It can be a maximum of 450 bytes in size.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_12
// Download the helper library from https://www.twilio.com/docs/node/install
_12
// Find your Account SID and Auth Token at twilio.com/console
_12
// and set the environment variables. See http://twil.io/secure
_12
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_12
const authToken = process.env.TWILIO_AUTH_TOKEN;
_12
const client = require('twilio')(accountSid, authToken);
_12
_12
client.serverless.v1.services('ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.environments('ZEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.variables('ZVXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.update({key: 'key'})
_12
.then(variable => console.log(variable.sid));

Output

_11
{
_11
"sid": "ZVXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_11
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_11
"service_sid": "ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_11
"environment_sid": "ZEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_11
"key": "update-key",
_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/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments/ZE00000000000000000000000000000000/Variables/ZV00000000000000000000000000000000"
_11
}


Delete a Variable resource

delete-a-variable-resource page anchor
DELETE https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{EnvironmentSid}/Variables/{Sid}

URI parameters
ServiceSidtype: string
Path ParameterNot PII

The SID of the Service to delete the Variable resource from.


EnvironmentSidtype: SID<ZE>
Path ParameterNot PII

The SID of the Environment with the Variables to delete.

Pattern:
^ZE[0-9a-fA-F]{32}$
Min length:
34
Max length:
34

Sidtype: SID<ZV>
Path ParameterNot PII

The SID of the Variable resource to delete.

Pattern:
^ZV[0-9a-fA-F]{32}$
Min length:
34
Max length:
34
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_11
// Download the helper library from https://www.twilio.com/docs/node/install
_11
// Find your Account SID and Auth Token at twilio.com/console
_11
// and set the environment variables. See http://twil.io/secure
_11
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11
const authToken = process.env.TWILIO_AUTH_TOKEN;
_11
const client = require('twilio')(accountSid, authToken);
_11
_11
client.serverless.v1.services('ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.environments('ZEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.variables('ZVXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.remove();


Rate this page: