← Blog

Shopify inventory sync: fix stock mismatches for good

For e-commerce and operations managers who run Shopify next to an ERP: the five causes of stock drift, a sync design that corrects itself, and who can build it.

Get a summary withChatGPT Claude Google AI Mode
Warehouse shelves linked to a shop window by a glowing thread, picturing shopify inventory sync that keeps stock level
On this page

Your Shopify catalogue and your inventory system disagree, and someone on your team spends part of every week making them agree again. A reliable Shopify inventory sync needs three things: one system that owns the stock number, retries when a message fails, and a nightly check that catches whatever slips through. Most drift comes from a missing piece of that design, rarely from Shopify itself.

This guide is for e-commerce and operations managers who run Shopify next to an ERP or a warehouse system. You will recognise the five causes behind a stock mismatch, decide which system owns the numbers and see a sync design with working code. You will also get the criteria to choose between an app, n8n and a custom service.

werun.dev builds and maintains these syncs for online stores, so the last sections cover cost, timeline and what the work looks like week to week.

Key takeaways

  • Stock drift comes from gaps in the design (no owner, no retries, no checks), so a better design fixes it where more manual edits never will.
  • Name one system as the owner of the stock number before you build anything, and send its quantities to Shopify as absolute values.
  • Combine webhooks for speed, a queue with retries for safety and a nightly reconciliation report for whatever slips through.
  • Alerts and a weekly mismatch report turn silent failures into a short check the same morning.

Why Shopify inventory sync drifts

Stock drifts when two systems each believe they hold the truth and nothing compares them. A sale on Shopify lowers one number, a goods receipt in the warehouse raises another, and the message between them arrives late, twice or never. After a few weeks the gap is large enough that a customer buys something you cannot ship.

The fix is a design, not a bigger import file. You decide which system owns the number, you move changes as events, you retry what fails and you compare both sides every night. The rest of this guide takes those parts one at a time.

Two balance scales drifting out of level with a bright thread pulling them back, showing stock counts that disagree
Two stock counts drift apart until a design pulls them level

What a healthy sync looks like

In a healthy setup, a change in either system reaches the other within seconds or minutes. A failed update retries on its own. If it keeps failing, it lands on a short list that someone sees the same morning.

Each morning you read one report that says how many SKUs differ. The answer is usually zero or a handful. Your team stops asking whether a number is right and starts asking what to reorder.

What oversells and manual fixes cost you

An oversell means an apology email, a refund and sometimes a lost customer. Manual fixes cost hours: someone exports a CSV, compares columns and edits quantities, usually in the middle of a busy week.

For example (illustrative), a person who spends 3 hours a week on corrections spends roughly 150 hours a year on work that a sync does in the background. That time is better spent on purchasing, promotions or customers.

Five causes of a Shopify stock mismatch

Find your own case below. Each cause leaves a symptom you can describe to a developer, which shortens the diagnosis a lot.

Symptom

Stock lags by hours

A sold-out product still shows units. Suspect batch imports or throttled updates.

Symptom

Total right, place wrong

The sum matches but one site shows zero. Suspect the location setup.

Symptom

Some products never update

The same few SKUs are always off. Suspect SKU or variant mapping.

Symptom

Updates stop without a sound

Everything is fine, then counts drift for days. Suspect failed webhooks.

The map below shows where each cause enters the path between your inventory system and the store, and where the nightly check catches what slipped through.

Stock drift path

  1. 01Inventory systemSource of truth for counts
  2. 02CSV batchHours-old counts reach the store
  3. 03API rate limitThrottled updates arrive late
  4. 04Location splitStock lands at the wrong place
  5. 05SKU mappingUnmatched variants never update
  6. 06Shopify storeShows the count customers see

Map of five points where stock drift enters between an inventory system and Shopify, with a nightly check catching the rest

Where drift enters the path to your store

Batch CSV imports that arrive late

If your inventory system exports a file every few hours, Shopify only knows the stock as of the last file. A product can sell out at 10:00 and still show 12 units until the 14:00 import.

Imports also overwrite. A file built at 09:00 and applied at 09:40 erases the sales made in those 40 minutes. The longer the gap, the bigger the error.

API rate limits that drop updates

Shopify limits how fast an app can call its Admin API, and the allowance depends on your plan (see Shopify's Admin API rate limits (opens in a new tab)). A full catalogue push after a price-list change can pass that limit.

If the sync ignores the throttle response, the updates past the limit are lost. The symptom is a batch where the first products are right and the last ones are stale.

Multiple locations that split the count

Shopify tracks stock per location. If the sync writes one total to a single location, your pickup store can show zero while the warehouse holds 40 units.

The reverse also happens: the ERP sends per-site numbers and the store reads only the total. Orders then route to the wrong place, or products show as unavailable where they are in stock.

Variants and SKU mismatches

Stock in Shopify lives on an inventory item, one per variant, and the SKU is usually the key that links it to your system. If the ERP says TS-100-M and Shopify says TS-100-Mediumor a SKU has a trailing space, the sync cannot match them. It skips the item or updates the wrong variant.

Bundles and reused SKUs make it worse. Clean product data upstream helps, and the guide on PIM and product content shows how to keep SKUs and attributes consistent.

Webhook failures nobody notices

A webhook is how Shopify tells your system that something happened, such as a new order (see Shopify webhooks (opens in a new tab)). If your endpoint is down during a deploy or answers too slowly, the delivery fails.

Shopify retries for a limited period and can remove a subscription that keeps failing. Without a delivery log or an alert, the sync simply stops, and the first sign is a wrong count days later.

Decide which system owns the stock number

Pick one system to own the stock number before anyone writes code. The owner is the system whose number wins when the two disagree. Every later choice, from direction of data to conflict rules, follows from this one.

Our pick for most ERP setups

Inventory system owns stock

  • One number across Shopify, marketplaces and B2B orders
  • Receipts, transfers and counts reach the store automatically
  • Needs a sync you design, monitor and maintain
  • Manual stock edits in Shopify get overwritten

Option B

Shopify owns stock

  • Simplest setup, with nothing to sync into
  • Works well with one location and Shopify POS
  • Other tools read the number from Shopify
  • Gets hard once a second warehouse or channel appears

When the inventory system should own stock

Choose this when you have a warehouse, an ERP, purchase orders or more than one sales channel. The inventory system already knows about receipts, transfers, returns and reserved units, so it is the place where the real number is computed.

Shopify then becomes a display and checkout layer. Orders flow back as events, the inventory system recalculates, and the new quantity flows out.

When Shopify should own it

Choose this for a small catalogue with one location and no ERP stock logic. Your team edits stock in Shopify, and other tools such as a label printer or a spreadsheet read from it.

If you expect a second warehouse or a marketplace within a year, plan for the first option now. Moving the owner later is possible, but it costs a careful cutover.

What flows in each direction

The table shows the usual split when the inventory system owns stock.

DataDirectionWhy
Available quantityInventory system to ShopifyOne owner of the number
New orders and refundsShopify to inventory systemThe owner recalculates stock
Receipts, transfers, countsInventory system to ShopifyThey change what can be sold
SKU and barcodeProduct source to bothKeeps matches stable
Price and contentProduct source to ShopifySeparate flow from stock

Design a Shopify inventory sync that corrects itself

The pattern that holds up has three layers. Webhooks give speed, a queue gives safety and a nightly reconciliation gives a net under both. Each layer covers a weakness of the others.

01

Stock change

Sale or goods receipt

02

Webhook or event

Signed message arrives

03

Queue with retries

Ordered and deduplicated

04

Shopify update

Plus nightly check

Webhooks and a queue for live changes

Your endpoint should do three small things: verify the signature, store the event and answer quickly. A separate worker then reads the queue at a pace the API allows. Receiving and working stay apart, so a slow Shopify response never makes you miss a message.

Shopify sends an event id in the X-Shopify-Event-Id header. Keep it, so the worker can spot a delivery that arrives twice.

Idempotent updates and retries

Idempotent means that applying the same message twice leaves the same result. You get there by sending the full quantity instead of an adjustment, and by remembering which event ids you have already processed.

Retries wait longer after each failure. After a set number of attempts the message moves to a dead letter list, a holding area for failures that need a person, and an alert fires. The flow below shows both paths.

Event to stock

  1. 01Sale or receipt eventShopify sale or warehouse receipt
  2. 02QueueOrdered and deduplicated by event id
  3. 03WorkerReads at the pace the API allows
  • ASuccessStock matches everywhere
    1. Absolute quantities appliedFull quantity, not an adjustment
    2. Shopify and inventory systemBoth show the same count
  • BFailureThe update did not go through
    1. Retry with backoffWaits longer, then back to worker
    2. Dead letter list, then alertAfter several attempts, team is told

Step by step view of a sync where sale and receipt events enter a queue, a worker updates stock and failures retry then alert

How events become correct stock, with retries

A nightly reconciliation report

Webhooks are not guaranteed, so compare both sides every night. Export stock from the owner and from Shopify, match by SKU and location and list every difference. Small gaps can be corrected automatically to the owner's number. Large gaps go to a person, because they often point to a mapping problem.

// Compare two stock lists keyed by "SKU|location" and print the differences.
function diffStock(owner, shopify) {
  const diffs = [];
  for (const [key, ownerQty] of owner) {
    const shopifyQty = shopify.get(key);
    if (shopifyQty === undefined) {
      diffs.push({ key, ownerQty, shopifyQty: null, issue: "missing in Shopify" });
    } else if (shopifyQty !== ownerQty) {
      diffs.push({ key, ownerQty, shopifyQty, issue: "quantity differs" });
    }
  }
  for (const key of shopify.keys()) {
    if (!owner.has(key)) {
      diffs.push({ key, ownerQty: null, shopifyQty: shopify.get(key), issue: "missing in inventory system" });
    }
  }
  return diffs;
}

const owner = new Map([["TS-100-M|warehouse", 12], ["TS-100-L|warehouse", 7], ["MUG-01|warehouse", 40]]);
const shopify = new Map([["TS-100-M|warehouse", 12], ["TS-100-L|warehouse", 9], ["CAP-02|warehouse", 3]]);

console.table(diffStock(owner, shopify));

Set stock with the Shopify inventory API

The goal here is simple: the number in Shopify equals the number your inventory system sent, at the right location. Shopify documents the model for inventory management apps (opens in a new tab), and the parts you need are few.

Inventory items, locations and levels

Every variant has an inventory item, which carries the SKU. A location is a place that holds stock, such as a warehouse or a shop. An inventory level is the quantity of one item at one location.

So a store with 2,000 SKUs and 3 locations has up to 6,000 levels to keep right. Your sync writes at that level, never at product level.

Code: set absolute quantities with GraphQL

The mutation inventorySetQuantities in the Admin GraphQL API sets the quantity of the available state for each item and location. This example adds duplicate protection by event id and a retry when Shopify throttles the request.

// Set absolute stock quantities in Shopify with retries and duplicate protection.
const ENDPOINT = `https://${process.env.SHOPIFY_SHOP}/admin/api/2025-07/graphql.json`;

const MUTATION = `
  mutation SetStock($input: InventorySetQuantitiesInput!) {
    inventorySetQuantities(input: $input) {
      inventoryAdjustmentGroup { id }
      userErrors { field message code }
    }
  }
`;

type StockLine = { inventoryItemId: string; locationId: string; quantity: number };

// In production keep processed event ids in Redis or a database table.
const processed = new Set<string>();
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));

export async function setStock(eventId: string, lines: StockLine[], maxAttempts = 5) {
  if (processed.has(eventId)) return "duplicate";

  for (let attempt = 1; attempt <= maxAttempts; attempt++) {
    const response = await fetch(ENDPOINT, {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "X-Shopify-Access-Token": process.env.SHOPIFY_ADMIN_TOKEN!,
      },
      body: JSON.stringify({
        query: MUTATION,
        variables: {
          input: {
            name: "available",
            reason: "correction",
            referenceDocumentUri: `logistics://inventory-sync/${eventId}`,
            ignoreCompareQuantity: true,
            quantities: lines,
          },
        },
      }),
    });

    const body = await response.json();
    const throttled =
      response.status === 429 ||
      body.errors?.some((e: any) => e.extensions?.code === "THROTTLED");

    if (throttled) {
      await sleep(2 ** attempt * 500); // wait longer after each throttled attempt
      continue;
    }
    if (!response.ok || body.errors) {
      throw new Error(JSON.stringify(body.errors ?? response.status));
    }

    const userErrors = body.data.inventorySetQuantities.userErrors;
    if (userErrors.length > 0) throw new Error(JSON.stringify(userErrors));

    processed.add(eventId);
    return "updated";
  }
  throw new Error(`Throttled after ${maxAttempts} attempts, move to the dead letter list`);
}

Ids are Shopify global ids, such as gid://shopify/InventoryItem/123456. Because the inventory system owns the number, the code sets ignoreCompareQuantity to true. Check the API reference for your version, since arguments change between releases.

Absolute, never deltas

Send the full quantity, not "minus 2" or "plus 10". A repeated or late message then repeats the same correct number and cannot corrupt the count.

Staying inside API rate limits

Batch many quantities into one call instead of one call per SKU. Let the queue set the pace, and read the throttle response so the worker waits instead of hammering the API.

For a large first load or a full price-list refresh, run the job off-peak. The limits grow with your plan, and Shopify Plus stores get a higher allowance, as the rate limits page (opens in a new tab) explains.

Choose an app, n8n or a custom service

The right build depends on catalogue size, number of locations and how many business rules sit between the two systems. This table gives the criteria.

OptionBest forStrengthWatch out for
Inventory appOne location, a standard ERP, few rulesFast to start, low upfront costFixed logic, monthly fees, limited alerts
n8n workflowsSeveral systems, custom rules, moderate volumeVisible logic, quick changesQueueing and retries need deliberate design
Custom serviceMany SKUs and locations, bundles, high volumeFull control of rules and monitoringHigher upfront investment

When an app is enough

An app fits when your ERP has a maintained connector, you have one or two locations and your rules are standard. You start in days and pay a subscription. The guide on Shopify app limits and hidden costs helps you weigh that choice honestly.

Watch two things: how the app handles failed updates, and whether it shows you a report of mismatches.

When n8n workflows fit

n8n is a workflow tool where you draw the steps and can add code where needed (see the n8n documentation (opens in a new tab)). It suits stores that connect Shopify to an ERP and also to a spreadsheet, a supplier feed or a notification channel.

It works best when someone designs the retry, queue and reconciliation steps on purpose. If you are comparing tools, n8n vs Zapier vs Make covers pricing, control and limits.

When a custom service pays off

A custom service pays off with a large catalogue, several warehouses, bundles or kits, or rules such as reserved stock and safety buffers. You get exact control of the rules, the speed and the alerts.

It also removes dependence on a third-party app roadmap. The trade is a bigger upfront build, which you recover in fewer corrections and fewer lost orders.

Monitor the sync so drift shows early

A sync you cannot see fails quietly. Monitoring turns that into a short morning check, and it is the part most projects skip.

Alerts worth waking up for

Keep alerts few, so each one gets read. These are the ones that matter:

  • The dead letter list is not empty.
  • No webhook arrived for several hours on a business day.
  • The oldest message in the queue is older than the limit you set.
  • The nightly reconciliation finds more differences than your threshold.
  • API errors or throttling rise well above their usual level.

Send them to email or a team chat channel with the SKU, the location and what the sync tried to do.

A weekly mismatch report

Once a week, send one short report: how many SKUs differed, which SKUs appear again and again, how many oversells happened and how long updates took on average. Repeating SKUs usually point to a mapping or location rule that needs fixing at the root.

Over a few weeks the report shows the sync getting quieter. That trend is your evidence that the fix holds.

Cost, timeline and who builds it

What drives the cost

The price follows scope, not catalogue size alone. These factors move it most:

  • How good the ERP or inventory system API is, or whether it only exports files.
  • The number of locations and sales channels.
  • Bundles, kits and variants with unusual SKU patterns.
  • How much SKU data needs cleaning before the sync can match it.
  • Business rules such as reserved stock or safety buffers.
  • The depth of monitoring and reporting you want.

An app has the lowest upfront cost and a recurring fee. n8n sits in the middle, and a custom service costs most upfront and carries the fewest limits. Ask for a scoped quote, since a single location with clean SKUs costs far less than a multi-warehouse ERP.

A realistic timeline

For a store like the earlier example, 2,000 SKUs and 3 locations, a typical shape looks like this (illustrative, it varies with the ERP and the data):

  1. Week 1: audit SKUs, locations and the current flow, and agree on the owner of the number.
  2. Weeks 2 to 3: build the webhook receiver, queue, worker and reconciliation job.
  3. Week 4: test with your real catalogue on a development store, including failures on purpose.
  4. Weeks 5 to 6: go live in stages, watch the report and tune the rules.

How werun.dev builds and keeps it running

You tell us the goal, for example no oversells and no hand edits, and we build the way there. We map your SKUs and locations, agree on the owner of the number and build the webhooks, queue, retries and nightly report. The Shopify ERP integration page describes how that project runs.

After launch we stay beside you: alerts reach us as well, the monthly report shows how the sync behaves, and a reply arrives in under 2 hours on business days. The wider Shopify platform work covers themes, store operations and Shopify Plus.

Where to start this week

You can make real progress in an afternoon, without writing code. The list below gives you the facts any developer will ask for, and it shows how serious the drift is.

  • Decide which system owns the stock number, even if only as a draft.
  • Export 20 SKUs that are currently mismatched, with both quantities.
  • List every location in Shopify and in your inventory system.
  • Check the webhook delivery logs for failed or missing deliveries.
  • Note when the last full import ran and how often files arrive.

With that list in hand, the cause is usually visible within minutes. If you want help, tell werun.dev your goal and share the list. We will reply with what we see and the simplest way to a sync that holds.

Frequently asked questions

Why is my Shopify inventory not matching my ERP?

The usual causes are late batch imports, throttled API calls, per-location counts that do not line up, SKU mismatches and webhooks that failed without an alert. Naming one system as owner of the number and adding retries plus a nightly comparison removes most of them.

How often should Shopify inventory sync with my inventory system?

For stores that sell fast, changes should travel as events within seconds or minutes, not in hourly files. Add a nightly full comparison as a safety net, because event delivery can fail.

How do I stop overselling on Shopify?

Keep a single owner of the stock number, update Shopify as soon as a sale or receipt happens, and send absolute quantities. Add a safety buffer for slow-moving updates and an alert that fires when updates fail.

Can I sync Shopify inventory with an ERP without an app?

Yes. You can use n8n workflows or a custom service that listens to Shopify webhooks and calls the Admin API directly. This gives you more control over rules, retries and monitoring than a fixed app.

What are Shopify API rate limits for inventory updates?

Shopify limits how many calls an app can make per store, and the allowance depends on the store plan, with higher limits on Shopify Plus. Batching quantities, pacing a queue and retrying when throttled keep updates inside the limit.

How much does a custom Shopify inventory integration cost?

It depends on scope: the quality of the ERP API, the number of locations, bundles and the rules involved. A single location with clean SKUs costs much less than a multi-warehouse setup, so ask for a scoped quote after a short audit.

Running into this on your own stack?

Tell us the platform and the problem. We'll tell you what it takes and who does it.

Start a conversation No commitment. Just a conversation.