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

Environment


Environments define the different domains your Functions and Assets are available under. You can have one environment, or you can have many, e.g., a dev, stage, and prod. You can deploy a Build to any of your Environments.


Environment Properties

environment-properties page anchor
Resource properties
sidtype: SID<ZE>
Not PII

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

Pattern:
^ZE[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 Environment resource is associated with.

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

build_sidtype: SID<ZB>

The SID of the build deployed in the environment.

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

unique_nametype: string

A user-defined string that uniquely identifies the Environment resource.


domain_suffixtype: string

A URL-friendly name that represents the environment and forms part of the domain name.


domain_nametype: string

The domain name for all Functions and Assets deployed in the Environment, using the Service unique name, a randomly-generated Service suffix, and an optional Environment domain suffix.


date_createdtype: string<date-time>

The date and time in GMT when the Environment 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 Environment resource was last updated specified in ISO 8601(link takes you to an external page) format.


urltype: string<uri>

The absolute URL of the Environment resource.


linkstype: object<uri-map>

The URLs of the Environment resource's nested resources.


Create an Environment resource

create-an-environment-resource page anchor
POST https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments

Parameters

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

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


Request body parameters
UniqueNametype: stringRequired

A user-defined string that uniquely identifies the Environment resource. It can be a maximum of 100 characters.


DomainSuffixtype: string

A URL-friendly name that represents the environment and forms part of the domain name. It can be a maximum of 16 characters.

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
_11
.create({domainSuffix: 'stage', uniqueName: 'staging'})
_11
.then(environment => console.log(environment.domainName));

Output

_18
{
_18
"sid": "ZE00000000000000000000000000000000",
_18
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18
"service_sid": "ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18
"build_sid": null,
_18
"unique_name": "staging",
_18
"domain_suffix": "stage",
_18
"domain_name": "foobar-1234-stage.twil.io",
_18
"custom_domain_name": null,
_18
"date_created": "2018-11-10T20:00:00Z",
_18
"date_updated": "2018-11-10T20:00:00Z",
_18
"url": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments/ZE00000000000000000000000000000000",
_18
"links": {
_18
"variables": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments/ZE00000000000000000000000000000000/Variables",
_18
"deployments": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments/ZE00000000000000000000000000000000/Deployments",
_18
"logs": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments/ZE00000000000000000000000000000000/Logs"
_18
}
_18
}


Fetch an Environment resource

fetch-an-environment-resource page anchor
GET https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{Sid}

URI parameters
ServiceSidtype: string
Path ParameterNot PII

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


Sidtype: SID<ZE>
Path ParameterNot PII

The SID of the Environment resource to fetch.

Pattern:
^ZE[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
.fetch()
_11
.then(environment => console.log(environment.uniqueName));

Output

_18
{
_18
"sid": "ZEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18
"service_sid": "ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18
"build_sid": "ZB00000000000000000000000000000000",
_18
"unique_name": "testing-environment",
_18
"domain_suffix": "testing",
_18
"domain_name": "foobar-1234-testing.twil.io",
_18
"custom_domain_name": null,
_18
"date_created": "2018-11-10T20:00:00Z",
_18
"date_updated": "2018-11-10T20:00:00Z",
_18
"url": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments/ZE00000000000000000000000000000000",
_18
"links": {
_18
"variables": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments/ZE00000000000000000000000000000000/Variables",
_18
"deployments": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments/ZE00000000000000000000000000000000/Deployments",
_18
"logs": "https://serverless.twilio.com/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments/ZE00000000000000000000000000000000/Logs"
_18
}
_18
}


Read multiple Environment resources

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

URI parameters
ServiceSidtype: string
Path ParameterNot PII

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


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.

List multiple Environments

list-multiple-environments page anchor
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
_11
.list({limit: 20})
_11
.then(environments => environments.forEach(e => console.log(e.sid)));

Output

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


Delete an Environment resource

delete-an-environment-resource page anchor
DELETE https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{Sid}

URI parameters
ServiceSidtype: string
Path ParameterNot PII

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


Sidtype: SID<ZE>
Path ParameterNot PII

The SID of the Environment resource to delete.

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

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


Rate this page: