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

Service


Services are containers for your environments. You may only need one Service with many environments. When you begin working on a new application, you will likely want to create a new Service.

(warning)

Warning

The unique name of your service forms the first part of your Serverless domain and cannot be updated.


Service Properties

service-properties page anchor
Property nameTypePIIDescription
sidSID<ZS>
Not PII

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

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

account_sidSID<AC>

The SID of the Account that created the Service resource.

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

friendly_namestring
PII MTL: 7 days

The string that you assigned to describe the Service resource.


unique_namestring

A user-defined string that uniquely identifies the Service resource. It can be used in place of the Service resource's sid in the URL to address the Service resource.


include_credentialsboolean

Whether to inject Account credentials into a function invocation context.


ui_editableboolean

Whether the Service resource's properties and subresources can be edited via the UI.


domain_basestring

The base domain name for this Service, which is a combination of the unique name and a randomly generated string.


date_updatedstring<date-time>

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


urlstring<uri>

The absolute URL of the Service resource.


linksobject<uri-map>

The URLs of the Service's nested resources.


Create a Service resource

create-a-service-resource page anchor
POST https://serverless.twilio.com/v1/Services

Request body parameters

request-body-parameters page anchor
Property nameTypeRequiredPIIDescription
UniqueNamestringrequired

A user-defined string that uniquely identifies the Service resource. It can be used as an alternative to the sid in the URL path to address the Service resource. This value must be 50 characters or less in length and be unique.


FriendlyNamestringrequired

A descriptive string that you create to describe the Service resource. It can be a maximum of 255 characters.


IncludeCredentialsbooleanOptional

Whether to inject Account credentials into a function invocation context. The default value is true.


UiEditablebooleanOptional

Whether the Service's properties and subresources can be edited via the UI. The default value is false.

Create Service

create-service page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_20
// Download the helper library from https://www.twilio.com/docs/node/install
_20
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_20
_20
// Find your Account SID and Auth Token at twilio.com/console
_20
// and set the environment variables. See http://twil.io/secure
_20
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_20
const authToken = process.env.TWILIO_AUTH_TOKEN;
_20
const client = twilio(accountSid, authToken);
_20
_20
async function createService() {
_20
const service = await client.serverless.v1.services.create({
_20
friendlyName: "My New App",
_20
includeCredentials: true,
_20
uniqueName: "my-new-app",
_20
});
_20
_20
console.log(service.sid);
_20
}
_20
_20
createService();

Output

_18
{
_18
"sid": "ZS00000000000000000000000000000000",
_18
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_18
"friendly_name": "My New App",
_18
"unique_name": "my-new-app",
_18
"include_credentials": true,
_18
"ui_editable": false,
_18
"domain_base": "service-unique-1234",
_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",
_18
"links": {
_18
"environments": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments",
_18
"functions": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Functions",
_18
"assets": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Assets",
_18
"builds": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Builds"
_18
}
_18
}


Fetch a Service resource

fetch-a-service-resource page anchor
GET https://serverless.twilio.com/v1/Services/{Sid}

Property nameTypeRequiredPIIDescription
Sidstringrequired

The sid or unique_name of the Service resource to fetch.

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

_16
// Download the helper library from https://www.twilio.com/docs/node/install
_16
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_16
_16
// Find your Account SID and Auth Token at twilio.com/console
_16
// and set the environment variables. See http://twil.io/secure
_16
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_16
const authToken = process.env.TWILIO_AUTH_TOKEN;
_16
const client = twilio(accountSid, authToken);
_16
_16
async function fetchService() {
_16
const service = await client.serverless.v1.services("Sid").fetch();
_16
_16
console.log(service.sid);
_16
}
_16
_16
fetchService();

Output

_18
{
_18
"sid": "Sid",
_18
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_18
"friendly_name": "test-service",
_18
"unique_name": "test-service-1",
_18
"include_credentials": true,
_18
"ui_editable": false,
_18
"domain_base": "test-service-1-1234",
_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",
_18
"links": {
_18
"environments": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments",
_18
"functions": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Functions",
_18
"assets": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Assets",
_18
"builds": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Builds"
_18
}
_18
}


Read multiple Service resources

read-multiple-service-resources page anchor
GET https://serverless.twilio.com/v1/Services

Property nameTypeRequiredPIIDescription
PageSizeintegerOptional

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

Minimum: 1Maximum: 1000

PageintegerOptional

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

Minimum: 0

PageTokenstringOptional

The page token. This is provided by the API.

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

_16
// Download the helper library from https://www.twilio.com/docs/node/install
_16
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_16
_16
// Find your Account SID and Auth Token at twilio.com/console
_16
// and set the environment variables. See http://twil.io/secure
_16
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_16
const authToken = process.env.TWILIO_AUTH_TOKEN;
_16
const client = twilio(accountSid, authToken);
_16
_16
async function listService() {
_16
const services = await client.serverless.v1.services.list({ limit: 20 });
_16
_16
services.forEach((s) => console.log(s.sid));
_16
}
_16
_16
listService();

Output

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


Update a Service resource

update-a-service-resource page anchor
POST https://serverless.twilio.com/v1/Services/{Sid}

Property nameTypeRequiredPIIDescription
Sidstringrequired

The sid or unique_name of the Service resource to update.

Property nameTypeRequiredPIIDescription
IncludeCredentialsbooleanOptional

Whether to inject Account credentials into a function invocation context.


FriendlyNamestringOptional

A descriptive string that you create to describe the Service resource. It can be a maximum of 255 characters.


UiEditablebooleanOptional

Whether the Service resource's properties and subresources can be edited via the UI. The default value is false.

Update a Service to be editable in the Console UI

update-a-service-to-be-editable-in-the-console-ui page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_18
// Download the helper library from https://www.twilio.com/docs/node/install
_18
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18
_18
// Find your Account SID and Auth Token at twilio.com/console
_18
// and set the environment variables. See http://twil.io/secure
_18
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18
const authToken = process.env.TWILIO_AUTH_TOKEN;
_18
const client = twilio(accountSid, authToken);
_18
_18
async function updateService() {
_18
const service = await client.serverless.v1
_18
.services("Sid")
_18
.update({ uiEditable: true });
_18
_18
console.log(service.sid);
_18
}
_18
_18
updateService();

Output

_18
{
_18
"sid": "Sid",
_18
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_18
"friendly_name": "service-friendly-update",
_18
"unique_name": "service-unique-update",
_18
"include_credentials": true,
_18
"ui_editable": true,
_18
"domain_base": "service-unique-update-1234",
_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",
_18
"links": {
_18
"environments": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments",
_18
"functions": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Functions",
_18
"assets": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Assets",
_18
"builds": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Builds"
_18
}
_18
}


Delete a Service resource

delete-a-service-resource page anchor
DELETE https://serverless.twilio.com/v1/Services/{Sid}

Property nameTypeRequiredPIIDescription
Sidstringrequired

The sid or unique_name of the Service resource to delete.

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

_14
// Download the helper library from https://www.twilio.com/docs/node/install
_14
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_14
_14
// Find your Account SID and Auth Token at twilio.com/console
_14
// and set the environment variables. See http://twil.io/secure
_14
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_14
const authToken = process.env.TWILIO_AUTH_TOKEN;
_14
const client = twilio(accountSid, authToken);
_14
_14
async function deleteService() {
_14
await client.serverless.v1.services("Sid").remove();
_14
}
_14
_14
deleteService();


Rate this page: