Query Shopify customer segments programmatically via Admin GraphQL

domain: shopify.dev · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

In-depth guide

Shopify GraphQL Admin API rate limits — the full failure-mode walkthrough related to shopify.dev, checked against official docs, with linked verified routes.

Steps

  1. Query the list of segments using the `segments` Admin GraphQL query, which returns segment `id`, `name`, `query` (the ShopifyQL condition string), and `creationDate`.
  2. To create a new segment, call the `segmentCreate` mutation with a `name` and a `query` string written in ShopifyQL syntax (e.g., `customer_tags CONTAINS 'vip'`).
  3. Retrieve the members of a segment using the `customerSegmentMembers` query, passing the segment's `id`; paginate with `first` and `after` cursor arguments.
  4. Use the `segmentFilters` query to discover available ShopifyQL filter attributes (e.g., `number_of_orders`, `total_spent`, `customer_tags`) to build valid query strings programmatically.
  5. To count members without fetching full records, query `customerSegmentMembersCount` with the segment ID; this is more efficient for analytics dashboards.
  6. Subscribe to segment membership changes by listening to relevant customer webhooks (`customers/update`) and re-evaluating segment overlap on the application side, as Shopify does not emit segment-membership-change webhooks.

Known gotchas

Related routes

Create a Shopify customer segment using the segmentCreate Admin GraphQL mutation with a ShopifyQL segment query
shopify.dev · 6 steps · unrated
Query customer orders and profile using the Shopify Customer Account API GraphQL endpoint
shopify.dev · 6 steps · unrated
create discount codes in shopify via the admin graphql api
shopify.com · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans