# Filter by API to nested field

**URL:** <https://discourse.getcockpit.com/t/filter-by-api-to-nested-field/3018>\
**Category:** Support\
**Created:** [July 29, 2024, 11:41pm UTC](https://discourse.getcockpit.com/t/filter-by-api-to-nested-field/3018 "2024-07-29T23:41:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![CristianDev](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/cristiandev/32/1402_2.png) [@CristianDev](https://discourse.getcockpit.com/u/CristianDev)\
**Post date:** [July 29, 2024, 11:41pm UTC](https://discourse.getcockpit.com/t/filter-by-api-to-nested-field/3018/1 "2024-07-29T23:41:31Z")

</div>

I want to perform a filter using the API to get all the items in my “customers” collection where I have the “books” field. In this collection I have a “set of fields” type field called “publisher” with a field called “date”.

I would like to get all the customers who have books from publishers with the existing date value $exists.

[https://api.mycockpit.com/api/content/items/customers?filter={“$and”:[{“\_state”:1}](https://api.mycockpit.com/api/content/items/customers?filter=%7B%22$and%22:%5B%7B%22_state%22:1%7D)]}

How would the filter be performed with that type of nesting?

If I can’t filter I will have to create those fields outside the “set of fields” but that would really be a lot of work 😕

Currently this is the link I have:  
[https://api.mycockpit.com/api/content/items/tickets?filter={“$and”:[{“\_state”:1},{“owner.customer.email”:“me@gmail.com”}](https://api.mycockpit.com/api/content/items/tickets?filter=%7B%22$and%22:%5B%7B%22_state%22:1%7D,%7B%22owner.customer.email%22:%22me@gmail.com%22%7D)]}
