eCommerce

Magento 2 Inventory Sync from API: MSI, ERP, POS and Amazon

Sergey

8 min read

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:

  1. The ERP or POS sends changed quantities, not the whole catalogue, every few minutes or on each change.
  2. The integration maps SKUs and locations to Magento sources.
  3. It updates source items in batches, through the bulk API for large volumes.
  4. New Magento orders go back to the ERP, which becomes the new source of truth for that stock.
  5. Errors go to a queue and are retried; anything that keeps failing raises an alert.

Inventory sync extension or a custom integration?

Search for "Magento 2 inventory sync from API extension" and you'll find several ready-made modules. They work well for one common case: a supplier or system that exposes stock through a simple API or file, and a store with one source. Where they stop:

  • Several sources. Not every module maps locations to MSI sources correctly.
  • Your ERP's quirks. Unit conversions, kits and bundles, stock reserved for key accounts, products that exist in the ERP but not in the store.
  • Orders going back. Many modules only bring stock in; they don't send Magento orders to the ERP, so the ERP never learns what was sold online.
  • Monitoring. A module that fails quietly is worse than no module.

Our usual approach: start with a vendor module if one exists for the system you use, and build a custom module when the module doesn't cover how your business actually works. Either way, the same rules apply: one owner per number, deltas instead of full imports, and an alert when the sync stops.

When the ERP has no API: file-based sync

Many ERPs, especially older ones, can't be called through an API, but they can export and import files on a schedule. That's enough for a reliable sync:

  • The ERP writes stock and prices to XML or CSV files on an FTP or SFTP server.
  • A Magento module picks up new files, validates them, and updates only what changed.
  • Orders go back the same way, as files the ERP imports.

On a B2B self-service portal we built for an industrial manufacturer, the legacy ERP was connected exactly like this, through XML files over FTP, with no changes to the ERP itself. On another project, the US division of a German manufacturer, both the ERP and the PIM exchange data with Magento through XML files. See the B2B portal case study and the headless B2B case study.

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.

Amazon inventory sync in practice

We've connected Magento to Amazon to keep both stock and products in sync. What matters most on such a project:

  • SKU and ASIN mapping. Every product needs a clear link between your SKU and the Amazon listing, or updates land on the wrong product.
  • Separate stock for FBA. Stock that sits in Amazon's warehouses (Fulfilled by Amazon) belongs to Amazon's numbers, not to your warehouse. Keep it as its own source, so it isn't sold twice.
  • A buffer for fast sellers. Marketplace orders arrive in bursts. Showing slightly less than you have on fast-selling products prevents overselling between syncs.
  • Product data, not just stock. Titles, attributes and images have to meet Amazon's category rules, which are stricter than most stores' own data.

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.

Lightspeed, ChannelAdvisor and other tools

  • Lightspeed is a POS and retail system used by many stores with physical shops. Its stock can be synced with Magento through its API or through a connector, with each shop as a separate Magento source.
  • ChannelAdvisor, now part of Rithum, is a multichannel platform: it sits between Magento and the marketplaces and manages listings, stock and orders. It suits stores selling on many channels; the trade-off is another monthly subscription and another system that owns part of your data.
  • Stitch Labs was a popular inventory and order management tool for Magento, but it has been discontinued. Stores that used it for inventory or order sync need a replacement: another platform, or a direct integration with the ERP and the marketplaces.

How a reliable inventory sync is built

Part What it does Why it matters
Change detection Sends only SKUs whose stock changed Keeps API calls low and the store fast
Mapping table Links ERP codes, POS codes, marketplace IDs and Magento SKUs Prevents updates on the wrong product
Queue Holds updates and retries failed ones Nothing is lost when an API is down for a minute
Batch updates Writes many source items in one request Large catalogs sync in minutes, not hours
Order export Sends Magento orders to the ERP The ERP stays the real source of truth
Monitoring Alerts when the last successful update is too old Silent failures get caught the same day

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.

How to test an inventory sync before going live

  • Compare stock for a sample of SKUs in every system after the first full run
  • Change stock in the ERP and time how long it takes to reach Magento and each marketplace
  • Place an order in Magento and check that it reaches the ERP and reduces stock everywhere
  • Sell the last unit of a product on two channels at once and see what happens
  • Stop the sync for an hour and check that someone gets an alert
  • Run a full import during a busy hour on staging and watch the storefront speed

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.

Is there a ready-made inventory sync from API extension?

Yes, for common cases. Check whether it supports several sources, sends orders back and alerts on failures. If it doesn't, a custom module built around your ERP is usually cheaper than working around the gaps.

How often should Amazon stock be updated?

For fast-selling products, every few minutes. Marketplace orders come in bursts, so slow updates are the main cause of overselling.

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.

Need stock, prices and orders to move between Magento, your ERP and marketplaces without manual work? SYSINT connects Magento stores to ERP, POS, Amazon and product feeds, with vendor modules where they fit and custom modules where they don't. See our e-commerce integration services, Magento integration and extension development and the guide to Magento system integrators.

Are we a good fit? Let's discuss.

Tell us about your store and what you want to get done. If we're a fit, you get a clear next step. If not, we'll tell you.

  • Reply within one business day
  • Fixed estimate before we start
  • No commitment