Menu

Expand
Rate this page:

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
sid<AC> Not PII

The SID of the Account that created the Map Item resource.

service_sid
sid<IS> Not PII

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

map_sid
sid<MP> Not PII

The SID of the Sync Map that contains the Map Item.

url
url Not PII

The absolute URL of the Map Item resource.

revision
string Not PII

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
date_time<iso8601> Not PII

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 null. The Map Item might not be deleted immediately after it expires.

date_created
date_time<iso8601> Not PII

The date and time in GMT when the resource was created specified in ISO 8601 format.

date_updated
date_time<iso8601> Not PII

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 identity field. If the Map Item was created from the REST API, the value is system.

Create a MapItem resource

post
https://sync.twilio.com/v1/Services/{ServiceSid}/Maps/{MapSid}/Items
Parameters
Parameters in REST API format
service_sid
Path
post sid_like<IS> Not PII

The SID of the Sync Service to create the Map Item in.

map_sid
Path
post sid_like<MP> Not PII

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

key
Required
post string PII MTL: 30 DAYS

The unique, user-defined key for the Map Item. Can be up to 320 characters long.

data
Required
post object PII MTL: 7 DAYS

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
post integer Not PII

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

item_ttl
Optional
post integer Not PII

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

collection_ttl
Optional
post integer Not PII

How long, in seconds, before the Map Item's parent Sync Map expires (time-to-live) and is deleted.

Example 1
Loading Code Sample...
        
        

        Create a MapItem with the REST API

        Example 2
        Loading Code Sample...
              
              
              Use the set method

              Add JSON to a Map

              Use the set method

              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
              Loading Code Sample...
                    
                    
                    Note that there are two separate events for map item adds and map item updates:

                    Subscribe to a MapItem addition with the JavaScript SDK

                    Note that there are two separate events for map item adds and map item updates:

                    Fetch a MapItem resource

                    get
                    https://sync.twilio.com/v1/Services/{ServiceSid}/Maps/{MapSid}/Items/{Key}
                    Parameters
                    Parameters in REST API format
                    service_sid
                    Path
                    get sid_like<IS> Not PII

                    The SID of the Sync Service with the Sync Map Item resource to fetch.

                    map_sid
                    Path
                    get sid_like<MP> Not PII

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

                    key
                    Path
                    get string PII MTL: 30 DAYS

                    The key value of the Sync Map Item resource to fetch.

                    Example 1
                    Loading Code Sample...
                          
                          
                          Request a MapItem by the key you defined when you created the item

                          Fetch a MapItem with the REST API

                          Request a MapItem by the key you defined when you created the item
                          Example 2
                          Loading Code Sample...
                                
                                
                                Fetches by a specific key

                                Fetch a single MapItem with the JavaScript SDK

                                Fetches by a specific key

                                Read all MapItem resources

                                get
                                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
                                get sid_like<IS> Not PII

                                The SID of the Sync Service with the Map Item resources to read.

                                map_sid
                                Path
                                get sid_like<MP> Not PII

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

                                order
                                Optional
                                get enum:query_result_order Not PII

                                How to order the Map Items returned by their key value. Can be: asc (ascending) or desc (descending) and the default is ascending. Map Items are ordered lexicographically by Item key.

                                from
                                Optional
                                get string Not PII

                                The key of the first Sync Map Item resource to read. See also bounds.

                                bounds
                                Optional
                                get enum:query_from_bound_type Not PII

                                Whether to include the Map Item referenced by the from parameter. Can be: inclusive to include the Map Item referenced by the from parameter or exclusive to start with the next Map Item. The default value is inclusive.

                                Example 1
                                Loading Code Sample...
                                      
                                      

                                      Read all MapItems with the REST API

                                      Example 2
                                      Loading Code Sample...
                                            
                                            

                                            Read: Query a Map with filters with the REST API

                                            Example 3
                                            Loading Code Sample...
                                                  
                                                  
                                                  This code sample displays the first item.

                                                  Get all MapItems with the JavaScript SDK

                                                  This code sample displays the first item.

                                                  Update a MapItem resource

                                                  post
                                                  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
                                                  post sid_like<IS> Not PII

                                                  The SID of the Sync Service with the Sync Map Item resource to update.

                                                  map_sid
                                                  Path
                                                  post sid_like<MP> Not PII

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

                                                  key
                                                  Path
                                                  post string PII MTL: 30 DAYS

                                                  The key value of the Sync Map Item resource to update.

                                                  data
                                                  Optional
                                                  post object PII MTL: 7 DAYS

                                                  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
                                                  post integer Not PII

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

                                                  item_ttl
                                                  Optional
                                                  post integer Not PII

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

                                                  collection_ttl
                                                  Optional
                                                  post integer Not PII

                                                  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 data or ttl is updated in the same request.

                                                  if_match
                                                  Header
                                                  post string Not PII

                                                  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
                                                  Loading Code Sample...
                                                        
                                                        

                                                        Update a MapItem with the REST API

                                                        Example 2
                                                        Loading Code Sample...
                                                              
                                                              

                                                              Update: Update a MapItem with Conflict Resolution with the REST API

                                                              Example 3
                                                              Loading Code Sample...
                                                                    
                                                                    
                                                                    Use the update method to change the data in a Map Item

                                                                    Update data in a MapItem with the JavaScript SDK

                                                                    Use the update method to change the data in a Map Item
                                                                    Example 4
                                                                    Loading Code Sample...
                                                                          
                                                                          
                                                                          Use mutate for more fine-grained control over updates.

                                                                          Mutate data in a MapItem using the JavaScript SDK

                                                                          Use mutate for more fine-grained control over updates.

                                                                          The mutate function helps your Javascript code respond to concurrent updates with versioned control. See the corresponding JavaScript SDK documentation for details.

                                                                          Example 5
                                                                          Loading Code Sample...
                                                                                
                                                                                
                                                                                Note that there are two separate events for map item adds and map item updates:

                                                                                Subscribe to a MapItem update with the JavaScript SDK

                                                                                Note that there are two separate events for map item adds and map item updates:

                                                                                Delete a MapItem resource

                                                                                delete
                                                                                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
                                                                                delete sid_like<IS> Not PII

                                                                                The SID of the Sync Service with the Sync Map Item resource to delete.

                                                                                map_sid
                                                                                Path
                                                                                delete sid_like<MP> Not PII

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

                                                                                key
                                                                                Path
                                                                                delete string PII MTL: 30 DAYS

                                                                                The key value of the Sync Map Item resource to delete.

                                                                                if_match
                                                                                Header
                                                                                delete string Not PII

                                                                                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
                                                                                Loading Code Sample...
                                                                                      
                                                                                      

                                                                                      Delete a MapItem with the REST API

                                                                                      Example 2
                                                                                      Loading Code Sample...
                                                                                            
                                                                                            

                                                                                            Delete: Delete a MapItem with Conflict Resolution using the REST API

                                                                                            Example 3
                                                                                            Loading Code Sample...
                                                                                                  
                                                                                                  
                                                                                                  Deletes the item with key "Taylor"

                                                                                                  Delete a single MapItem with the JavaScript SDK

                                                                                                  Deletes the item with key "Taylor"
                                                                                                  Rate this page:

                                                                                                  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.

                                                                                                  Loading Code Sample...
                                                                                                        
                                                                                                        
                                                                                                        

                                                                                                        Thank you for your feedback!

                                                                                                        Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

                                                                                                        Sending your feedback...
                                                                                                        🎉 Thank you for your feedback!
                                                                                                        Something went wrong. Please try again.

                                                                                                        Thanks for your feedback!

                                                                                                        thanks-feedback-gif