Skip to contentSkip to navigationSkip to topbar
On this page

Service Resource


A Service is the top-level scope of all other resources in the REST API. It contains all the objects in a Sync application. Services allow you to:

  • Create multiple environments (dev, stage, prod) under the same Twilio account with segregated data
  • Scope access to resources through the REST API
  • Configure the behavior of those resources in the scope of a Service

Service Properties

service-properties page anchor
Property nameTypeRequiredDescriptionChild properties
sidSID<IS>

Optional

Not PII

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

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

unique_namestring

Optional

An application-defined string that uniquely identifies the resource. It can be used in place of the resource's sid in the URL to address the resource. It is a read-only property, it cannot be assigned using REST API.


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 resource.


date_updatedstring<date-time>

Optional

The date and time in GMT when the 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.


webhook_urlstring<uri>

Optional

The URL we call when Sync objects are manipulated.


webhooks_from_rest_enabledboolean

Optional

Whether the Service instance should call webhook_url when the REST API is used to update Sync objects. The default is false.


reachability_webhooks_enabledboolean

Optional

Whether the service instance calls webhook_url when client endpoints connect to Sync. The default is false.


acl_enabledboolean

Optional

Whether token identities in the Service must be granted access to Sync objects by using the Permissions resource. It is disabled (false) by default.


reachability_debouncing_enabledboolean

Optional

Whether every endpoint_disconnected event should occur after a configurable delay. The default is false, where the endpoint_disconnected event occurs immediately after disconnection. When true, intervening reconnections can prevent the endpoint_disconnected event.


reachability_debouncing_windowinteger

Optional

The reachability event delay in milliseconds if reachability_debouncing_enabled = true. Must be between 1,000 and 30,000 and defaults to 5,000. This is the number of milliseconds after the last running client disconnects, and a Sync identity is declared offline, before webhook_url is called, if all endpoints remain offline. A reconnection from the same identity by any endpoint during this interval prevents the reachability event from occurring.

Default: 0

linksobject<uri-map>

Optional

The URLs of related resources.


Create a Service resource

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

Request body parameters

request-body-parameters page anchor
Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
FriendlyNamestring

Optional

A string that you assign to describe the resource.


WebhookUrlstring<uri>

Optional

The URL we should call when Sync objects are manipulated.


ReachabilityWebhooksEnabledboolean

Optional

Whether the service instance should call webhook_url when client endpoints connect to Sync. The default is false.


AclEnabledboolean

Optional

Whether token identities in the Service must be granted access to Sync objects by using the Permissions resource.


ReachabilityDebouncingEnabledboolean

Optional

Whether every endpoint_disconnected event should occur after a configurable delay. The default is false, where the endpoint_disconnected event occurs immediately after disconnection. When true, intervening reconnections can prevent the endpoint_disconnected event.


ReachabilityDebouncingWindowinteger

Optional

The reachability event delay in milliseconds if reachability_debouncing_enabled = true. Must be between 1,000 and 30,000 and defaults to 5,000. This is the number of milliseconds after the last running client disconnects, and a Sync identity is declared offline, before the webhook_url is called if all endpoints remain offline. A reconnection from the same identity by any endpoint during this interval prevents the call to webhook_url.


WebhooksFromRestEnabledboolean

Optional

Whether the Service instance should call webhook_url when the REST API is used to update Sync objects. The default is false.

Create Service resourceLink to code sample: Create Service resource
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.sync.v1.services.create();
12
13
console.log(service.sid);
14
}
15
16
createService();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"date_created": "2015-07-30T20:00:00Z",
4
"date_updated": "2015-07-30T20:00:00Z",
5
"friendly_name": "friendly_name",
6
"links": {
7
"documents": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents",
8
"lists": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists",
9
"maps": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps",
10
"streams": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams"
11
},
12
"sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
13
"unique_name": "unique_name",
14
"url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
15
"webhook_url": "http://www.example.com",
16
"webhooks_from_rest_enabled": false,
17
"reachability_webhooks_enabled": false,
18
"acl_enabled": true,
19
"reachability_debouncing_enabled": false,
20
"reachability_debouncing_window": 5000
21
}
Create Service resource with a webhook URLLink to code sample: Create Service resource with a webhook URL
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.sync.v1.services.create({
12
webhookUrl: "https://example.com/sync",
13
});
14
15
console.log(service.sid);
16
}
17
18
createService();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"date_created": "2015-07-30T20:00:00Z",
4
"date_updated": "2015-07-30T20:00:00Z",
5
"friendly_name": "friendly_name",
6
"links": {
7
"documents": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents",
8
"lists": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists",
9
"maps": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps",
10
"streams": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams"
11
},
12
"sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
13
"unique_name": "unique_name",
14
"url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
15
"webhook_url": "https://example.com/sync",
16
"webhooks_from_rest_enabled": false,
17
"reachability_webhooks_enabled": false,
18
"acl_enabled": true,
19
"reachability_debouncing_enabled": false,
20
"reachability_debouncing_window": 5000
21
}

Fetch a Service resource

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

Property nameTypeRequiredPIIDescription
Sidstringrequired

The SID 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.sync.v1.services("Sid").fetch();
12
13
console.log(service.sid);
14
}
15
16
fetchService();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"date_created": "2015-07-30T20:00:00Z",
4
"date_updated": "2015-07-30T20:00:00Z",
5
"friendly_name": "friendly_name",
6
"links": {
7
"documents": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents",
8
"lists": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists",
9
"maps": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps",
10
"streams": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams"
11
},
12
"sid": "Sid",
13
"unique_name": "unique_name",
14
"url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
15
"webhook_url": "http://www.example.com",
16
"webhooks_from_rest_enabled": false,
17
"reachability_webhooks_enabled": false,
18
"acl_enabled": false,
19
"reachability_debouncing_enabled": false,
20
"reachability_debouncing_window": 5000
21
}

Read multiple Service resources

read-multiple-service-resources page anchor
GET https://sync.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.sync.v1.services.list({ limit: 20 });
12
13
services.forEach((s) => console.log(s.sid));
14
}
15
16
listService();

Output

1
{
2
"meta": {
3
"first_page_url": "https://sync.twilio.com/v1/Services?PageSize=50&Page=0",
4
"key": "services",
5
"next_page_url": null,
6
"page": 0,
7
"page_size": 50,
8
"previous_page_url": null,
9
"url": "https://sync.twilio.com/v1/Services?PageSize=50&Page=0"
10
},
11
"services": []
12
}

Update a Service resource

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

Property nameTypeRequiredPIIDescription
Sidstringrequired

The SID of the Service resource to update.

Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
WebhookUrlstring<uri>

Optional

The URL we should call when Sync objects are manipulated.


FriendlyNamestring

Optional

A string that you assign to describe the resource.


ReachabilityWebhooksEnabledboolean

Optional

Whether the service instance should call webhook_url when client endpoints connect to Sync. The default is false.


AclEnabledboolean

Optional

Whether token identities in the Service must be granted access to Sync objects by using the Permissions resource.


ReachabilityDebouncingEnabledboolean

Optional

Whether every endpoint_disconnected event should occur after a configurable delay. The default is false, where the endpoint_disconnected event occurs immediately after disconnection. When true, intervening reconnections can prevent the endpoint_disconnected event.


ReachabilityDebouncingWindowinteger

Optional

The reachability event delay in milliseconds if reachability_debouncing_enabled = true. Must be between 1,000 and 30,000 and defaults to 5,000. This is the number of milliseconds after the last running client disconnects, and a Sync identity is declared offline, before the webhook is called if all endpoints remain offline. A reconnection from the same identity by any endpoint during this interval prevents the webhook from being called.


WebhooksFromRestEnabledboolean

Optional

Whether the Service instance should call webhook_url when the REST API is used to update Sync objects. The default is false.

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.sync.v1
12
.services("Sid")
13
.update({ webhookUrl: "https://www.example.com" });
14
15
console.log(service.sid);
16
}
17
18
updateService();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"date_created": "2015-07-30T20:00:00Z",
4
"date_updated": "2015-07-30T20:00:00Z",
5
"friendly_name": "friendly_name",
6
"links": {
7
"documents": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents",
8
"lists": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists",
9
"maps": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps",
10
"streams": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams"
11
},
12
"sid": "Sid",
13
"unique_name": "unique_name",
14
"url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
15
"webhook_url": "https://www.example.com",
16
"webhooks_from_rest_enabled": false,
17
"reachability_webhooks_enabled": false,
18
"acl_enabled": true,
19
"reachability_debouncing_enabled": false,
20
"reachability_debouncing_window": 5000
21
}

Delete a Service resource

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

Property nameTypeRequiredPIIDescription
Sidstringrequired

The SID 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.sync.v1.services("Sid").remove();
12
}
13
14
deleteService();

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.