Ecommerce integrations
How Do You Keep Shopify and ERP Stock in Sync Without Overselling?
("To keep Shopify and an ERP in sync without overselling, choose one authoritative system for each inventory decision, map every Shopify inventory item and location to an exact ERP item and warehouse, make every update safe to repeat, reject stale writes, and reconcile the two systems continuously. Fast updates help, but clear ownership and verifiable controls are what stop yesterday's quantity or a duplicate event from becoming today's sellable stock.", 'The integration must also agree what stock means. On hand, available, committed, reserved, damaged and safety stock are not interchangeable. Sending one unexplained number between systems can make a technically successful synchronisation commercially wrong.', 'The method below gives ecommerce and operations teams a practical contract for stock movement, exceptions and recovery. It does not assume that either platform should overwrite everything in the other.')
For a repeatable version of this process, explore M.I.A.I Integration Engine.
Choose the stock decision before choosing the API
Start with the customer-facing decision: how many units may this store sell at this location right now? Then work backwards to the records and rules needed to answer it. This prevents an integration project from becoming a list of endpoints without a shared business definition.
Name the source of truth for physical stock, sellable stock, allocations, transfers, safety stock and order commitments. An ERP may own warehouse quantities while Shopify owns checkout commitments. A fulfilment provider may own pick and dispatch events. The integration should coordinate those responsibilities instead of creating a fourth unexplained stock figure.
M.I.A.I Integration Engine is designed for managed data mapping, synchronisation workflows, operational monitoring and human exception handling across ecommerce, ERP and other approved business systems. The business still decides which system owns each field and when a discrepancy must stop an automated update.
Define what each inventory number means
A quantity named stock can hide several different states. On-hand units may include damaged, quarantined or reserved items. Available units may already exclude commitments and safety stock. Incoming stock may have an expected date but cannot yet be promised to a customer.
Shopify's inventory model distinguishes states including incoming, on hand, available, committed, reserved, damaged, safety stock and quality control. Its documentation also notes that committed quantities are managed through Shopify actions such as creating and fulfilling orders. An integration must therefore map business meanings, not just match fields with similar names.
Write the sellable-stock formula in plain language and in testable rules. If the ERP owns on-hand quantity and internal allocations, state whether Shopify commitments are already represented there, how safety stock is applied, and what happens during a lag. Never subtract the same commitment twice.
- Physical on hand: units recorded at a real warehouse or location
- Committed: units attached to accepted orders or fulfilment work
- Reserved: units deliberately removed from general availability
- Safety stock: a buffer withheld from sale under an approved rule
- Available to sell: the governed result presented to a sales channel
- Incoming: expected stock that is not yet available to fulfil
Assign ownership at field and location level
Ownership can vary by field and warehouse. NetSuite might own physical quantity for a distribution centre, while Shopify tracks a separate retail location. A third-party warehouse may be authoritative only after it accepts a fulfilment request. Document the direction and owner for every location rather than declaring that the ERP owns inventory in general.
Decide which system may perform absolute sets and which may submit adjustments. Shopify's current inventorySetQuantities documentation says absolute values should be set on behalf of a system that acts as the source of truth; otherwise it points integrations towards adjustment operations. That distinction prevents two systems from repeatedly replacing each other's work.
Record the owner, rule version and effective time with each synchronisation decision. When ownership changes—because a warehouse opens, a 3PL takes over or a store is migrated—the mapping and tests must change before the live write path does.
Map exact items and locations before moving quantities
A stock update is safe only when the integration knows exactly which item and location it affects. Map Shopify product and variant identifiers to Shopify inventory-item identifiers, then to the ERP item identifier. Map Shopify location IDs to the corresponding ERP warehouse, bin or location scope.
Do not rely on titles, product handles or display names. SKUs are useful but can be missing, duplicated or changed, so treat them as governed business keys only when the organisation enforces uniqueness. Preserve the provider IDs and the approved cross-system mapping.
Block ambiguous records. If one ERP item maps to two active Shopify variants unexpectedly, or a location has no approved warehouse match, place the record in an exception queue. Guessing is more dangerous than showing temporarily conservative availability.
- Shopify product, variant and inventory-item IDs
- ERP item or stock-record ID
- Shopify location ID and ERP warehouse or bin ID
- SKU, barcode and supplier reference as reviewed supporting keys
- Mapping status, owner, effective date and last verification
Use one event to produce one business effect
Webhooks and queues are normally delivered with at-least-once behaviour: retries protect against lost messages, but the same event can arrive more than once. Shopify says duplicate webhook deliveries can occur after a timeout or retry and recommends idempotent processing. It provides delivery and event identifiers that integrations can use to deduplicate or correlate messages.
Store a durable idempotency key before applying the stock change. A repeated delivery with the same business operation must return the recorded outcome rather than adjust quantity again. The key should represent the operation—such as a particular order allocation or stock correction—not merely the time a worker happened to process it.
The same protection belongs on outbound writes. Shopify now requires idempotency keys for the current inventorySetQuantities mutation and supports compare-and-set behaviour. A network timeout must not tempt the integration to invent a new key and apply the same correction twice.
Reject stale and out-of-order updates
Fast systems still deliver events out of order. A warehouse correction created at 10:02 can reach the store after a later count created at 10:05. If the integration blindly writes in arrival order, it restores the older value.
Carry the source record version, source event time and last accepted version for each item-location pair. Apply a new state only when it is newer under the agreed ordering rule. Do not use the integration server's receipt time as proof that the business data is newer.
For absolute quantity writes, compare the current destination value with the value the workflow previously observed. Shopify's compare-and-set control rejects the update when the persisted quantity no longer matches the comparison value. Treat that rejection as a concurrency signal to re-read and reconcile, not as an error to defeat by switching off the check.
Separate event updates from reconciliation
Events provide low-latency movement; reconciliation proves that the resulting state is correct. Use both. A webhook can be missed, a credential can expire, a queue can stall or a mapping can change after an event was produced.
Run a scheduled comparison across every governed item-location pair. Compare identifiers, relevant inventory states, update times and rule versions. Classify differences rather than immediately overwriting them: expected in-flight difference, mapping problem, stale event, failed write, unrecognised manual change or genuine source discrepancy.
Reconciliation should report totals as well as records. Count source items, mapped items, successfully compared items, mismatches, exclusions and failures. A job that compared 9,990 of 10,000 items is not complete until the missing ten are explained.
Keep the overselling rule conservative during failure
Agree what happens when the source cannot be reached. Reusing the last known quantity indefinitely is simple but risky. Setting everything to zero protects stock but can stop valid sales. The right policy depends on item value, sales velocity, fulfilment tolerance and how quickly staff can intervene.
Possible controls include a safety-stock buffer, a maximum age for the last verified quantity, per-item caps, a pause for high-risk SKUs and a read-only exception route. Make the policy visible to operations and apply it consistently; do not let a background worker improvise.
Credentials, provider limits and maintenance windows should have distinct alerts. Retry transient failures with bounded backoff, but send expired authentication, invalid mapping and business-rule conflicts to people who can resolve them.
A concrete example: one part across two warehouses
Consider a replacement part sold as one Shopify variant and held in two NetSuite warehouses. The approved mapping connects the Shopify inventory-item ID to one NetSuite item ID and connects each Shopify location to its matching warehouse. NetSuite owns physical on hand and internal reservations; Shopify owns current checkout commitments.
The business rule calculates the channel quantity separately for each warehouse, applies the approved safety buffer once and never subtracts a Shopify commitment that NetSuite has already received. The result includes its source version, calculation rule and effective time.
At 10:02, warehouse A reports 12 sellable units. At 10:03, a Shopify order commits one unit. At 10:05, NetSuite records the order and reports 11. If the earlier 12-unit message is retried after 10:05, the integration recognises its idempotency key and stale source version, so it cannot restore 12.
If Shopify's current value no longer matches the integration's comparison value, the write is rejected and re-read. The reconciliation job later confirms 11 at warehouse A and reports warehouse B independently. No value is silently pooled across locations, and staff can trace every accepted or rejected change.
Design an exception queue people can actually use
An exception needs enough context to resolve it: product and variant, source item, location, source and destination values, inventory states, event and version identifiers, attempted rule, provider response and suggested next check. A red failed label without evidence simply creates another manual investigation.
Prioritise by commercial risk. Negative quantities, active high-velocity products, unmapped order lines and repeated concurrency conflicts should normally appear above a slow-moving discrepancy. Let authorised users retry only after the underlying issue is corrected.
Preserve the original failure and the resolution. Editing the audit record to make a retry look successful removes the evidence needed to prevent recurrence.
Test the race conditions, not only the happy path
A stock integration can pass a demonstration and still fail under real ordering and retry behaviour. Build repeatable cases for duplicate events, delayed events, two simultaneous writes, location remapping, missing identifiers, partial batch failure, expired credentials, provider rate limits and reconciliation during an active order.
Verify the business outcome after every case. A successful HTTP response is not enough; confirm the exact item, location, quantity state, source reference and audit entry. Test that an unauthorised user or connector cannot write inventory it does not own.
Before launch, replay representative production-shaped records in a non-production environment or controlled dry run. Compare the proposed writes with the values operations expects, then activate one limited location or product group before expanding.
- The same event delivered twice changes stock only once
- An older event cannot overwrite a newer accepted state
- A compare-and-set conflict triggers re-read and review
- One failed record does not hide behind a successful batch total
- Unmapped items and locations are blocked, not guessed
- Reconciliation finds a deliberately missed event
- Expired credentials produce an actionable alert
Measure stock accuracy and recovery
Useful measures include mapped item-location coverage, quantity agreement rate, event processing delay, stale-event rejection count, duplicate suppression count, reconciliation mismatch age, exception resolution time and oversell incidents. Track both median and worst-case delays because a small tail can contain the commercially important failures.
Review manual corrections as evidence. Repeated changes to the same item may reveal a bad ownership rule, duplicate mapping or timing gap rather than careless users. Fix the workflow instead of training staff to compensate for it.
M.I.A.I Integration Engine can coordinate approved mappings, synchronisation workflows, monitoring and exception handling between Shopify, NetSuite and other connected systems. The outcome to pursue is not constant data movement; it is a sellable quantity the business can explain, verify and recover when something goes wrong.
Stock synchronisation launch checklist
Launch only when commerce, operations and finance agree the definitions and owners. Document the rollback and failure policy alongside the mapping so support staff do not have to reconstruct it during an incident.
After launch, keep reconciliation and exception review permanent. Inventory correctness is a continuing control, not a one-off migration milestone.
- Define physical, committed, reserved, safety and sellable quantities
- Assign the source of truth for every field and location
- Map exact provider item and location identifiers
- Make inbound events and outbound writes idempotent
- Reject stale events and use concurrency comparisons
- Reconcile all governed item-location pairs on a schedule
- Apply a documented conservative failure policy
- Give people an evidence-rich exception queue
- Test duplicates, reordering, partial failure and credential loss
- Monitor accuracy, latency, exception age and oversell incidents
AUTHORITATIVE SOURCES
Guidance used in this article
FREQUENTLY ASKED QUESTIONS
Questions about ecommerce integrations and AI search content
Should Shopify or the ERP be the source of truth for stock?
There is no universal answer. Assign ownership by inventory meaning and location. An ERP often owns physical warehouse stock while Shopify owns checkout commitments, but the integration must document the exact rule.
How often should Shopify and ERP inventory be synchronised?
Use events for low-latency changes and scheduled reconciliation to prove completeness. The acceptable delay depends on sales velocity, stock depth and overselling risk.
Why can duplicate webhooks change stock twice?
Webhook delivery can be retried. The handler must use a durable idempotency key so a repeated business operation returns the first result instead of applying another adjustment.
What should happen when Shopify and the ERP disagree?
Classify the mismatch, preserve both values and their timestamps, then follow the ownership rule or send the record to review. Do not let the most recent arrival automatically win.
What does M.I.A.I Integration Engine provide for inventory workflows?
It is designed to coordinate governed mappings, synchronisation workflows, operational monitoring and human exception handling across connected ecommerce and ERP systems.
