Skip to contentSkip to navigationSkip to topbar
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 nameTypeRequiredDescriptionChild properties
sidSID<ZS>

Optional

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>

Optional

The SID of the Account that created the Service resource.

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

friendly_namestring

Optional

PII MTL: 7 days

The string that you assigned to describe the Service resource.


unique_namestring

Optional

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

Optional

Whether to inject Account credentials into a function invocation context.


ui_editableboolean

Optional

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


domain_basestring

Optional

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


date_updatedstring<date-time>

Optional

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>

Optional

The absolute URL of the Service resource.


linksobject<uri-map>

Optional

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
Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
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.


IncludeCredentialsboolean

Optional

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


UiEditableboolean

Optional

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

Create ServiceLink to code sample: Create Service
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function createService() {
11
const service = await client.serverless.v1.services.create({
12
friendlyName: "My New App",
13
includeCredentials: true,
14
uniqueName: "my-new-app",
15
});
16
17
console.log(service.sid);
18
}
19
20
createService();

Output

1
{
2
"sid": "ZS00000000000000000000000000000000",
3
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"friendly_name": "My New App",
5
"unique_name": "my-new-app",
6
"include_credentials": true,
7
"ui_editable": false,
8
"domain_base": "service-unique-1234",
9
"date_created": "2018-11-10T20:00:00Z",
10
"date_updated": "2018-11-10T20:00:00Z",
11
"url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000",
12
"links": {
13
"environments": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments",
14
"functions": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Functions",
15
"assets": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Assets",
16
"builds": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Builds"
17
}
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.

1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function fetchService() {
11
const service = await client.serverless.v1.services("Sid").fetch();
12
13
console.log(service.sid);
14
}
15
16
fetchService();

Output

1
{
2
"sid": "Sid",
3
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"friendly_name": "test-service",
5
"unique_name": "test-service-1",
6
"include_credentials": true,
7
"ui_editable": false,
8
"domain_base": "test-service-1-1234",
9
"date_created": "2018-11-10T20:00:00Z",
10
"date_updated": "2018-11-10T20:00:00Z",
11
"url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000",
12
"links": {
13
"environments": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments",
14
"functions": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Functions",
15
"assets": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Assets",
16
"builds": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Builds"
17
}
18
}

Read multiple Service resources

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

Property nameTypeRequiredPIIDescription
PageSizeinteger

Optional

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

Minimum: 1Maximum: 1000

Pageinteger

Optional

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

Minimum: 0

PageTokenstring

Optional

The page token. This is provided by the API.

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

Output

1
{
2
"services": [],
3
"meta": {
4
"first_page_url": "https://serverless.twilio.com/v1/Services?PageSize=50&Page=0",
5
"key": "services",
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?PageSize=50&Page=0"
11
}
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.

Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
IncludeCredentialsboolean

Optional

Whether to inject Account credentials into a function invocation context.


FriendlyNamestring

Optional

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


UiEditableboolean

Optional

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 UILink to code sample: Update a Service to be editable in the Console UI
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function updateService() {
11
const service = await client.serverless.v1
12
.services("Sid")
13
.update({ uiEditable: true });
14
15
console.log(service.sid);
16
}
17
18
updateService();

Output

1
{
2
"sid": "Sid",
3
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"friendly_name": "service-friendly-update",
5
"unique_name": "service-unique-update",
6
"include_credentials": true,
7
"ui_editable": true,
8
"domain_base": "service-unique-update-1234",
9
"date_created": "2018-11-10T20:00:00Z",
10
"date_updated": "2018-11-10T20:00:00Z",
11
"url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000",
12
"links": {
13
"environments": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Environments",
14
"functions": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Functions",
15
"assets": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Assets",
16
"builds": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Builds"
17
}
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.

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

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.