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:
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.
The unique string that we created to identify the Sync Map resource.
^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.
^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Sync Service the resource is associated with.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The date and time in GMT when the Sync Map expires and will be deleted, specified in ISO 8601 format. If the Sync Map does not expire, this value is null
. The Sync Map might not be deleted immediately after it expires.
The date and time in GMT when the resource was created specified in ISO 8601 format.
The date and time in GMT when the resource was last updated specified in ISO 8601 format.
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.
The SID of the Sync Service to create the Sync Map in.
application/x-www-form-urlencoded
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.
How long, in seconds, before the Sync Map expires (time-to-live) and is deleted.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createSyncMap() {11const syncMap = await client.sync.v1.services("ServiceSid").syncMaps.create();1213console.log(syncMap.sid);14}1516createSyncMap();
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/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items",9"permissions": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions"10},11"revision": "revision",12"service_sid": "ServiceSid",13"sid": "MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14"unique_name": "unique_name",15"url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"16}
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createSyncMap() {11const syncMap = await client.sync.v112.services("ServiceSid")13.syncMaps.create({ uniqueName: "my_first_map" });1415console.log(syncMap.sid);16}1718createSyncMap();
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/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items",9"permissions": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions"10},11"revision": "revision",12"service_sid": "ServiceSid",13"sid": "MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14"unique_name": "my_first_map",15"url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"16}
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createSyncMap() {11const syncMap = await client.sync.v112.services("ServiceSid")13.syncMaps.create({ ttl: 600 });1415console.log(syncMap.sid);16}1718createSyncMap();
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/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items",9"permissions": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions"10},11"revision": "revision",12"service_sid": "ServiceSid",13"sid": "MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14"unique_name": "unique_name",15"url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"16}
GET https://sync.twilio.com/v1/Services/{ServiceSid}/Maps/{Sid}
The SID of the Sync Map resource to fetch. Can be the Sync Map's sid
or its unique_name
.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function fetchSyncMap() {11const syncMap = await client.sync.v112.services("ServiceSid")13.syncMaps("Sid")14.fetch();1516console.log(syncMap.sid);17}1819fetchSyncMap();
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/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items",9"permissions": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/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/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"16}
GET https://sync.twilio.com/v1/Services/{ServiceSid}/Maps
Retrieve a list of all Maps belonging to this Service Instance.
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.
The SID of the Sync Service with the Sync Map resources to read.
How many resources to return in each list page. The default is 50, and the maximum is 1000.
1
Maximum: 1000
The page token. This is provided by the API.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function listSyncMap() {11const syncMaps = await client.sync.v112.services("ServiceSid")13.syncMaps.list({ limit: 20 });1415syncMaps.forEach((s) => console.log(s.sid));16}1718listSyncMap();
1{2"maps": [],3"meta": {4"first_page_url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps?PageSize=50&Page=0",5"key": "maps",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/Maps?PageSize=50&Page=0"11}12}
POST https://sync.twilio.com/v1/Services/{ServiceSid}/Maps/{Sid}
The SID of the Sync Map resource to update. Can be the Sync Map's sid
or its unique_name
.
application/x-www-form-urlencoded
An alias for collection_ttl
. If both parameters are provided, this value is ignored.
How long, in seconds, before the Sync Map expires (time-to-live) and is deleted.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function updateSyncMap() {11const syncMap = await client.sync.v112.services("ServiceSid")13.syncMaps("Sid")14.update({ ttl: 42 });1516console.log(syncMap.sid);17}1819updateSyncMap();
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/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items",9"permissions": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/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/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"16}
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.
The SID of the Sync Map resource to delete. Can be the Sync Map's sid
or its unique_name
.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function deleteSyncMap() {11await client.sync.v1.services("ServiceSid").syncMaps("Sid").remove();12}1314deleteSyncMap();
1syncClient.map('users').then(function (map) {2map.removeMap().then(function () {3console.log('map deleted');4});5});