Skip to content

Shopify Dude Fix

Shopify inventorySetQuantities in 2026: Replace compareQuantity with changeFromQuantity

Migrate absolute inventory writes to the 2026-04 compare-and-swap contract and avoid overwriting concurrent stock changes.

Quick answer: Starting with Admin API 2026-04, include changeFromQuantity for each inventory quantity. Supply the expected existing value to protect against concurrent updates, or explicitly use null when an authoritative source must overwrite it.
On this page

Why this happens

The 2026-01 API introduced the replacement field. In 2026-04 the older compareQuantity and ignoreCompareQuantity inputs were removed. The new field must be supplied at runtime even though schema tooling may not mark it required.

How to fix it

Audit ERP and warehouse integrations for inventorySetQuantities payload builders. Decide whether each integration owns the absolute stock value or is applying a relative movement. Use inventoryAdjustQuantities for relative adjustments rather than deriving a stale absolute value. For absolute writes, read the relevant inventory item, location and quantity state, then include the expected value. Handle CHANGE_FROM_QUANTITY_STALE by re-reading and reconciling the upstream event rather than blindly overwriting.

Practical example

If available stock was 40 and your authoritative calculation says 38, a conditional quantity input contains quantity: 38 and changeFromQuantity: 40 alongside inventoryItemId and locationId. If another process changes stock to 39 first, investigate and recompute before submitting again. Explicit null is appropriate only when the source truly owns the absolute quantity.

Common misunderstanding: Passing null and omitting the field are not equivalent. Also, compare-and-swap does not resolve which system owns inventory or prevent duplicate upstream events.
How to test this:

  1. Pin the target API version
  2. use a disposable inventory item at a test location
  3. read its available quantity
  4. submit a conditional update
  5. attempt another with the stale expected quantity
  6. verify the error and persisted stock
  7. test explicit null on disposable data
  8. inspect retry handling and reconcile against the warehouse ledger.