# Filtering Devices by Custom Metadata

When you use [List Devices](https://docs.seam.co/latest/api/devices/list), you can filter the list by one or more [custom metadata](https://docs.seam.co/latest/api/devices#properties) pairs. Include the `custom_metadata_has` parameter with a JSON string that specifies the desired key:value pairs.

{% hint style="info" %}
You can use the [Update Connected Account](https://docs.seam.co/latest/api/connected_accounts/update) method with the optional `custom_metadata` property to [add custom metadata for a device](https://docs.seam.co/latest/core-concepts/devices/adding-custom-metadata-to-a-device).
{% endhint %}

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

```python
devices = seam.devices.list(
  custom_metadata_has = {
    "internal_account_id": "user-1"
  }
)

pprint(devices)
```

**Response:**

```
[Device(device_id='f7a7fb02-9277-4354-8dd1-28e2d016a7a9',
        device_type='schlage_lock',
        ...
        is_managed=True,
        custom_metadata={"internal_account_id": "user-1"}),
...]
```

{% endtab %}

{% tab title="cURL (bash)" %}
**Request:**

```bash
curl -X 'POST' \
  'https://connect.getseam.com/devices/list' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer ${API_KEY}' \
  -H 'Content-Type: application/json' \
  -d '{
  "custom_metadata_has": {
    "internal_account_id": "user-1"
  },
}'
```

**Response:**

```json
{
  "devices": [
    {
      "device_id": "f7a7fb02-9277-4354-8dd1-28e2d016a7a9",
      "device_type": "schlage_lock",
      ...
      "is_managed": true,
      "custom_metadata": {
        "internal_account_id": "user-1"
      }
    }
  ],
  "ok": true
}
```

{% endtab %}

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

```javascript
const devices = await seam.devices.list({
  custom_metadata_has: {
    "internal_account_id": "user-1"
  }
});

console.log(devices);
```

**Response:**

```json
[
  {
    device_id: 'f7a7fb02-9277-4354-8dd1-28e2d016a7a9',
    device_type: 'schlage_lock',
    ...
    is_managed: true,
    custom_metadata: { internal_account_id: 'user-1' }
  },
  ...
]
```

{% endtab %}

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

```ruby
devices = client.devices.list(
  custom_metadata_has: {
    "internal_account_id": "user-1"
  }
)

puts devices.inspect
```

**Response:**

```
[<Seam::Device:0x004d8
  device_id="f7a7fb02-9277-4354-8dd1-28e2d016a7a9"
  device_type="schlage_lock"
  ...
  is_managed=true
  custom_metadata={"internal_account_id"=>"user-1"}>, ...]
```

{% endtab %}

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

```php
$devices = $seam->devices->list(
  custom_metadata_has: array('internal_account_id' => 'user-1')
);

echo json_encode($devices);
```

**Response:**

{% code overflow="wrap" %}

```json
[{"device_id":"f7a7fb02-9277-4354-8dd1-28e2d016a7a9","device_type":"schlage_lock",..."is_managed":true,"custom_metadata":{"internal_account_id":"user-1"}},...]
```

{% endcode %}
{% endtab %}

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

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

var devices = seam.Devices.List(
  customMetadataHas: customMetadata
);

foreach (var device in devices)
{
  Console.WriteLine(device);
}
```

**Response:**

```json
{
  "device_id": "f7a7fb02-9277-4354-8dd1-28e2d016a7a9",
  "device_type": "schlage_lock",
  ...
  "is_managed": true,
  "custom_metadata": {
    "internal_account_id": "user-1"
  }
}
...
```

{% endtab %}
{% endtabs %}
