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.
Property nameTypePIIDescription
The unique string that we created to identify the Environment resource.
Pattern: ^ZE[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Account that created the Environment resource.
Pattern: ^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
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
The SID of the build deployed in the environment.
Pattern: ^ZB[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
A user-defined string that uniquely identifies the Environment resource.
A URL-friendly name that represents the environment and forms part of the domain name.
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_createdstring<date-time>
date_updatedstring<date-time>
The absolute URL of the Environment resource.
The URLs of the Environment resource's nested resources.
POST https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments
Property nameTypeRequiredPIIDescription
The SID of the Service to create the Environment resource under.
Property nameTypeRequiredPIIDescription
A user-defined string that uniquely identifies the Environment resource. It can be a maximum of 100 characters.
DomainSuffixstringOptional A URL-friendly name that represents the environment and forms part of the domain name. It can be a maximum of 16 characters.
_21// Download the helper library from https://www.twilio.com/docs/node/install
_21const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_21// Find your Account SID and Auth Token at twilio.com/console
_21// and set the environment variables. See http://twil.io/secure
_21const accountSid = process.env.TWILIO_ACCOUNT_SID;
_21const authToken = process.env.TWILIO_AUTH_TOKEN;
_21const client = twilio(accountSid, authToken);
_21async function createEnvironment() {
_21 const environment = await client.serverless.v1
_21 .services("ServiceSid")
_21 .environments.create({
_21 domainSuffix: "stage",
_21 uniqueName: "staging",
_21 console.log(environment.domainName);
_18 "sid": "ZE00000000000000000000000000000000",
_18 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_18 "service_sid": "ServiceSid",
_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/ZS00000000000000000000000000000000/Environments/ZE00000000000000000000000000000000",
_18 "variables": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments/ZE00000000000000000000000000000000/Variables",
_18 "deployments": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments/ZE00000000000000000000000000000000/Deployments",
_18 "logs": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments/ZE00000000000000000000000000000000/Logs"
GET https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{Sid}
Property nameTypeRequiredPIIDescription
The SID of the Service to fetch the Environment resource from.
The SID of the Environment resource to fetch.
Pattern: ^ZE[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
_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 fetchEnvironment() {
_19 const environment = await client.serverless.v1
_19 .services("ServiceSid")
_19 .environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19 console.log(environment.sid);
_18 "sid": "ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_18 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_18 "service_sid": "ServiceSid",
_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/ZS00000000000000000000000000000000/Environments/ZE00000000000000000000000000000000",
_18 "variables": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments/ZE00000000000000000000000000000000/Variables",
_18 "deployments": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments/ZE00000000000000000000000000000000/Deployments",
_18 "logs": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments/ZE00000000000000000000000000000000/Logs"
GET https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments
Property nameTypeRequiredPIIDescription
The SID of the Service to read the Environment resources from.
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.
_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 listEnvironment() {
_18 const environments = await client.serverless.v1
_18 .services("ServiceSid")
_18 .environments.list({ limit: 20 });
_18 environments.forEach((e) => console.log(e.sid));
_12 "first_page_url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments?PageSize=50&Page=0",
_12 "key": "environments",
_12 "next_page_url": null,
_12 "previous_page_url": null,
_12 "url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments?PageSize=50&Page=0"
DELETE https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{Sid}
Property nameTypeRequiredPIIDescription
The SID of the Service to delete the Environment resource from.
The SID of the Environment resource to delete.
Pattern: ^ZE[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
_17// Download the helper library from https://www.twilio.com/docs/node/install
_17const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_17// Find your Account SID and Auth Token at twilio.com/console
_17// and set the environment variables. See http://twil.io/secure
_17const accountSid = process.env.TWILIO_ACCOUNT_SID;
_17const authToken = process.env.TWILIO_AUTH_TOKEN;
_17const client = twilio(accountSid, authToken);
_17async function deleteEnvironment() {
_17 await client.serverless.v1
_17 .services("ServiceSid")
_17 .environments("ZEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")