# Sync MapItem Resource

A Sync **MapItem** is an individual item that belongs to one or more of your [Sync Maps](/docs/sync/api/map-resource). See the full API reference documentation for the Sync Map resource [here](/docs/sync/api/map-resource).

> \[!NOTE]
>
> You need to [create a Map](/docs/sync/api/map-resource) 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

```json
{"type":"object","refName":"sync.v1.service.sync_map.sync_map_item","modelName":"sync_v1_service_sync_map_sync_map_item","properties":{"key":{"type":"string","nullable":true,"description":"The unique, user-defined key for the Map Item.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}},"account_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^AC[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the [Account](/docs/iam/api/account) that created the Map Item resource."},"service_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^IS[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the [Sync Service](/docs/sync/api/service) the resource is associated with."},"map_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^MP[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the Sync Map that contains the Map Item."},"url":{"type":"string","format":"uri","nullable":true,"description":"The absolute URL of the Map Item resource."},"revision":{"type":"string","nullable":true,"description":"The current revision of the Map Item, represented as a string."},"data":{"nullable":true,"description":"An arbitrary, schema-less object that the Map Item stores. Can be up to 16 KiB in length.","x-twilio":{"pii":{"handling":"sensitive","deleteSla":7}}},"date_expires":{"type":"string","format":"date-time","nullable":true,"description":"The date and time in GMT when the Map Item expires and will be deleted, specified in [ISO 8601](https://en.wikipedia.org/wiki/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":{"type":"string","format":"date-time","nullable":true,"description":"The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format."},"date_updated":{"type":"string","format":"date-time","nullable":true,"description":"The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format."},"created_by":{"type":"string","nullable":true,"description":"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`.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}}}}
```

## Create a MapItem resource

`POST https://sync.twilio.com/v1/Services/{ServiceSid}/Maps/{MapSid}/Items`

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the [Sync Service](/docs/sync/api/service) to create the Map Item in.","schema":{"type":"string"},"required":true},{"name":"MapSid","in":"path","description":"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`.","schema":{"type":"string"},"required":true}]
```

### Request body parameters

```json
{"schema":{"type":"object","title":"CreateSyncMapItemRequest","required":["Key","Data"],"properties":{"Key":{"type":"string","description":"The unique, user-defined key for the Map Item. Can be up to 320 characters long.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}},"Data":{"description":"A JSON string that represents an arbitrary, schema-less object that the Map Item stores. Can be up to 16 KiB in length.","x-twilio":{"pii":{"handling":"sensitive","deleteSla":7}}},"Ttl":{"type":"integer","description":"An alias for `item_ttl`. If both parameters are provided, this value is ignored."},"ItemTtl":{"type":"integer","description":"How long, [in seconds](/docs/sync/limits#sync-payload-limits), before the Map Item expires (time-to-live) and is deleted."},"CollectionTtl":{"type":"integer","description":"How long, [in seconds](/docs/sync/limits#sync-payload-limits), before the Map Item's parent Sync Map expires (time-to-live) and is deleted."}}},"examples":{"create":{"value":{"lang":"json","value":"{\n  \"Data\": \"{}\",\n  \"Key\": \"key\",\n  \"Ttl\": 3600\n}","meta":"","code":"{\n  \"Data\": \"{}\",\n  \"Key\": \"key\",\n  \"Ttl\": 3600\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"Data\"","#7EE787"],[":","#C9D1D9"]," ",["\"{}\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Key\"","#7EE787"],[":","#C9D1D9"]," ",["\"key\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Ttl\"","#7EE787"],[":","#C9D1D9"]," ",["3600","#79C0FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}}},"encodingType":"application/x-www-form-urlencoded","conditionalParameterMap":{}}
```

{" "}

Create a MapItem with the REST API

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function createSyncMapItem() {
  const syncMapItem = await client.sync.v1
    .services("ServiceSid")
    .syncMaps("MapSid")
    .syncMapItems.create({
      data: {
        name: "Foo Bar",
        level: 30,
        username: "foo_bar",
      },
      key: "foo",
    });

  console.log(syncMapItem.key);
}

createSyncMapItem();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

sync_map_item = (
    client.sync.v1.services("ServiceSid")
    .sync_maps("MapSid")
    .sync_map_items.create(
        key="foo", data={"name": "Foo Bar", "level": 30, "username": "foo_bar"}
    )
)

print(sync_map_item.key)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Sync.V1.Service.SyncMap;
using System.Threading.Tasks;
using System.Collections.Generic;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var syncMapItem = await SyncMapItemResource.CreateAsync(
            key: "foo",
            data: new Dictionary<
                string,
                Object>() { { "name", "Foo Bar" }, { "level", 30 }, { "username", "foo_bar" } },
            pathServiceSid: "ServiceSid",
            pathMapSid: "MapSid");

        Console.WriteLine(syncMapItem.Key);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import java.util.HashMap;
import com.twilio.Twilio;
import com.twilio.rest.sync.v1.service.syncmap.SyncMapItem;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        SyncMapItem syncMapItem = SyncMapItem
                                      .creator("ServiceSid",
                                          "MapSid",
                                          "foo",
                                          new HashMap<String, Object>() {
                                              {
                                                  put("name", "Foo Bar");
                                                  put("level", 30);
                                                  put("username", "foo_bar");
                                              }
                                          })
                                      .create();

        System.out.println(syncMapItem.getKey());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	sync "github.com/twilio/twilio-go/rest/sync/v1"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &sync.CreateSyncMapItemParams{}
	params.SetKey("foo")
	params.SetData(map[string]interface{}{
		"name":     "Foo Bar",
		"level":    30,
		"username": "foo_bar",
	})

	resp, err := client.SyncV1.CreateSyncMapItem("ServiceSid",
		"MapSid",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Key != nil {
			fmt.Println(*resp.Key)
		} else {
			fmt.Println(resp.Key)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$sync_map_item = $twilio->sync->v1
    ->services("ServiceSid")
    ->syncMaps("MapSid")
    ->syncMapItems->create(
        "foo", // Key
        [
            "name" => "Foo Bar",
            "level" => 30,
            "username" => "foo_bar",
        ] // Data
    );

print $sync_map_item->key;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

sync_map_item = @client
                .sync
                .v1
                .services('ServiceSid')
                .sync_maps('MapSid')
                .sync_map_items
                .create(
                  key: 'foo',
                  data: {
                    'name' => 'Foo Bar',
                    'level' => 30,
                    'username' => 'foo_bar'
                  }
                )

puts sync_map_item.key
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:sync:v1:services:maps:items:create \
   --service-sid ServiceSid \
   --map-sid MapSid \
   --key foo \
   --data "{\"name\":\"Foo Bar\",\"level\":30,\"username\":\"foo_bar\"}"
```

```bash
DATA_OBJ=$(cat << EOF
{
  "name": "Foo Bar",
  "level": 30,
  "username": "foo_bar"
}
EOF
)
curl -X POST "https://sync.twilio.com/v1/Services/ServiceSid/Maps/MapSid/Items" \
--data-urlencode "Key=foo" \
--data-urlencode "Data=$DATA_OBJ" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "created_by": "created_by",
  "data": {
    "name": "Foo Bar",
    "level": 30,
    "username": "foo_bar"
  },
  "date_expires": "2015-07-30T21:00:00Z",
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z",
  "key": "foo",
  "map_sid": "MapSid",
  "revision": "revision",
  "service_sid": "ServiceSid",
  "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/key"
}
```

```js title="Add JSON to a Map" description="Use the set method"
syncClient.map("users").then(function (map) {
  map
    .set("Taylor", {
      phone_number: 12345678,
      country: "UK",
    })
    .then(function (item) {
      console.log("Added: ", item.key);
    })
    .catch(function (err) {
      console.error(err);
    });
});
```

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

```js title="Subscribe to a MapItem addition with the JavaScript SDK" description="Note that there are two separate events for map item adds and map item updates:"
// !mark(2:5)
syncClient.map("users").then(function (map) {
  map.on("itemAdded", function (item) {
    console.log("key", item.key);
    console.log("JSON data", item.value);
  });

  //Note that there are two separate events for map item adds and map item updates:
  map.on("itemUpdated", function (item) {
    console.log("key", item.key);
    console.log("JSON data", item.value);
  });
});
```

## Fetch a MapItem resource

`GET https://sync.twilio.com/v1/Services/{ServiceSid}/Maps/{MapSid}/Items/{Key}`

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the [Sync Service](/docs/sync/api/service) with the Sync Map Item resource to fetch.","schema":{"type":"string"},"required":true},{"name":"MapSid","in":"path","description":"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`.","schema":{"type":"string"},"required":true},{"name":"Key","in":"path","description":"The `key` value of the Sync Map Item resource to fetch.","schema":{"type":"string"},"x-twilio":{"pii":{"handling":"standard","deleteSla":30}},"required":true}]
```

{" "}

Fetch a MapItem with the REST API

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function fetchSyncMapItem() {
  const syncMapItem = await client.sync.v1
    .services("ServiceSid")
    .syncMaps("MapSid")
    .syncMapItems("foo")
    .fetch();

  console.log(syncMapItem.key);
}

fetchSyncMapItem();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

sync_map_item = (
    client.sync.v1.services("ServiceSid")
    .sync_maps("MapSid")
    .sync_map_items("foo")
    .fetch()
)

print(sync_map_item.key)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Sync.V1.Service.SyncMap;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var syncMapItem = await SyncMapItemResource.FetchAsync(
            pathServiceSid: "ServiceSid", pathMapSid: "MapSid", pathKey: "foo");

        Console.WriteLine(syncMapItem.Key);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.sync.v1.service.syncmap.SyncMapItem;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        SyncMapItem syncMapItem = SyncMapItem.fetcher("ServiceSid", "MapSid", "foo").fetch();

        System.out.println(syncMapItem.getKey());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	resp, err := client.SyncV1.FetchSyncMapItem("ServiceSid",
		"MapSid",
		"foo")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Key != nil {
			fmt.Println(*resp.Key)
		} else {
			fmt.Println(resp.Key)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$sync_map_item = $twilio->sync->v1
    ->services("ServiceSid")
    ->syncMaps("MapSid")
    ->syncMapItems("foo")
    ->fetch();

print $sync_map_item->key;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

sync_map_item = @client
                .sync
                .v1
                .services('ServiceSid')
                .sync_maps('MapSid')
                .sync_map_items('foo')
                .fetch

puts sync_map_item.key
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:sync:v1:services:maps:items:fetch \
   --service-sid ServiceSid \
   --map-sid MapSid \
   --key foo
```

```bash
curl -X GET "https://sync.twilio.com/v1/Services/ServiceSid/Maps/MapSid/Items/foo" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "created_by": "created_by",
  "data": {},
  "date_expires": "2015-07-30T21:00:00Z",
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z",
  "key": "foo",
  "map_sid": "MapSid",
  "revision": "revision",
  "service_sid": "ServiceSid",
  "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/key"
}
```

```js title="Fetch a single MapItem with the JavaScript SDK" description="Fetches by a specific key"
syncClient.map("users").then(function (map) {
  map.get("Taylor").then(function (item) {
    console.log(item.value);
  });
});
```

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

{" "}

> \[!NOTE]
>
> By default, this will return the first 50 MapItems. Supply a PageSize
> parameter to fetch up to 100 items at once. See
> [paging](/docs/usage/twilios-response#pagination)
> for more information.

{" "}

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the [Sync Service](/docs/sync/api/service) with the Map Item resources to read.","schema":{"type":"string"},"required":true},{"name":"MapSid","in":"path","description":"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`.","schema":{"type":"string"},"required":true}]
```

### Query parameters

```json
[{"name":"Order","in":"query","description":"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](https://en.wikipedia.org/wiki/Lexicographical_order) by Item key.","schema":{"type":"string","enum":["asc","desc"],"refName":"sync_map_item_enum_query_result_order","modelName":"sync_map_item_enum_query_result_order"},"examples":{"readEmpty":{"value":"asc"},"readFull":{"value":"asc"}}},{"name":"From","in":"query","description":"The `key` of the first Sync Map Item resource to read. See also `bounds`.","schema":{"type":"string"},"examples":{"readEmpty":{"value":"from"},"readFull":{"value":"from"}}},{"name":"Bounds","in":"query","description":"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`.","schema":{"type":"string","enum":["inclusive","exclusive"],"refName":"sync_map_item_enum_query_from_bound_type","modelName":"sync_map_item_enum_query_from_bound_type"},"examples":{"readEmpty":{"value":"inclusive"},"readFull":{"value":"inclusive"}}},{"name":"PageSize","in":"query","description":"How many resources to return in each list page. The default is 50, and the maximum is 100.","schema":{"type":"integer","format":"int64","minimum":1,"maximum":100}},{"name":"Page","in":"query","description":"The page index. This value is simply for client state.","schema":{"type":"integer","minimum":0}},{"name":"PageToken","in":"query","description":"The page token. This is provided by the API.","schema":{"type":"string"}}]
```

{" "}

Read all MapItems with the REST API

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function listSyncMapItem() {
  const syncMapItems = await client.sync.v1
    .services("ServiceSid")
    .syncMaps("MapSid")
    .syncMapItems.list({ limit: 20 });

  syncMapItems.forEach((s) => console.log(s.key));
}

listSyncMapItem();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

sync_map_items = (
    client.sync.v1.services("ServiceSid")
    .sync_maps("MapSid")
    .sync_map_items.list(limit=20)
)

for record in sync_map_items:
    print(record.key)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Sync.V1.Service.SyncMap;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var syncMapItems = await SyncMapItemResource.ReadAsync(
            pathServiceSid: "ServiceSid", pathMapSid: "MapSid", limit: 20);

        foreach (var record in syncMapItems) {
            Console.WriteLine(record.Key);
        }
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.sync.v1.service.syncmap.SyncMapItem;
import com.twilio.base.ResourceSet;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        ResourceSet<SyncMapItem> syncMapItems = SyncMapItem.reader("ServiceSid", "MapSid").limit(20).read();

        for (SyncMapItem record : syncMapItems) {
            System.out.println(record.getKey());
        }
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	sync "github.com/twilio/twilio-go/rest/sync/v1"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &sync.ListSyncMapItemParams{}
	params.SetLimit(20)

	resp, err := client.SyncV1.ListSyncMapItem("ServiceSid",
		"MapSid",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		for record := range resp {
			if resp[record].Key != nil {
				fmt.Println(*resp[record].Key)
			} else {
				fmt.Println(resp[record].Key)
			}
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$syncMapItems = $twilio->sync->v1
    ->services("ServiceSid")
    ->syncMaps("MapSid")
    ->syncMapItems->read([], 20);

foreach ($syncMapItems as $record) {
    print $record->key;
}
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

sync_map_items = @client
                 .sync
                 .v1
                 .services('ServiceSid')
                 .sync_maps('MapSid')
                 .sync_map_items
                 .list(limit: 20)

sync_map_items.each do |record|
   puts record.key
end
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:sync:v1:services:maps:items:list \
   --service-sid ServiceSid \
   --map-sid MapSid
```

```bash
curl -X GET "https://sync.twilio.com/v1/Services/ServiceSid/Maps/MapSid/Items?PageSize=20" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "items": [],
  "meta": {
    "first_page_url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items?From=from&Bounds=inclusive&Order=asc&PageSize=50&Page=0",
    "key": "items",
    "next_page_url": null,
    "page": 0,
    "page_size": 50,
    "previous_page_url": null,
    "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items?From=from&Bounds=inclusive&Order=asc&PageSize=50&Page=0"
  }
}
```

{" "}

Read: Query a Map with filters with the REST API

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function listSyncMapItem() {
  const syncMapItems = await client.sync.v1
    .services("ServiceSid")
    .syncMaps("MapSid")
    .syncMapItems.list({
      from: "foo",
      order: "asc",
      limit: 20,
    });

  syncMapItems.forEach((s) => console.log(s.key));
}

listSyncMapItem();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

sync_map_items = (
    client.sync.v1.services("ServiceSid")
    .sync_maps("MapSid")
    .sync_map_items.list(order="asc", from_="foo", limit=20)
)

for record in sync_map_items:
    print(record.key)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Sync.V1.Service.SyncMap;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var syncMapItems = await SyncMapItemResource.ReadAsync(
            pathServiceSid: "ServiceSid",
            pathMapSid: "MapSid",
            order: SyncMapItemResource.QueryResultOrderEnum.Asc,
            from: "foo",
            limit: 20);

        foreach (var record in syncMapItems) {
            Console.WriteLine(record.Key);
        }
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.sync.v1.service.syncmap.SyncMapItem;
import com.twilio.base.ResourceSet;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        ResourceSet<SyncMapItem> syncMapItems = SyncMapItem.reader("ServiceSid", "MapSid")
                                                    .setOrder(SyncMapItem.QueryResultOrder.ASC)
                                                    .setFrom("foo")
                                                    .limit(20)
                                                    .read();

        for (SyncMapItem record : syncMapItems) {
            System.out.println(record.getKey());
        }
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	sync "github.com/twilio/twilio-go/rest/sync/v1"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &sync.ListSyncMapItemParams{}
	params.SetOrder("asc")
	params.SetFrom("foo")
	params.SetLimit(20)

	resp, err := client.SyncV1.ListSyncMapItem("ServiceSid",
		"MapSid",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		for record := range resp {
			if resp[record].Key != nil {
				fmt.Println(*resp[record].Key)
			} else {
				fmt.Println(resp[record].Key)
			}
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$syncMapItems = $twilio->sync->v1
    ->services("ServiceSid")
    ->syncMaps("MapSid")
    ->syncMapItems->read(
        [
            "order" => "asc",
            "from" => "foo",
        ],
        20
    );

foreach ($syncMapItems as $record) {
    print $record->key;
}
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

sync_map_items = @client
                 .sync
                 .v1
                 .services('ServiceSid')
                 .sync_maps('MapSid')
                 .sync_map_items
                 .list(
                   order: 'asc',
                   from: 'foo',
                   limit: 20
                 )

sync_map_items.each do |record|
   puts record.key
end
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:sync:v1:services:maps:items:list \
   --service-sid ServiceSid \
   --map-sid MapSid \
   --order asc \
   --from foo
```

```bash
curl -X GET "https://sync.twilio.com/v1/Services/ServiceSid/Maps/MapSid/Items?Order=asc&From=foo&PageSize=20" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "items": [],
  "meta": {
    "first_page_url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items?From=from&Bounds=inclusive&Order=asc&PageSize=50&Page=0",
    "key": "items",
    "next_page_url": null,
    "page": 0,
    "page_size": 50,
    "previous_page_url": null,
    "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items?From=from&Bounds=inclusive&Order=asc&PageSize=50&Page=0"
  }
}
```

```js title="Get all MapItems with the JavaScript SDK" description="This code sample displays the first item."
syncClient.map("users").then(function (map) {
  map.getItems().then(function (page) {
    console.log("show first item", page.items[0].key, page.items[0].value);
  });
});
```

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

{" "}

### Headers

```json
[{"name":"If-Match","in":"header","description":"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](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match).","schema":{"type":"string"}}]
```

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the [Sync Service](/docs/sync/api/service) with the Sync Map Item resource to update.","schema":{"type":"string"},"required":true},{"name":"MapSid","in":"path","description":"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`.","schema":{"type":"string"},"required":true},{"name":"Key","in":"path","description":"The `key` value of the Sync Map Item resource to update. ","schema":{"type":"string"},"x-twilio":{"pii":{"handling":"standard","deleteSla":30}},"required":true}]
```

### Request body parameters

```json
{"schema":{"type":"object","title":"UpdateSyncMapItemRequest","properties":{"Data":{"description":"A JSON string that represents an arbitrary, schema-less object that the Map Item stores. Can be up to 16 KiB in length.","x-twilio":{"pii":{"handling":"sensitive","deleteSla":7}}},"Ttl":{"type":"integer","description":"An alias for `item_ttl`. If both parameters are provided, this value is ignored."},"ItemTtl":{"type":"integer","description":"How long, [in seconds](/docs/sync/limits#sync-payload-limits), before the Map Item expires (time-to-live) and is deleted."},"CollectionTtl":{"type":"integer","description":"How long, [in seconds](/docs/sync/limits#sync-payload-limits), 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."}}},"examples":{"update":{"value":{"lang":"json","value":"{\n  \"Data\": \"{}\",\n  \"Ttl\": 3600\n}","meta":"","code":"{\n  \"Data\": \"{}\",\n  \"Ttl\": 3600\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"Data\"","#7EE787"],[":","#C9D1D9"]," ",["\"{}\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Ttl\"","#7EE787"],[":","#C9D1D9"]," ",["3600","#79C0FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}}},"encodingType":"application/x-www-form-urlencoded","conditionalParameterMap":{}}
```

{" "}

Update a MapItem with the REST API

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function updateSyncMapItem() {
  const syncMapItem = await client.sync.v1
    .services("ServiceSid")
    .syncMaps("MapSid")
    .syncMapItems("foo")
    .update({
      data: {
        name: "FooBaz",
        level: 31,
        username: "foo_baz",
      },
    });

  console.log(syncMapItem.key);
}

updateSyncMapItem();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

sync_map_item = (
    client.sync.v1.services("ServiceSid")
    .sync_maps("MapSid")
    .sync_map_items("foo")
    .update(data={"name": "FooBaz", "level": 31, "username": "foo_baz"})
)

print(sync_map_item.key)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Sync.V1.Service.SyncMap;
using System.Threading.Tasks;
using System.Collections.Generic;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var syncMapItem = await SyncMapItemResource.UpdateAsync(
            data: new Dictionary<
                string,
                Object>() { { "name", "FooBaz" }, { "level", 31 }, { "username", "foo_baz" } },
            pathServiceSid: "ServiceSid",
            pathMapSid: "MapSid",
            pathKey: "foo");

        Console.WriteLine(syncMapItem.Key);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import java.util.HashMap;
import com.twilio.Twilio;
import com.twilio.rest.sync.v1.service.syncmap.SyncMapItem;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        SyncMapItem syncMapItem = SyncMapItem.updater("ServiceSid", "MapSid", "foo")
                                      .setData(new HashMap<String, Object>() {
                                          {
                                              put("name", "FooBaz");
                                              put("level", 31);
                                              put("username", "foo_baz");
                                          }
                                      })
                                      .update();

        System.out.println(syncMapItem.getKey());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	sync "github.com/twilio/twilio-go/rest/sync/v1"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &sync.UpdateSyncMapItemParams{}
	params.SetData(map[string]interface{}{
		"name":     "FooBaz",
		"level":    31,
		"username": "foo_baz",
	})

	resp, err := client.SyncV1.UpdateSyncMapItem("ServiceSid",
		"MapSid",
		"foo",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Key != nil {
			fmt.Println(*resp.Key)
		} else {
			fmt.Println(resp.Key)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$sync_map_item = $twilio->sync->v1
    ->services("ServiceSid")
    ->syncMaps("MapSid")
    ->syncMapItems("foo")
    ->update([
        "data" => [
            "name" => "FooBaz",
            "level" => 31,
            "username" => "foo_baz",
        ],
    ]);

print $sync_map_item->key;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

sync_map_item = @client
                .sync
                .v1
                .services('ServiceSid')
                .sync_maps('MapSid')
                .sync_map_items('foo')
                .update(
                  data: {
                    'name' => 'FooBaz',
                    'level' => 31,
                    'username' => 'foo_baz'
                  }
                )

puts sync_map_item.key
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:sync:v1:services:maps:items:update \
   --service-sid ServiceSid \
   --map-sid MapSid \
   --key foo \
   --data "{\"name\":\"FooBaz\",\"level\":31,\"username\":\"foo_baz\"}"
```

```bash
DATA_OBJ=$(cat << EOF
{
  "name": "FooBaz",
  "level": 31,
  "username": "foo_baz"
}
EOF
)
curl -X POST "https://sync.twilio.com/v1/Services/ServiceSid/Maps/MapSid/Items/foo" \
--data-urlencode "Data=$DATA_OBJ" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "created_by": "created_by",
  "data": {
    "name": "FooBaz",
    "level": 31,
    "username": "foo_baz"
  },
  "date_expires": "2015-07-30T21:00:00Z",
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z",
  "key": "foo",
  "map_sid": "MapSid",
  "revision": "revision",
  "service_sid": "ServiceSid",
  "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/key"
}
```

{" "}

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

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function updateSyncMapItem() {
  const syncMapItem = await client.sync.v1
    .services("ServiceSid")
    .syncMaps("MapSid")
    .syncMapItems("foo")
    .update({
      data: {
        name: "FooBaz",
        level: 31,
        username: "foo_baz",
      },
      ifMatch: "1a",
    });

  console.log(syncMapItem.revision);
}

updateSyncMapItem();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

sync_map_item = (
    client.sync.v1.services("ServiceSid")
    .sync_maps("MapSid")
    .sync_map_items("foo")
    .update(
        data={"name": "FooBaz", "level": 31, "username": "foo_baz"},
        if_match="1a",
    )
)

print(sync_map_item.revision)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Sync.V1.Service.SyncMap;
using System.Threading.Tasks;
using System.Collections.Generic;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var syncMapItem = await SyncMapItemResource.UpdateAsync(
            ifMatch: "1a",
            data: new Dictionary<
                string,
                Object>() { { "name", "FooBaz" }, { "level", 31 }, { "username", "foo_baz" } },
            pathServiceSid: "ServiceSid",
            pathMapSid: "MapSid",
            pathKey: "foo");

        Console.WriteLine(syncMapItem.Revision);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import java.util.HashMap;
import com.twilio.Twilio;
import com.twilio.rest.sync.v1.service.syncmap.SyncMapItem;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        SyncMapItem syncMapItem = SyncMapItem.updater("ServiceSid", "MapSid", "foo")
                                      .setIfMatch("1a")
                                      .setData(new HashMap<String, Object>() {
                                          {
                                              put("name", "FooBaz");
                                              put("level", 31);
                                              put("username", "foo_baz");
                                          }
                                      })
                                      .update();

        System.out.println(syncMapItem.getRevision());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	sync "github.com/twilio/twilio-go/rest/sync/v1"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &sync.UpdateSyncMapItemParams{}
	params.SetData(map[string]interface{}{
		"name":     "FooBaz",
		"level":    31,
		"username": "foo_baz",
	})
	params.SetIfMatch("1a")

	resp, err := client.SyncV1.UpdateSyncMapItem("ServiceSid",
		"MapSid",
		"foo",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Revision != nil {
			fmt.Println(*resp.Revision)
		} else {
			fmt.Println(resp.Revision)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$sync_map_item = $twilio->sync->v1
    ->services("ServiceSid")
    ->syncMaps("MapSid")
    ->syncMapItems("foo")
    ->update([
        "data" => [
            "name" => "FooBaz",
            "level" => 31,
            "username" => "foo_baz",
        ],
        "ifMatch" => "1a",
    ]);

print $sync_map_item->revision;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

sync_map_item = @client
                .sync
                .v1
                .services('ServiceSid')
                .sync_maps('MapSid')
                .sync_map_items('foo')
                .update(
                  data: {
                    'name' => 'FooBaz',
                    'level' => 31,
                    'username' => 'foo_baz'
                  },
                  if_match: '1a'
                )

puts sync_map_item.revision
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:sync:v1:services:maps:items:update \
   --service-sid ServiceSid \
   --map-sid MapSid \
   --key foo \
   --data "{\"name\":\"FooBaz\",\"level\":31,\"username\":\"foo_baz\"}" \
   --if-match 1a
```

```bash
DATA_OBJ=$(cat << EOF
{
  "name": "FooBaz",
  "level": 31,
  "username": "foo_baz"
}
EOF
)
curl -X POST "https://sync.twilio.com/v1/Services/ServiceSid/Maps/MapSid/Items/foo" \
--header "If-Match=1a" \
--data-urlencode "Data=$DATA_OBJ" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "created_by": "created_by",
  "data": {
    "name": "FooBaz",
    "level": 31,
    "username": "foo_baz"
  },
  "date_expires": "2015-07-30T21:00:00Z",
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z",
  "key": "foo",
  "map_sid": "MapSid",
  "revision": "revision",
  "service_sid": "ServiceSid",
  "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/key"
}
```

```js title="Update data in a MapItem with the JavaScript SDK" description="Use the update method to change the data in a Map Item"
syncClient.map("users").then(function (map) {
  map.update("Taylor", { country: "IRL" });
});
```

```js title="Mutate data in a MapItem using the JavaScript SDK" description="Use mutate for more fine-grained control over updates."
syncClient.map("users").then(function (map) {
  map.mutate("david", function (remoteData) {
    remoteData.country = "USA";
    return remoteData;
  });
});
```

The `mutate` function helps your JavaScript code respond to concurrent updates with versioned control. See the corresponding [JavaScript SDK](/docs/sync/javascript/changelog) documentation for details.

```js title="Subscribe to a MapItem update with the JavaScript SDK" description="Note that there are two separate events for map item adds and map item updates:"
// !mark(8:11)
syncClient.map("users").then(function (map) {
  map.on("itemAdded", function (item) {
    console.log("key", item.key);
    console.log("JSON data", item.value);
  });

  //Note that there are two separate events for map item adds and map item updates:
  map.on("itemUpdated", function (item) {
    console.log("key", item.key);
    console.log("JSON data", item.value);
  });
});
```

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

{" "}

### Headers

```json
[{"name":"If-Match","in":"header","description":"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](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match).","schema":{"type":"string"}}]
```

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the [Sync Service](/docs/sync/api/service) with the Sync Map Item resource to delete.","schema":{"type":"string"},"required":true},{"name":"MapSid","in":"path","description":"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`.","schema":{"type":"string"},"required":true},{"name":"Key","in":"path","description":"The `key` value of the Sync Map Item resource to delete.","schema":{"type":"string"},"x-twilio":{"pii":{"handling":"standard","deleteSla":30}},"required":true}]
```

{" "}

Delete a MapItem with the REST API

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function deleteSyncMapItem() {
  await client.sync.v1
    .services("ServiceSid")
    .syncMaps("MapSid")
    .syncMapItems("foo")
    .remove();
}

deleteSyncMapItem();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

client.sync.v1.services("ServiceSid").sync_maps("MapSid").sync_map_items(
    "foo"
).delete()
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Sync.V1.Service.SyncMap;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        await SyncMapItemResource.DeleteAsync(
            pathServiceSid: "ServiceSid", pathMapSid: "MapSid", pathKey: "foo");
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.sync.v1.service.syncmap.SyncMapItem;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        SyncMapItem.deleter("ServiceSid", "MapSid", "foo").delete();
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	sync "github.com/twilio/twilio-go/rest/sync/v1"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &sync.DeleteSyncMapItemParams{}

	err := client.SyncV1.DeleteSyncMapItem("ServiceSid",
		"MapSid",
		"foo",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$twilio->sync->v1
    ->services("ServiceSid")
    ->syncMaps("MapSid")
    ->syncMapItems("foo")
    ->delete();
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

@client
  .sync
  .v1
  .services('ServiceSid')
  .sync_maps('MapSid')
  .sync_map_items('foo')
  .delete
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:sync:v1:services:maps:items:remove \
   --service-sid ServiceSid \
   --map-sid MapSid \
   --key foo
```

```bash
curl -X DELETE "https://sync.twilio.com/v1/Services/ServiceSid/Maps/MapSid/Items/foo" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

{" "}

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

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function deleteSyncMapItem() {
  await client.sync.v1
    .services("ServiceSid")
    .syncMaps("MapSid")
    .syncMapItems("foo")
    .remove({ ifMatch: "1a" });
}

deleteSyncMapItem();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

client.sync.v1.services("ServiceSid").sync_maps("MapSid").sync_map_items(
    "foo"
).delete(if_match="1a")
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Sync.V1.Service.SyncMap;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        await SyncMapItemResource.DeleteAsync(
            ifMatch: "1a", pathServiceSid: "ServiceSid", pathMapSid: "MapSid", pathKey: "foo");
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.sync.v1.service.syncmap.SyncMapItem;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        SyncMapItem.deleter("ServiceSid", "MapSid", "foo").setIfMatch("1a").delete();
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	sync "github.com/twilio/twilio-go/rest/sync/v1"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &sync.DeleteSyncMapItemParams{}
	params.SetIfMatch("1a")

	err := client.SyncV1.DeleteSyncMapItem("ServiceSid",
		"MapSid",
		"foo",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$twilio->sync->v1
    ->services("ServiceSid")
    ->syncMaps("MapSid")
    ->syncMapItems("foo")
    ->delete(["ifMatch" => "1a"]);
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

@client
  .sync
  .v1
  .services('ServiceSid')
  .sync_maps('MapSid')
  .sync_map_items('foo')
  .delete(if_match: '1a')
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:sync:v1:services:maps:items:remove \
   --service-sid ServiceSid \
   --map-sid MapSid \
   --key foo \
   --if-match 1a
```

```bash
curl -X DELETE "https://sync.twilio.com/v1/Services/ServiceSid/Maps/MapSid/Items/foo" \
--header "If-Match=1a" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```js title="Delete a single MapItem with the JavaScript SDK" description="Deletes the item with key 'Taylor'"
syncClient.map("users").then(function (map) {
  map.remove("Taylor").then(function () {
    console.log("item deleted");
  });
});
```
