# Adding Custom Metadata to a Device

You can use custom metadata to store a custom payload or object, tailored to the specific needs of your app. For example, this feature is useful for tracking customer information, internal user IDs, or other internal resources for a [device](https://docs.seam.co/latest/core-concepts/devices). Storing custom metadata in a Seam `device` object enables you to look up an internal resource from directly within your Seam [workspace](https://docs.seam.co/latest/core-concepts/workspaces). Then, you can [filter devices by the desired metadata](https://docs.seam.co/latest/core-concepts/devices/filtering-devices-by-custom-metadata).

{% hint style="info" %}
You can also use unique resource keys as an easy way to link your resources to Seam resources. For details, see [Mapping Your Resources to Seam Resources](https://docs.seam.co/latest/core-concepts/mapping-your-resources-to-seam-resources).
{% endhint %}

Use the [Update Device](https://docs.seam.co/latest/api/devices/update) method with the optional [`custom_metadata` property](https://docs.seam.co/latest/api/devices/#properties) to change or add custom metadata for the connected account. This property accepts up to 50 JSON key:value pairs.

{% tabs %}
{% tab title="JavaScript" %}
**Request:**

```javascript
const deviceUpdate = await seam.devices.update({
  device_id: "30fd243b-3054-4384-a713-5487076a3826",
  custom_metadata: {
    "internal_account_id": "user-1"
  }
})

console.log(deviceUpdate)
```

**Response:**

```json
{ ok: true }
```

{% endtab %}

{% tab title="cURL" %}
**Request:**

```bash
curl -X 'POST' \
  'https://connect.getseam.com/devices/update' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer ${API_KEY}' \
  -H 'Content-Type: application/json' \
  -d '{
  "device_id": "30fd243b-3054-4384-a713-5487076a3826",
  "custom_metadata": {
    "id": "internal_id_1"
  }
}'
```

**Response:**

```json
{
  "ok": true
}
```

{% endtab %}

{% tab title="Python" %}
**Request:**

```python
device_update = seam.devices.update(
    device = "30fd243b-3054-4384-a713-5487076a3826",
    custom_metadata = {
        "internal_account_id": "user-1"
    }
)

pprint(device_update)
```

**Response:**

```
True
```

{% endtab %}

{% tab title="Ruby" %}
**Request:**

```ruby
device_update = client.devices.update(
  device_id: "30fd243b-3054-4384-a713-5487076a3826",
  custom_metadata: {
    "internal_account_id": "user-1"
  }
)

puts device_update.inspect
```

**Response:**

```
{"ok"=>true}
```

{% endtab %}

{% tab title="PHP" %}
**Request:**

```php
$device_update = $seam->devices->update(
  device_id: "30fd243b-3054-4384-a713-5487076a3826",
  custom_metadata: array('internal_account_id' => 'user-1')
)
echo json_encode($device_update, JSON_PRETTY_PRINT);
```

**Response:**

{% code overflow="wrap" %}

```json
true
```

{% endcode %}
{% endtab %}

{% tab title="C#" %}
**Request:**

```csharp
var customMetadata = new Dictionary<string, string>()
{
  {"internal_account_id", "user-1"}
};

var deviceUpdate = seam.Devices.Update(
  deviceId: "30fd243b-3054-4384-a713-5487076a3826",
  customMetadata: customMetadata
);

Console.WriteLine(deviceUpdate);
```

**Response:**

```json
{
  "device_id": "30fd243b-3054-4384-a713-5487076a3826",
  "device_type": "schlage_lock",
  ...
  "is_managed": true,
  "custom_metadata": {"internal_account_id"=>"user-1"}
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.seam.co/latest/core-concepts/devices/adding-custom-metadata-to-a-device.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
