Skip to contentSkip to navigationSkip to topbar
Rate this Page:

Map Resource


A Sync Map stores unordered JSON objects accessible via a developer-defined key. It is an unordered collection of individual Map items.

After you create a Map, use the MapItem resource to add, retrieve, update, and delete items from your Map.

A few notes about Sync Maps:

  • Full map modification history persists with every change that triggers a new revision.
  • Strict ordering of map mutation events is guaranteed, but the map item order is not defined.
  • By default, data persists permanently, but maps will expire and be deleted automatically if eviction is configured via the TTL parameter.

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


Map properties

map-properties page anchor

Each Map object root resource has the following properties.

Unique name and expiration date attributes are optional and may be null.

Resource properties
sidtype: SID<MP>Not PII

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


unique_nametype: stringPII 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.


service_sidtype: SID<IS>Not PII

The SID of the Sync Service(link takes you to an external page) the resource is associated with.


urltype: string<URI>Not PII

The absolute URL of the Sync Map resource.


linkstype: object<URI MAP>Not PII

The URLs of the Sync Map's nested resources.


revisiontype: stringNot PII

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


date_expirestype: string<DATE TIME>Not PII

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


date_createdtype: string<DATE TIME>Not PII

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


date_updatedtype: string<DATE TIME>Not PII

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_bytype: stringPII MTL: 30 days

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


Create a SyncMap resource

create-a-syncmap-resource page anchor
POST https://sync.twilio.com/v1/Services/{ServiceSid}/Maps

Create a new Map in this Service Instance, optionally giving it a unique name and assigning an expiration deadline.

Parameters

create-parameters page anchor
URI parameters
ServiceSidtype: stringNot PII
Path Parameter

The SID of the Sync Service(link takes you to an external page) to create the Sync Map in.


Request body parameters
UniqueNametype: stringPII MTL: 30 days

An application-defined string that uniquely identifies the resource. It can be used as an alternative to the sid in the URL path to address the resource.


Ttltype: integerNot PII

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


CollectionTtltype: integerNot PII

How long, in seconds(link takes you to an external page), before the Sync Map expires (time-to-live) and is deleted.

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

_11
// Download the helper library from https://www.twilio.com/docs/node/install
_11
// Find your Account SID and Auth Token at twilio.com/console
_11
// and set the environment variables. See http://twil.io/secure
_11
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11
const authToken = process.env.TWILIO_AUTH_TOKEN;
_11
const client = require('twilio')(accountSid, authToken);
_11
_11
client.sync.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.syncMaps
_11
.create()
_11
.then(sync_map => console.log(sync_map.sid));

Output

_16
{
_16
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"created_by": "created_by",
_16
"date_expires": "2015-07-30T21:00:00Z",
_16
"date_created": "2015-07-30T20:00:00Z",
_16
"date_updated": "2015-07-30T20:00:00Z",
_16
"links": {
_16
"items": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Maps/MPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Items",
_16
"permissions": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Maps/MPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Permissions"
_16
},
_16
"revision": "revision",
_16
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"sid": "MPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"unique_name": "unique_name",
_16
"url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Maps/MPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_16
}

Create a Map with a unique name

create-a-map-with-a-unique-name page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_11
// Download the helper library from https://www.twilio.com/docs/node/install
_11
// Find your Account SID and Auth Token at twilio.com/console
_11
// and set the environment variables. See http://twil.io/secure
_11
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11
const authToken = process.env.TWILIO_AUTH_TOKEN;
_11
const client = require('twilio')(accountSid, authToken);
_11
_11
client.sync.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.syncMaps
_11
.create({uniqueName: 'my_first_map'})
_11
.then(sync_map => console.log(sync_map.sid));

Output

_16
{
_16
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"created_by": "created_by",
_16
"date_expires": "2015-07-30T21:00:00Z",
_16
"date_created": "2015-07-30T20:00:00Z",
_16
"date_updated": "2015-07-30T20:00:00Z",
_16
"links": {
_16
"items": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Maps/MPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Items",
_16
"permissions": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Maps/MPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Permissions"
_16
},
_16
"revision": "revision",
_16
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"sid": "MPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"unique_name": "my_first_map",
_16
"url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Maps/MPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_16
}

Create a Map with an expiration deadline

create-a-map-with-an-expiration-deadline page anchor

Set TTL (in seconds) for expiring this Map instance

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

_11
// Download the helper library from https://www.twilio.com/docs/node/install
_11
// Find your Account SID and Auth Token at twilio.com/console
_11
// and set the environment variables. See http://twil.io/secure
_11
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11
const authToken = process.env.TWILIO_AUTH_TOKEN;
_11
const client = require('twilio')(accountSid, authToken);
_11
_11
client.sync.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.syncMaps
_11
.create({ttl: 600})
_11
.then(sync_map => console.log(sync_map.sid));

Output

_16
{
_16
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"created_by": "created_by",
_16
"date_expires": "2015-07-30T21:00:00Z",
_16
"date_created": "2015-07-30T20:00:00Z",
_16
"date_updated": "2015-07-30T20:00:00Z",
_16
"links": {
_16
"items": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Maps/MPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Items",
_16
"permissions": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Maps/MPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Permissions"
_16
},
_16
"revision": "revision",
_16
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"sid": "MPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"unique_name": "unique_name",
_16
"url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Maps/MPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_16
}


Fetch a SyncMap resource

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

URI parameters
ServiceSidtype: stringNot PII
Path Parameter

The SID of the Sync Service(link takes you to an external page) with the Sync Map resource to fetch.


Sidtype: stringNot PII
Path Parameter

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

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

_11
// Download the helper library from https://www.twilio.com/docs/node/install
_11
// Find your Account SID and Auth Token at twilio.com/console
_11
// and set the environment variables. See http://twil.io/secure
_11
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11
const authToken = process.env.TWILIO_AUTH_TOKEN;
_11
const client = require('twilio')(accountSid, authToken);
_11
_11
client.sync.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.syncMaps('MPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.fetch()
_11
.then(sync_map => console.log(sync_map.uniqueName));

Output

_16
{
_16
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"created_by": "created_by",
_16
"date_expires": "2015-07-30T21:00:00Z",
_16
"date_created": "2015-07-30T20:00:00Z",
_16
"date_updated": "2015-07-30T20:00:00Z",
_16
"links": {
_16
"items": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Maps/MPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Items",
_16
"permissions": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Maps/MPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Permissions"
_16
},
_16
"revision": "revision",
_16
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"sid": "MPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"unique_name": "unique_name",
_16
"url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Maps/MPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_16
}


Read multiple SyncMap resources

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

Retrieve a list of all Maps belonging to this Service Instance.

(information)

Info

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

URI parameters
ServiceSidtype: stringNot PII
Path Parameter

The SID of the Sync Service(link takes you to an external page) with the Sync Map resources to read.


PageSizetype: integerNot PII
Query Parameter

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


Pagetype: integerNot PII
Query Parameter

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


PageTokentype: stringNot PII
Query Parameter

The page token. This is provided by the API.

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

_11
// Download the helper library from https://www.twilio.com/docs/node/install
_11
// Find your Account SID and Auth Token at twilio.com/console
_11
// and set the environment variables. See http://twil.io/secure
_11
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11
const authToken = process.env.TWILIO_AUTH_TOKEN;
_11
const client = require('twilio')(accountSid, authToken);
_11
_11
client.sync.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.syncMaps
_11
.list({limit: 20})
_11
.then(syncMaps => syncMaps.forEach(s => console.log(s.sid)));

Output

_12
{
_12
"maps": [],
_12
"meta": {
_12
"first_page_url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Maps?PageSize=50&Page=0",
_12
"key": "maps",
_12
"next_page_url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Maps?PageSize=50&Page=1",
_12
"page": 0,
_12
"page_size": 50,
_12
"previous_page_url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Maps?PageSize=50&Page=0",
_12
"url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Maps?PageSize=50&Page=0"
_12
}
_12
}


Update a SyncMap resource

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

URI parameters
ServiceSidtype: stringNot PII
Path Parameter

The SID of the Sync Service(link takes you to an external page) with the Sync Map resource to update.


Sidtype: stringNot PII
Path Parameter

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


Request body parameters
Ttltype: integerNot PII

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


CollectionTtltype: integerNot PII

How long, in seconds(link takes you to an external page), before the Sync Map expires (time-to-live) and is deleted.

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

_11
// Download the helper library from https://www.twilio.com/docs/node/install
_11
// Find your Account SID and Auth Token at twilio.com/console
_11
// and set the environment variables. See http://twil.io/secure
_11
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11
const authToken = process.env.TWILIO_AUTH_TOKEN;
_11
const client = require('twilio')(accountSid, authToken);
_11
_11
client.sync.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.syncMaps('MPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.update({ttl: 1})
_11
.then(sync_map => console.log(sync_map.uniqueName));

Output

_16
{
_16
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"created_by": "created_by",
_16
"date_expires": "2015-07-30T21:00:00Z",
_16
"date_created": "2015-07-30T20:00:00Z",
_16
"date_updated": "2015-07-30T20:00:00Z",
_16
"links": {
_16
"items": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Maps/MPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Items",
_16
"permissions": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Maps/MPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Permissions"
_16
},
_16
"revision": "revision",
_16
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"sid": "MPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"unique_name": "unique_name",
_16
"url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Maps/MPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_16
}


Delete a Sync Map resource

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

Permanently delete a specific Map along with all items belonging to it from a given Sync Service Instance.

URI parameters
ServiceSidtype: stringNot PII
Path Parameter

The SID of the Sync Service(link takes you to an external page) with the Sync Map resource to delete.


Sidtype: stringNot PII
Path Parameter

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

Delete a Map with the REST API

delete-a-map-with-the-rest-api page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_10
// Download the helper library from https://www.twilio.com/docs/node/install
_10
// Find your Account SID and Auth Token at twilio.com/console
_10
// and set the environment variables. See http://twil.io/secure
_10
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10
const authToken = process.env.TWILIO_AUTH_TOKEN;
_10
const client = require('twilio')(accountSid, authToken);
_10
_10
client.sync.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10
.syncMaps('MPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10
.remove();

Delete a Map with the JavaScript SDK

delete-a-map-with-the-javascript-sdk page anchor

_10
syncClient.map('users').then(function (map) {
_10
map.removeMap().then(function () {
_10
console.log('map deleted');
_10
});
_10
});


Rate this Page: