Ways to filter Discount Codes under a Price Rule in REST API?

12 0 10

I see that this is not possible in the documentation - but wondering if anyone has determined a solution to approximate this.

The scenario is that I have several Price Rules that regularly have new Discount Codes generated under them. Some of these price rules have many thousand discount codes currently, and more added on a regular basis.

For our reporting outside of Shopify, I GET recently updated price rules - this would include price rules that recently had a new code generated under it (so, if it is a new customer code created, the "new customer" rule would be updated and returned). Then I GET the discount codes under this price rule - in this scenario, I only need the newly created ones. However, the API does not support any filters for the discount_codes endpoint - so, no created_at_min/created_at_max.

This means if I want to see what the most recent "new customer" discount codes were, I have to return all discount codes under that price rule. I can easily filter them out once the data is returned (either by comparing to a list of already captured discount codes or by comparing the created_at value that the discount code has), but it just makes for a LOT of data returned when I only need a few of the codes under the price rule.

Maybe this is possible via GraphQL? Or some other avenue I haven't explored?


Replies 0 (0)