Variant inventory
Auditable ledger, balance per warehouse and selective quantity publication.
Inventory always belongs to a Variant, never directly to the Product or the Listing. This lets black/16 GB, white/16 GB and black/32 GB have independent balances, even when they appear together in the same listing. A Listing only receives the quantity of the Variant linked by the binding.
Within the Variant, the balance is per warehouse: each Variant has one balance line per warehouse of the seller, and the Variant balance is their sum.
How the balance is computed and reaches the marketplace, with diagrams: Catalog and inventory.
Pick one source of truth per Variant
inventoryAuthority | Who decides the balance | API behavior |
|---|---|---|
marketapi | MarketAPI | accepts immutable movements and computes the ledger |
managed_externally | ERP/WMS or another system | does not accept local movements as the source of truth |
derived | the kit BOM | computes availability from the components |
disabled | nobody in this API | no managed or publishable quantity |
Do not choose marketapi just to "push a balance" if the ERP is still the authority. First define where a sale, return or adjustment will be recorded; duplicating both sides produces unavoidable divergence.
Full inventory flow
- On the Variant, choose
inventoryAuthority: "marketapi"if this ledger owns the balance. - Record movements with a type, a quantity and a business reference when there is an order, ERP or transfer. Without
warehouseId, the movement goes to the seller's default warehouse. - Read the balance.
available, notonHand, is the quantity that can be offered. - To send the quantity now, pick targets in the movement itself or use resend inventory.
- For automation after future movements, mark the bindings and the Listing policy. Automation sends only quantity, and only to listings already published that are neither closed (
closed) nor deleted at the marketplace (deleted); it does not republish content, price or media. Changing the Variant of a line in Update binding also sends the new Variant's quantity. - Follow the Job and the
inventory.publishedwebhook. Connection capabilities are still required for any external call.
Warehouses and transfer
Every seller starts with a default warehouse. Create others in Create warehouse if it keeps stock in more than one place.
- A movement changes one warehouse.
warehouseIdpicks which. Without it, it is the default one. - Transfer (
type: "transfer"): takes from the source warehouse (warehouseId) and puts into the destination (toWarehouseId), with a positive quantity. It writes two ledger rows with the sametransferId. The Variant total does not change, but the quantity of each marketplace location may change (it sums the warehouses of the fulfillment mapping). So a transfer also triggers automatic publication. - Warehouse of another seller:
404. Archived warehouse:409withdetails.reason = "warehouse_archived". - Not enough stock in the warehouse:
409withdetails.reason = "inventory_underflow", and nothing is written.
How balances are computed
For a managed Variant, available = onHand - reserved, in each warehouse. A reservation lowers available without taking the physical unit out of stock; a confirmed sale lowers both. Reservation, release and sale are per warehouse too: take stock out of the same warehouse where you reserved it.
The API does not accept a negative balance: the movement returns 409 (inventory_underflow) with the warehouseId of the warehouse that went short. Only a Variant that allows backorder may go negative.
A derived kit has no movement of its own. The kit is calculated per warehouse: in each one, it is the smallest whole quotient of the components that are there, and the warehouses are summed. A kit is not assembled from parts that sit in two places.
If a kit uses two cables and one charger, with 10 cables and 3 chargers in the same warehouse, the kit balance is 3. If the 3 chargers are in another warehouse, with no cables, the kit is worth 0 in both. Check the BOM to explain that number; recording a movement on the components recalculates it on the next read.
Locations at the marketplace
marketapi reads the account's stock locations (List locations) on connect and on every reconciliation, and on the first save creates the fulfillment mapping: the seller's default warehouse feeds the primary location. A new warehouse is never added to the mapping by itself; use Update mapping.
- Publication per location. Publishing sends one quantity to each mapped location: the sum of
availableof its warehouses. A location outside the mapping is not touched. A Connection with no mapped location gets no publication, and an explicit request with no target answers409(inventory_target_empty). - Fulfillment locations (Full, FBA, FBS) are read-only. They never receive a publication: they only show up as observed stock.
- Scope (
inventory.scope).binding: one publication per offer line.marketplace_product_variant: one publication per marketplace product variant, for every offer that shares it (Mercado Livre User Products). A kit whose stock the marketplace computes is not published. - What the marketplace says it has is kept per target and location:
available,reserved(campaign or promotion),inTransitandunfulfillable. It is refreshed by notifications and by a reconciliation every 6 hours (sync state), and shows up inexternal[]of the variant balance, next topublishedQuantity. - Zero, once. A location that loses its last warehouse in the mapping gets 0 one time, and only if we already published a number above 0 there. After that marketapi no longer touches the location, and never zeroes a number the seller keeps by hand where we never published. It applies to every publication of the target, not only the one from the
PATCH. A 0 counts only once the marketplace accepts it; if it is refused, the next publication of the target sends it again. - What triggers automatic publication: a movement (including a transfer), a change to the mapping, the reconnection of a Connection that was
revokedor inerror, the first publication of the listing and the ones that change a variation ID (listing.publishwithautomaticpolicy,relist, marketplace product publish, import), switching a line's Variant, and the automatic resend described below. On a marketplace with stock per location, publishing the offer andrelistsend 0 and ask for this publication right after, under any policy and also for a line withinventoryEligible: false(the new offer can show 0 for a few seconds). - Crossed answer. If another publication of the same target may have crossed yours, the item ends
succeededand the quantities reached the marketplace, but the answer is not applied (noinventory.published).result.followUpJobIdof the item points to the automaticinventory.publishthat resends the current quantities (job items). - When publishing ends, the
inventory.publishedwebhook carrieslocations(locationIdandquantityof each location).
On Mercado Livre, inventory.read and inventory.publish are not supported: the location and mapping routes answer 422 (CAPABILITY_UNSUPPORTED), and a stock send does not reach an item that already exists. The quantity goes only when the item is created, with the total of the Variant's warehouses, so creating needs inventoryAuthority: marketapi (details). After you change the stock of an ML item, the inventory group of the diff stays pending_publication. Sending stock to an existing item is #56.
Stock discrepancies
A discrepancy is born when the marketplace shows, at a seller location (seller_location), a different number from the last one marketapi published there. The math is difference = (available + reserved) − published: the marketplace reservation is part of the published number.
- Only a managed target opens a discrepancy: a line with
inventoryEligible: trueof a Variant withinventoryAuthoritymarketapiorderived, under any policy, includingmanual(there, the discrepancy stays open until someone resolves it). Stock that your ERP manages (managed_externally) or that is off (disabled) does not. - It closes by itself with
resolution: "auto"when the numbers match again. It closes withresolution: "target_unmanaged"when the target leaves management: the line stops being eligible, the Variant becomesmanaged_externallyordisabled, or the binding, the listing or the marketplace product variation is removed. A dead offer also leaves management: closed (closed, by thecloseaction or by a read that finds it closed), deleted (deleted) or relisted (relist: the old offer's discrepancy closes), or with a line removed. A later read of the dead offer opens no discrepancy; a paused offer stays managed. It closes withresolution: "variant_changed"when the line starts selling another Variant (Update binding): the difference belonged to the old Variant and does not apply to the new one. If the change also takes the line out of management, the resolution istarget_unmanaged. Every closing announcesinventory.discrepancy_resolved. variantIdis the measured Variant: the one the target sold when the discrepancy opened. It never changes, not even on a Variant change. ThevariantIdfilter of the list, the events andaccept_observeduse that Variant.- Variant change: the published number of each location restarts at the last number the marketplace showed, and the next read is measured against it. The new Variant's number is pending publication: under the
manualpolicy, the diff showspending_publication; underautomatic, the change already requests the publication. - A sale shows up as a discrepancy until the order is imported.
- Notice:
inventory.discrepancy_detectedwhen it opens andinventory.discrepancy_resolvedwhen it closes. If the numbers change while it is open, only the record is updated, with no event.
List the discrepancies and close each one with Resolve discrepancy:
action | What it does |
|---|---|
republish | Publishes marketapi's number again. |
accept_observed | Records an adjustment movement so the balance matches the marketplace. Accepts warehouseId. |
dismiss | Just closes it. If the number is still different on the next read, a new discrepancy opens. |
Marketplace with stock per location. A stock change made outside arrives as inventory.discrepancy_detected and inventory.discrepancy_resolved, no longer as listing.external_changed. In the listing diff, the inventory group only compares the desired value with what was published: pending_publication or in_sync, never external_change or conflict. A marketplace without stock per location does not change.
Current support
Use the complete marketplace matrix to compare product support. The Connection capability still decides whether publication can be queued for that account.
Publish inventory
- MockDevelopment only
- Mercado LivreNot supported
- MagaluPlanned
- AmazonPlanned
- TikTok ShopPlanned
- ShopeePlanned
Inventory publication is always selective and asynchronous. Before choosing it, check that the binding is eligible, has an external identity and belongs to an already published Listing; also check the Connection's inventory capability.