Skip to contentSkip to navigationSkip to topbar
On this page

List Resource


A Sync List is an ordered collection of individual items, each storing separate JSON objects. Use Lists to push JSON into an ordered list and update existing items within the list.

After you create a List, you can add, retrieve, update, and delete items from your List with the ListItem resource. (That page contains more details on how items are stored in lists, including ordering, expiration, and limitations on each item's size.)

Lists can be created, updated, subscribed to and removed via the client JavaScript SDK. Servers wishing to manage these objects can do so via the REST API using the examples below.


List properties

list-properties page anchor
Property nameTypeRequiredDescriptionChild properties
sidSID<ES>Optional
Not PII

The unique string that we created to identify the Sync List resource.

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

unique_namestringOptional
PII MTL: 30 days

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.


account_sidSID<AC>Optional

The SID of the Account that created the Sync List resource.

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

service_sidSID<IS>Optional

The SID of the Sync Service the resource is associated with.

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

urlstring<uri>Optional

The absolute URL of the Sync List resource.


linksobject<uri-map>Optional

The URLs of the Sync List's nested resources.


revisionstringOptional

The current revision of the Sync List, represented as a string.


date_expiresstring<date-time>Optional

The date and time in GMT when the Sync List expires and will be deleted, specified in ISO 8601(link takes you to an external page) format. If the Sync List does not expire, this value is null. The Sync List might not be deleted immediately after it expires.


date_createdstring<date-time>Optional

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


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.


created_bystringOptional

The identity of the Sync List's creator. If the Sync List is created from the client SDK, the value matches the Access Token's identity field. If the Sync List was created from the REST API, the value is system.


POST https://sync.twilio.com/v1/Services/{ServiceSid}/Lists

Path parameters

path-parameters page anchor
Property nameTypeRequiredPIIDescription
ServiceSidstringrequired

The SID of the Sync Service to create the new Sync List in.

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

An application-defined string that uniquely identifies the resource. This value must be unique within its Service and it can be up to 320 characters long. The unique_name value can be used as an alternative to the sid in the URL path to address the resource.


TtlintegerOptional

Alias for collection_ttl. If both are provided, this value is ignored.


CollectionTtlintegerOptional

How long, in seconds, before the Sync List expires (time-to-live) and is deleted.

Create a ListLink to code sample: Create a List
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 createSyncList() {
11
const syncList = await client.sync.v1
12
.services("ServiceSid")
13
.syncLists.create();
14
15
console.log(syncList.sid);
16
}
17
18
createSyncList();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"created_by": "created_by",
4
"date_expires": "2015-07-30T21:00:00Z",
5
"date_created": "2015-07-30T20:00:00Z",
6
"date_updated": "2015-07-30T20:00:00Z",
7
"links": {
8
"items": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items",
9
"permissions": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions"
10
},
11
"revision": "revision",
12
"service_sid": "ServiceSid",
13
"sid": "ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"unique_name": "unique_name",
15
"url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
16
}

GET https://sync.twilio.com/v1/Services/{ServiceSid}/Lists/{Sid}

Property nameTypeRequiredPIIDescription
ServiceSidstringrequired

The SID of the Sync Service with the Sync List resource to fetch.


Sidstringrequired

The SID of the Sync List resource to fetch. Can be the Sync List resource's sid or its unique_name.

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 fetchSyncList() {
11
const syncList = await client.sync.v1
12
.services("ServiceSid")
13
.syncLists("Sid")
14
.fetch();
15
16
console.log(syncList.sid);
17
}
18
19
fetchSyncList();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"created_by": "created_by",
4
"date_expires": "2015-07-30T21:00:00Z",
5
"date_created": "2015-07-30T20:00:00Z",
6
"date_updated": "2015-07-30T20:00:00Z",
7
"links": {
8
"items": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items",
9
"permissions": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions"
10
},
11
"revision": "revision",
12
"service_sid": "ServiceSid",
13
"sid": "Sid",
14
"unique_name": "unique_name",
15
"url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
16
}

Read multiple List resources

read-multiple-list-resources page anchor
GET https://sync.twilio.com/v1/Services/{ServiceSid}/Lists

(information)

Info

By default, this will return the first 50 Lists. Supply a PageSize parameter to fetch up to 100 items at once. See paging for more information.

Property nameTypeRequiredPIIDescription
ServiceSidstringrequired

The SID of the Sync Service with the Sync List resources to read.

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.

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 listSyncList() {
11
const syncLists = await client.sync.v1
12
.services("ServiceSid")
13
.syncLists.list({ limit: 20 });
14
15
syncLists.forEach((s) => console.log(s.sid));
16
}
17
18
listSyncList();

Output

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

POST https://sync.twilio.com/v1/Services/{ServiceSid}/Lists/{Sid}

Property nameTypeRequiredPIIDescription
ServiceSidstringrequired

The SID of the Sync Service with the Sync List resource to update.


Sidstringrequired

The SID of the Sync List resource to update. Can be the Sync List resource's sid or its unique_name.

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

An alias for collection_ttl. If both are provided, this value is ignored.


CollectionTtlintegerOptional

How long, in seconds, before the Sync List expires (time-to-live) and is deleted.

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 updateSyncList() {
11
const syncList = await client.sync.v1
12
.services("ServiceSid")
13
.syncLists("Sid")
14
.update({ ttl: 42 });
15
16
console.log(syncList.sid);
17
}
18
19
updateSyncList();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"created_by": "created_by",
4
"date_expires": "2015-07-30T21:00:00Z",
5
"date_created": "2015-07-30T20:00:00Z",
6
"date_updated": "2015-07-30T20:00:00Z",
7
"links": {
8
"items": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items",
9
"permissions": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions"
10
},
11
"revision": "revision",
12
"service_sid": "ServiceSid",
13
"sid": "Sid",
14
"unique_name": "unique_name",
15
"url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
16
}

DELETE https://sync.twilio.com/v1/Services/{ServiceSid}/Lists/{Sid}

Permanently delete a List along with all items belonging to it.

Property nameTypeRequiredPIIDescription
ServiceSidstringrequired

The SID of the Sync Service with the Sync List resource to delete.


Sidstringrequired

The SID of the Sync List resource to delete. Can be the Sync List resource's sid or its unique_name.

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 deleteSyncList() {
11
await client.sync.v1
12
.services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
13
.syncLists("ESXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
14
.remove();
15
}
16
17
deleteSyncList();

Delete a List with the JavaScript SDK

delete-a-list-with-the-javascript-sdk page anchor
1
syncClient.list('example_list').then(function(list) {
2
list.removeList().then(function() {
3
console.log('deleted list');
4
});
5
});

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.