I want to query all product sets that contain a particular catalog item

I am trying to query the catalog api for a product set that has product_ids_any containing a particular item id:

{
    "object_types": [
      "PRODUCT_SET"
    ],
    "query":{
        "exact_query":{
            "attribute_name": "product_ids_any",
            "attribute_value": "<my item id>"
        }
    },
    "limit": 2
  }

what I get back is:

{

"errors": \[

    {

        "category": "INVALID_REQUEST_ERROR",

        "code": "INVALID_VALUE",

        "detail": "Unknown attribute definition name \\"product_ids_any\\".",

        "field": "exact_query.attribute_name"

    }

\]

}

I should add that what I really want to do is get all discounts for all items, which is very cumbersome and requires several calls.

:waving_hand: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Catalog API
Search for Items and Objects
Retrieve Catalog Objects

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

At this time the Square API returns an Unknown attribute definition name error when trying to search by product_ids_any . This field exists in product set objects but is not searchable through the API’s query system at this time. The Catalog API’s exact_query method cannot search within array fields like product_ids_any , and this specific attribute is not recognized as a valid searchable field.

You’ll have to retrieve all product sets from the Catalog API call and filtering client-side. This is the most efficient solution available and cannot be improved further due to Square API limitations. :slight_smile: