Main issue: How to query Shopify Admin API for all active discount codes applicable to a specific customer (via customer segment), using the customer’s ID.
Current guidance: Suggestion to use the price_rules endpoint, retrieve all price rules, then filter by customer segment to find applicable discounts.
Open questions from the asker:
Can filtering by price rule/customer segment be done directly in the query instead of post-processing?
What would the exact query look like?
How to identify discount codes whose price rule restricts usage to a single specific customer?
Notes:
No code examples or concrete query syntax have been provided.
No confirmation yet on direct server-side filtering by customer segment or customer ID within the Admin API response.
Status: Unresolved. The requester needs detailed guidance (query structure and method) to filter on the API side and identify single-customer–restricted discount codes.
Summarized with AI on December 25.
AI used: gpt-5.
Hi!
I’m trying to make an api request to the shopify admin api, in the request I would like to query for all active discount codes where the customer segments is for a specific customer, and to get that by that customer id, does anyone know if it is possbile or not?
Thanks for the fast response! can I already include the price rule in the query instead of filtering once i get the response? how should such a query should look like and how to get discount codes with the price rule indicates thats only 1 specific customer can use it?
Please if you can provide more details it would be of a great help