Magento 2 inventory sync keeps stock levels in Magento in line with the systems where stock actually changes: the ERP, the warehouse, a POS in physical stores, and marketplaces such as Amazon. Done well, it prevents overselling and saves hours of manual updates. This guide explains how stock works in Magento 2, how to sync it through the API, and what usually goes wrong.
How stock works in Magento 2
Since Magento 2.3, stock is handled by Multi-Source Inventory (MSI):
- Sources are physical places where stock is kept: warehouses, stores, a supplier's dropship stock.
- Stocks group sources and are assigned to websites. A website sells from its stock.
- Salable quantity is what can still be sold: the quantity in the sources minus orders that are placed but not yet shipped.
- Reservations hold stock for those orders, so two shoppers can't buy the last unit at the same time.
A single-warehouse store uses the default source. A store with several warehouses or physical shops needs one source per location, and the sync has to update each of them.
Where stock changes, and which system owns it
Before any code, decide which system is the source of truth:
- ERP or warehouse system: usually owns stock for warehouses. Magento receives it.
- POS in physical stores: owns stock in each shop, and Magento needs it for click & collect or for selling store stock online.
- Marketplaces: Amazon and others sell the same stock, so their orders must reduce it, and their listings must show what's left.
- Magento itself: owns reservations for online orders until they reach the ERP.
When two systems both think they own the same number, stock goes wrong. One owner per source is the rule.
How to sync inventory through the Magento 2 API
Magento 2 has a REST API for inventory:
- Source items set the quantity and stock status of a SKU in a given source. This is the main endpoint for an MSI sync, and it accepts many SKUs in one request.
- Bulk and asynchronous API endpoints accept large updates and process them in the background through Magento's message queue, so a big import doesn't block the store.
- Orders are read from Magento by the ERP or the integration, to reserve and ship stock there.
A typical sync:
- The ERP or POS sends changed quantities, not the whole catalogue, every few minutes or on each change.
- The integration maps SKUs and locations to Magento sources.
- It updates source items in batches, through the bulk API for large volumes.
- New Magento orders go back to the ERP, which becomes the new source of truth for that stock.
- Errors go to a queue and are retried; anything that keeps failing raises an alert.
Syncing stock with marketplaces
Marketplaces sell the same stock as your store, so they need fresh numbers fast. Amazon's old MWS API has been replaced by the Selling Partner API (SP-API); any integration still built on MWS needs to be rebuilt. Other channels have their own APIs and rate limits.
Two approaches:
- A multichannel platform sits between Magento and the marketplaces and manages listings, stock and orders for all of them.
- A direct integration connects Magento or the ERP to each marketplace. It gives full control, but every channel is a separate integration to maintain.
A note for anyone searching for Stitch Labs: the service has been discontinued, so stores that relied on it for Magento inventory sync need another tool or a direct integration.
Common problems, and how to avoid them
- Overselling. Usually caused by slow syncs or two systems updating the same stock. Sync changes often, and keep a safety buffer for marketplace listings of fast-selling products.
- SKU mismatches. The ERP, POS and marketplaces use different codes. Keep a mapping table, and reject updates for unknown SKUs instead of creating products by accident.
- API rate limits. Marketplaces and some ERPs limit requests. Send only changes, in batches.
- Slow store during imports. Full stock imports trigger reindexing. Send deltas, use the asynchronous API, and set indexers to "Update by schedule". If the store still slows down, a performance audit shows why.
- Silent failures. A sync that stops without an alert can run for days before anyone notices. Monitor the last successful update, not only errors.
Questions about Magento inventory sync
Should stock sync be real-time?
For fast-selling products and marketplaces, close to real-time: every few minutes or on each change. For slow-moving stock, a few times a day is enough.
Do we need Multi-Source Inventory?
Only if you sell from more than one location. A single warehouse works with the default source.
Can we sync stock from Excel or Google Sheets?
Yes, for smaller suppliers without an API. The file needs validation, so a broken spreadsheet doesn't set your whole catalogue to zero.
Does inventory sync work with a headless storefront?
Yes. Stock stays in Magento; the storefront gets the changes through a sync, and Magento checks stock again when a product is added to the cart.
SYSINT connects Magento stores to ERP, POS, marketplaces and product feeds for agencies and online stores. See our e-commerce integration services, Magento integration and extension development and the guide to Magento system integrators.
