Set absolute on-hand inventory quantities for a product variant across Shopify locations using the inventorySetQuantities Admin GraphQL mutation

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 `inventoryItem(id: $inventoryItemId)` or `productVariant.inventoryItem` to retrieve the inventory item ID for the variant you want to update
  2. Fetch the current `on_hand` quantities per location via `inventoryLevel.quantities(names: ["on_hand"])` on the inventory item to get current values for compare-and-swap
  3. Call `inventorySetQuantities(input: { name: "on_hand", reason: "correction", quantities: [{ inventoryItemId: $id, locationId: $locationId, quantity: 50, compareQuantity: 45 }] })` — the `compareQuantity` acts as an optimistic lock to prevent overwriting concurrent updates
  4. Check `inventorySetQuantitiesPayload.userErrors`; a `compareQuantity` mismatch error means another process updated the inventory between your read and write — re-fetch and retry
  5. Use `reason` values such as `correction`, `received`, or `damaged` to annotate the reason for the quantity change; this appears in the inventory history log
  6. For bulk updates across many variants and locations, batch multiple `quantities` entries in a single mutation call rather than making one call per variant

Known gotchas

Related routes

Run a Shopify Admin GraphQL bulk mutation to update variant prices across a large catalog using stagedUploadsCreate and bulkOperationRunMutation
shopify.dev · 6 steps · unrated
Run a Shopify Admin GraphQL bulk mutation to update metafield values across thousands of products using stagedUploadsCreate and bulkOperationRunMutation
shopify.dev · 6 steps · unrated
adjust shopify inventory quantities across multiple locations
shopify.com · 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