# Add list of device IDs as a filter to the Search Device Inventories route

**URL:** <https://hub.mender.io/t/add-list-of-device-ids-as-a-filter-to-the-search-device-inventories-route/6327>\
**Category:** General Discussions\
**Tags:** management-api\
**Created:** [November 9, 2023, 2:42pm UTC](https://hub.mender.io/t/add-list-of-device-ids-as-a-filter-to-the-search-device-inventories-route/6327 "2023-11-09T14:42:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![k.kasper](https://avatars.discourse-cdn.com/v4/letter/k/48db29/32.png) [@k.kasper](https://hub.mender.io/u/k.kasper)\
**Post date:** [November 9, 2023, 2:42pm UTC](https://hub.mender.io/t/add-list-of-device-ids-as-a-filter-to-the-search-device-inventories-route/6327/1 "2023-11-09T14:42:18Z")

</div>

Hello everyone,

Currently I have the use case that I want to search for a device by ID and limit the response attributes.

Unfortunately, there is currently (Mender 3.6) no Management API route to implement this use case.

With the [Management APIs \> Device inventory \> Get Device Inventory](https://docs.mender.io/api/3.6/?shell#management-api-device-inventory-get-device-inventory) route, I can search for a device by ID, but I cannot limit the attributes.

With the [Management APIs \> Device inventory filters and search \> Search Device Inventories](https://docs.mender.io/api/3.6/?shell#management-api-device-inventory-filters-and-search-search-device-inventories) route, I can limit the attributes, but not search by ID.

Both functions are covered by the [Internal APIs \> Device inventory filters and search \> Search Device Inventories](https://docs.mender.io/api/3.6/?shell#internal-api-device-inventory-filters-and-search) route, but unfortunately this is not exposed.

For this reason, I would like to request a feature.

As with the Internal API, I would like to be able to enter a list of device IDs when searching in order to filter.

Would it be possible to implement this feature?

Best regards and many thanks in advance!

Kevin

---

<div class="post-metadata">

**Author:** ![TheYoctoJester](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/theyoctojester/32/1444_2.png) [@TheYoctoJester](https://hub.mender.io/u/TheYoctoJester)\
**Post date:** [November 9, 2023, 2:58pm UTC](https://hub.mender.io/t/add-list-of-device-ids-as-a-filter-to-the-search-device-inventories-route/6327/2 "2023-11-09T14:58:23Z")

</div>

Hi @k.kasper,

Thanks for getting in touch. The filter `$in` should provide exactly the functionality you are looking for, and is available in the Professional and Enterprise tiers.

EDIT: this snippet should get you going:

```auto
fetch('https://hosted.mender.io/api/management/v2/inventory/filters/search', {
  headers: { authorization: 'Bearer <JWT>' },
  body: {
    page: 1,
    per_page: 20,
    filters: [
      { scope: 'identity', attribute: 'id', type: '$in', value: ['<deviceIds>'] },
      { scope: 'identity', attribute: 'status', type: '$eq', value: 'accepted' }
    ],
    attributes: [{ scope: 'identity', attribute: 'status' }]
  },
  method: 'POST'
});

```

Greetz,  
Josef

---

<div class="post-metadata">

**Author:** ![k.kasper](https://avatars.discourse-cdn.com/v4/letter/k/48db29/32.png) [@k.kasper](https://hub.mender.io/u/k.kasper)\
**Post date:** [November 9, 2023, 3:08pm UTC](https://hub.mender.io/t/add-list-of-device-ids-as-a-filter-to-the-search-device-inventories-route/6327/3 "2023-11-09T15:08:23Z")

</div>

Thank you, it works wonderfully!

I didn’t realise that the ID is also defined as an attribute 🙂
