> ## Documentation Index
> Fetch the complete documentation index at: https://docs.seam.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Filtering Devices by Custom Metadata

> When listing devices, you can filter by custom metadata.

When you use [List Devices](/api/devices/list), you can filter the list by one or more [custom metadata](/core-concepts/devices) pairs. Include the `custom_metadata_has` parameter with a JSON string that specifies the desired key:value pairs.

<Info>
  You can use the [Update Connected
  Account](/api/connected_accounts/update) method
  with the optional `custom_metadata` property to [add custom metadata for a
  device](/core-concepts/devices/adding-custom-metadata-to-a-device).
</Info>

**Request:**

<CodeGroup>
  ```javascript JavaScript theme={null}
  const devices = await seam.devices.list({
    custom_metadata_has: {
      internal_account_id: 'user-1',
    },
  })

  console.log(devices)
  ```

  ```bash cURL theme={null}
  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"
    },
  }'
  ```

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

  pprint(devices)
  ```

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

  puts devices.inspect
  ```

  ```php PHP theme={null}
  $devices = $seam->devices->list(
    custom_metadata_has: array('internal_account_id' => 'user-1')
  );

  echo json_encode($devices);
  ```

  ```csharp C# theme={null}
  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);
  }
  ```
</CodeGroup>

**Response:**

<CodeGroup>
  ```json JavaScript theme={null}
  [
    {
      device_id: 'f7a7fb02-9277-4354-8dd1-28e2d016a7a9',
      device_type: 'schlage_lock',
      ...
      is_managed: true,
      custom_metadata: { internal_account_id: 'user-1' }
    },
    ...
  ]
  ```

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

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

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

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

  ```json C# theme={null}
  {
    "device_id": "f7a7fb02-9277-4354-8dd1-28e2d016a7a9",
    "device_type": "schlage_lock",
    ...
    "is_managed": true,
    "custom_metadata": {
      "internal_account_id": "user-1"
    }
  }
  ...
  ```
</CodeGroup>
