FlowKit

Syncing Shopify inventory with n8n: the end of stockouts and overselling

Published 30 July 2026 · 3 min read

Inaccurate stock isn't a technical detail: it's either a lost sale (the product is there, the site says "sold out") or an oversell (the site sells what no longer exists, and you refund and apologize). The scale of the problem has been documented for a long time: the reference study by Gruen, Corsten and Bharadwaj published in 2002 ("Retail Out-of-Stocks: A Worldwide Examination of Extent, Causes and Consumer Responses", see on Google Scholar) already put shelf stockouts at around 8% of SKUs in worldwide retail — and showed that when facing a stockout, a large share of customers substitute or switch stores. In e-commerce, where the "shelf" is a database, most of those stockouts are avoidable: it's a synchronization problem, which is exactly what n8n does well.

The four flows of a complete sync

  1. Sales → stock: every Shopify order decrements stock in the other systems (ERP, second store, marketplace).
  2. Supply → Shopify: supplier deliveries and ERP movements flow back into Shopify.
  3. Alerts: threshold crossings trigger notifications or reordering.
  4. Reconciliation: a periodic full count compares all sources and corrects drift.

All of it builds on the base connection described in our Shopify + n8n guide: Admin API credential, Shopify node for products and orders, Shopify Trigger for webhooks.

Flow 1: react to sales in real time

The Shopify Trigger listens to order events (orders/create, orders/cancelled) and inventory events. On each order: extract the line items (SKU, quantity), then propagate the decrement to the other systems — a SQL query to the ERP via the Postgres node, an API call to WooCommerce if you run both platforms, or a marketplace update.

Two non-negotiable precautions on this flow. First, idempotency: Shopify can deliver a webhook more than once; without deduplication by order ID, every duplicate decrements stock one time too many — our guide to webhook idempotency covers the pattern. Second, cancellations and returns: orders/cancelled and refunds must credit stock back, or it artificially melts away.

Flow 2: push inventory into Shopify

In the other direction, levels computed by the ERP or received from the supplier must land in Shopify. The Shopify node handles products and orders; for per-location inventory, an HTTP Request node against the Admin GraphQL API does the job: resolve the SKU to its inventory item, then set the available quantity for the relevant location. Wrap that logic in a "update stock for one SKU" sub-workflow reused by every flow — one single place to fix when the API evolves.

A frequent real-world case: the supplier has no API but drops a CSV or Excel file (by email or on a server). n8n ingests it natively — file extraction, possibly fetched over SFTP — then a loop updates each SKU. Mind Shopify's API rate limits on large catalogs: process in batches with a pause between packets.

Flow 3: low-stock alerts and reordering

A scheduled workflow (Schedule Trigger) walks the levels and routes on per-SKU thresholds: below the alert threshold, a Slack or email notification to the buyer; below the critical threshold, automatic creation of a replenishment line in the ERP or a draft purchase order, with human approval before sending. Thresholds live in a Data Table or a Google Sheet the purchasing team can edit without touching the workflow.

Flow 4: the reconciliation that catches everything

Even well built, a real-time sync drifts: a webhook lost during maintenance, a manual back-office fix, a return handled outside the process. The remedy is a daily full count: export each system's levels, match them by SKU — the Compare Datasets node does exactly that, with its "different / only in A / only in B" outputs —, log every discrepancy, apply the designated source of truth and alert beyond a threshold. It's the same safety-net logic as an Error Workflow: you don't assume real time is perfect, you verify it.

Where to start

Start with flow 1 (sales → stock) and flow 4 (reconciliation): that pair eliminates overselling, the costliest risk. Then add alerts, then the supplier integration. And if your store already processes orders with n8n — our guide to e-commerce order automation lays the groundwork — inventory sync grafts naturally onto the same webhooks: same trigger, one more branch.

Permanently accurate stock isn't a five-figure ERP module: it's four disciplined n8n workflows — idempotent real time, centralized writes, editable thresholds and a daily reconciliation.

FAQ

Frequently asked questions

Should I sync in real time or in batches?

Both, for different reasons. Real time (order webhooks, inventory updates) keeps stock accurate as events happen; batch reconciliation (a full count every night) catches what real time missed — a lost webhook, a manual back-office edit, a return processed outside the process. A system that only does real time drifts slowly but surely.

How do I update Shopify inventory from n8n?

n8n's Shopify node covers products and orders; for inventory levels, use an HTTP Request node against Shopify's Admin API (GraphQL), which lets you set or adjust an item's quantity per location. Your existing n8n Shopify credential is reused, and the logic stays the same: resolve the inventory item and location ID, then push the quantity.

How do I avoid overselling during traffic spikes?

By shrinking the window between a sale and the decrement on other channels: process order webhooks immediately rather than in batches, and keep a safety buffer per channel — selling down to exactly 0 on two simultaneous channels guarantees an oversell sooner or later. A buffer of a few units on fast-moving SKUs absorbs the sync latency.

What if the supplier file contradicts the Shopify stock?

Never overwrite silently: discrepancies are information. Log every difference detected during reconciliation, apply the source of truth you designated (the ERP or the supplier, depending on the SKU), and alert beyond a discrepancy threshold — a massive gap signals a process problem, not normal fluctuation.

Bundle FlowKit Complet

€269