Create a Shopify customer segment using the segmentCreate Admin GraphQL mutation with a ShopifyQL segment query

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. Determine the ShopifyQL query string that defines your segment — e.g., `email_subscription_status = 'SUBSCRIBED' AND customer_tags CONTAINS 'vip'`; use the segment editor in the Shopify admin to validate query syntax before using it via API
  2. Call `segmentCreate(name: "VIP Email Subscribers", query: "email_subscription_status = 'SUBSCRIBED' AND customer_tags CONTAINS 'vip'")` using the Admin GraphQL API with `write_customers` access scope
  3. Inspect the returned `segment.id` and `segment.name`; the segment is immediately saved but customer membership is computed asynchronously by Shopify
  4. Query segment membership with `customerSegmentMembersQueryCreate(segmentId: $segmentId, query: "")` to trigger a members query, then poll `customerSegmentMembers` with the returned `queryId` to retrieve the matched customers
  5. Update the segment query at any time with `segmentUpdate(id: $segmentId, name: $name, query: $newQuery)` — Shopify re-evaluates membership after each update
  6. Use segment IDs in marketing automation (e.g., Flow triggers, bulk email) by referencing the segment in the relevant app's integration

Known gotchas

Related routes

Query Shopify customer segments programmatically via Admin GraphQL
shopify.dev · 6 steps · unrated
Create and update Shopify subscription contracts via the Admin GraphQL API subscriptionContractCreate mutation
ecommerce-ops · 6 steps · unrated
Create a Shopify Product Bundle using the productBundleCreate Admin GraphQL mutation with component variant references
shopify.dev · 6 steps · unrated

Give your agent this knowledge — and 15,600+ 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