Sync MapItem Resource
A Sync MapItem is an individual item that belongs to one or more of your Sync Maps. See the full API reference documentation for the Sync Map resource here.
You need to create a Map first before you can use this resource to create, read, update, and delete items.
Sync MapItems:
- can be inserted, updated, removed and iterated
- are limited to 16KB of data
Sync MapItem properties
Resource Properties in REST API format | |
---|---|
key
|
The unique, user-defined key for the Map Item. |
account_sid
|
The SID of the Account that created the Map Item resource. |
service_sid
|
The SID of the Sync Service the resource is associated with. |
map_sid
|
The SID of the Sync Map that contains the Map Item. |
url
|
The absolute URL of the Map Item resource. |
revision
|
The current revision of the Map Item, represented as a string. |
data
|
An arbitrary, schema-less object that the Map Item stores. Can be up to 16 KiB in length. |
date_expires
|
The date and time in GMT when the Map Item expires and will be deleted, specified in ISO 8601 format. If the Map Item does not expire, this value is |
date_created
|
The date and time in GMT when the resource was created specified in ISO 8601 format. |
date_updated
|
The date and time in GMT when the resource was last updated specified in ISO 8601 format. |
created_by
|
The identity of the Map Item's creator. If the Map Item is created from the client SDK, the value matches the Access Token's |
Create a MapItem resource
https://sync.twilio.com/v1/Services/{ServiceSid}/Maps/{MapSid}/Items
Parameters
Parameters in REST API format | |
---|---|
service_sid
Path
|
The SID of the Sync Service to create the Map Item in. |
map_sid
Path
|
The SID of the Sync Map to add the new Map Item to. Can be the Sync Map resource's |
key
Required
|
The unique, user-defined key for the Map Item. Can be up to 320 characters long. |
data
Required
|
A JSON string that represents an arbitrary, schema-less object that the Map Item stores. Can be up to 16 KiB in length. |
ttl
Optional
|
An alias for |
item_ttl
Optional
|
How long, in seconds, before the Map Item expires (time-to-live) and is deleted. |
collection_ttl
Optional
|
How long, in seconds, before the Map Item's parent Sync Map expires (time-to-live) and is deleted. |
Example 1
Example 2
Please note: You can also use the set
method to update data in existing JSON data in a Map. However, using set
will overwrite any existing data in a MapItem.
Example 3
Fetch a MapItem resource
https://sync.twilio.com/v1/Services/{ServiceSid}/Maps/{MapSid}/Items/{Key}
Parameters
Parameters in REST API format | |
---|---|
service_sid
Path
|
The SID of the Sync Service with the Sync Map Item resource to fetch. |
map_sid
Path
|
The SID of the Sync Map with the Sync Map Item resource to fetch. Can be the Sync Map resource's |
key
Path
|
The |
Example 1
Example 2
Read all MapItem resources
https://sync.twilio.com/v1/Services/{ServiceSid}/Maps/{MapSid}/Items
MapItem read access is performed using the key
that provided as an arbitrary string to identify the item.
By default, this will return the first 50 MapItems. Supply a PageSize parameter to fetch up to 100 items at once. See paging for more information.
Parameters
Parameters in REST API format | |
---|---|
service_sid
Path
|
The SID of the Sync Service with the Map Item resources to read. |
map_sid
Path
|
The SID of the Sync Map with the Sync Map Item resource to fetch. Can be the Sync Map resource's |
order
Optional
|
How to order the Map Items returned by their |
from
Optional
|
The |
bounds
Optional
|
Whether to include the Map Item referenced by the |
Example 1
Example 2
Example 3
Update a MapItem resource
https://sync.twilio.com/v1/Services/{ServiceSid}/Maps/{MapSid}/Items/{Key}
MapItem update access is performed using the key
that provided as an arbitrary string to identify the item.
Parameters
Parameters in REST API format | |
---|---|
service_sid
Path
|
The SID of the Sync Service with the Sync Map Item resource to update. |
map_sid
Path
|
The SID of the Sync Map with the Sync Map Item resource to update. Can be the Sync Map resource's |
key
Path
|
The |
data
Optional
|
A JSON string that represents an arbitrary, schema-less object that the Map Item stores. Can be up to 16 KiB in length. |
ttl
Optional
|
An alias for |
item_ttl
Optional
|
How long, in seconds, before the Map Item expires (time-to-live) and is deleted. |
collection_ttl
Optional
|
How long, in seconds, before the Map Item's parent Sync Map expires (time-to-live) and is deleted. This parameter can only be used when the Map Item's |
if_match
Header
|
If provided, applies this mutation if (and only if) the “revision” field of this [map item] matches the provided value. This matches the semantics of (and is implemented with) the HTTP If-Match header. |
Example 1
Example 2
Example 3
Example 4
The mutate
function helps your Javascript code respond to concurrent updates with versioned control. See the corresponding JavaScript SDK documentation for details.
Example 5
Delete a MapItem resource
https://sync.twilio.com/v1/Services/{ServiceSid}/Maps/{MapSid}/Items/{Key}
Permanently delete a specific item from an existing Map.
Parameters
Parameters in REST API format | |
---|---|
service_sid
Path
|
The SID of the Sync Service with the Sync Map Item resource to delete. |
map_sid
Path
|
The SID of the Sync Map with the Sync Map Item resource to delete. Can be the Sync Map resource's |
key
Path
|
The |
if_match
Header
|
If provided, applies this mutation if (and only if) the “revision” field of this [map item] matches the provided value. This matches the semantics of (and is implemented with) the HTTP If-Match header. |
Example 1
Example 2
Example 3
Need some help?
We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.