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.
Each Map object root resource has the following properties.
Unique name and expiration date attributes are optional and may be null.
Property name Type PII Description
The unique string that we created to identify the Sync Map resource.
Pattern: ^MP[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
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.
The SID of the Account that created the Sync Map resource.
Pattern: ^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Sync Service the resource is associated with.
Pattern: ^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The absolute URL of the Sync Map resource.
The URLs of the Sync Map's nested resources.
The current revision of the Sync Map, represented as a string.
date_expires string<date-time> 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_created string<date-time> date_updated string<date-time> 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
.
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.
Property name Type Required PII Description
Property name Type Required PII Description
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.
An alias for collection_ttl
. If both parameters are provided, this value is ignored.
CollectionTtl integer Optional How long, in seconds , before the Sync Map expires (time-to-live) and is deleted.
_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 // 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 async function createSyncMap() {
_16 const syncMap = await client.sync.v1.services("ServiceSid").syncMaps.create();
_16 console.log(syncMap.sid);
_16 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_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 "items": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items",
_16 "permissions": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions"
_16 "revision": "revision",
_16 "service_sid": "ServiceSid",
_16 "sid": "MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_16 "unique_name": "unique_name",
_16 "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_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 // 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 async function createSyncMap() {
_18 const syncMap = await client.sync.v1
_18 .services("ServiceSid")
_18 .syncMaps.create({ uniqueName: "my_first_map" });
_18 console.log(syncMap.sid);
_16 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_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 "items": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items",
_16 "permissions": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions"
_16 "revision": "revision",
_16 "service_sid": "ServiceSid",
_16 "sid": "MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_16 "unique_name": "my_first_map",
_16 "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
Set TTL (in seconds) for expiring this Map instance
_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 // 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 async function createSyncMap() {
_18 const syncMap = await client.sync.v1
_18 .services("ServiceSid")
_18 .syncMaps.create({ ttl: 600 });
_18 console.log(syncMap.sid);
_16 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_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 "items": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items",
_16 "permissions": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions"
_16 "revision": "revision",
_16 "service_sid": "ServiceSid",
_16 "sid": "MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_16 "unique_name": "unique_name",
_16 "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
GET https://sync.twilio.com/v1/Services/{ServiceSid}/Maps/{Sid}
Property name Type Required PII Description
The SID of the Sync Service with the Sync Map resource to fetch.
The SID of the Sync Map resource to fetch. Can be the Sync Map's sid
or its unique_name
.
_19 // Download the helper library from https://www.twilio.com/docs/node/install
_19 const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_19 // Find your Account SID and Auth Token at twilio.com/console
_19 // and set the environment variables. See http://twil.io/secure
_19 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19 const authToken = process.env.TWILIO_AUTH_TOKEN;
_19 const client = twilio(accountSid, authToken);
_19 async function fetchSyncMap() {
_19 const syncMap = await client.sync.v1
_19 .services("ServiceSid")
_19 console.log(syncMap.sid);
_16 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_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 "items": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items",
_16 "permissions": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions"
_16 "revision": "revision",
_16 "service_sid": "ServiceSid",
_16 "unique_name": "unique_name",
_16 "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
GET https://sync.twilio.com/v1/Services/{ServiceSid}/Maps
Retrieve a list of all Maps belonging to this Service Instance.
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.
Property name Type Required PII Description
The SID of the Sync Service with the Sync Map resources to read.
Property name Type Required PII Description
How many resources to return in each list page. The default is 50, and the maximum is 1000.
Minimum: 1
Maximum: 1000
The page index. This value is simply for client state.
Minimum: 0
The page token. This is provided by the API.
_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 // 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 async function listSyncMap() {
_18 const syncMaps = await client.sync.v1
_18 .services("ServiceSid")
_18 .syncMaps.list({ limit: 20 });
_18 syncMaps.forEach((s) => console.log(s.sid));
_12 "first_page_url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps?PageSize=50&Page=0",
_12 "next_page_url": null,
_12 "previous_page_url": null,
_12 "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps?PageSize=50&Page=0"
POST https://sync.twilio.com/v1/Services/{ServiceSid}/Maps/{Sid}
Property name Type Required PII Description
The SID of the Sync Service with the Sync Map resource to update.
The SID of the Sync Map resource to update. Can be the Sync Map's sid
or its unique_name
.
Property name Type Required PII Description
An alias for collection_ttl
. If both parameters are provided, this value is ignored.
CollectionTtl integer Optional How long, in seconds , before the Sync Map expires (time-to-live) and is deleted.
_19 // Download the helper library from https://www.twilio.com/docs/node/install
_19 const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_19 // Find your Account SID and Auth Token at twilio.com/console
_19 // and set the environment variables. See http://twil.io/secure
_19 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19 const authToken = process.env.TWILIO_AUTH_TOKEN;
_19 const client = twilio(accountSid, authToken);
_19 async function updateSyncMap() {
_19 const syncMap = await client.sync.v1
_19 .services("ServiceSid")
_19 .update({ ttl: 278 });
_19 console.log(syncMap.sid);
_16 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_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 "items": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items",
_16 "permissions": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions"
_16 "revision": "revision",
_16 "service_sid": "ServiceSid",
_16 "unique_name": "unique_name",
_16 "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
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.
Property name Type Required PII Description
The SID of the Sync Service with the Sync Map resource to delete.
The SID of the Sync Map resource to delete. Can be the Sync Map's sid
or its unique_name
.
_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 // 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 async function deleteSyncMap() {
_14 await client.sync.v1.services("ServiceSid").syncMaps("Sid").remove();
_10 syncClient.map('users').then(function (map) {
_10 map.removeMap().then(function () {
_10 console.log('map deleted');