Inventory and warehouses
Warehouses and locations, transfers between them, reservations, delivery notes in flight, incoming purchases, and the difference between physical, committed and available stock.
If you read one thing on this page, read the three balances. It is the concept every integration gets wrong when nobody wrote it down, and getting it wrong means overselling.
Everything here is gated by the warehouses module (Avanzado plan upwards),
except the availability read and the stock movement ledger of the company, which
belong to the catalog and only need products:read.
The three balances
An article does not have "a stock". It has three numbers, and the availability read returns all three:
| Field | What it is |
|---|---|
physical_total | What is on the shelf. What a stocktake would count. |
committed_total | What is held by live reservations plus what travels in delivery notes of a sales order not delivered yet (the next section). Still on the shelf, already promised. |
available_total | physical − committed. What you may still sell. |
Two consequences that surprise people:
- Holding stock does not move it. A reservation never writes a stock movement; the physical balance of an article with live holds is exactly the balance it would have without them. The difference appears only in the read.
- Sell against
available_total, never againstphysical_total. The second one is the warehouse's truth; the first one is the shop's.
When the available balance is lower than the physical one and you want to know
why, list the commitments
of that article: they add up to exactly the difference, each with its holder,
its warehouse, its quantity and its expiry. Each row says what kind it is in
kind — reservation or delivery_note — and holder.number carries the
number of the sales order or of the delivery note that holds the goods
(PED-2026-412, ALB-2026-240), so the row reads without a second call; it is
null when the holder is not a numbered document, like a cart. A delivery_note
row also carries holder.sales_order_id, the order the note comes from.
per_warehouse breaks the same three numbers down by warehouse, and
warehouse_breakdown_complete tells you whether that breakdown accounts for the
whole balance — do not sum the rows and assume you have the total.
Each row also carries last_location, the last known location of the article in
that warehouse — id, code and name — taken from the latest stock movement
that names a location or, failing that, from the latest posted goods receipt. It
is a hint for picking, not a balance per location, and it is null when nothing
in that warehouse names one. For many articles at once there is a
batch read.
Goods dispatched by a transfer and not yet received are published as
in_transit_total on the availability and as in_transit_quantity on the
per_warehouse row of the destination warehouse. Both are informative: in-transit
stock is not part of physical_total — the dispatch already took it out of the
origin — and it is not subtracted from available_total; it becomes physical at
the destination when it is received. A warehouse with goods in transit and no
balance appears with a physical balance of zero. in_transit_total is null
for an article that does not manage stock, like the other two totals.
What is committed
committed_total is the sum of two figures, and both are published next to it:
| Field | Part of the commitment |
|---|---|
reserved_total | What live reservations hold: a cart, a confirmed sales order, whatever holds stock for a holder. |
in_delivery_notes_total | What travels in delivery notes born from a sales order that have not been delivered yet. |
So committed_total = reserved_total + in_delivery_notes_total, and
available_total subtracts the whole of it from the physical balance.
The second part exists because of what serving does. Creating the delivery note
of an order consumes the reservation, but the physical balance only drops when
the note is delivered. Between the two moments the units are neither held nor
gone: they are packed and waiting. Counting them keeps the available figure
honest, instead of letting it jump up and offer the same units again. When the
note is delivered the units leave in_delivery_notes_total and the physical
balance at the same time, so they are never subtracted twice.
Only delivery notes born from a sales order commit. A loose delivery note,
one that does not come from an order, does not count: it is not in
in_delivery_notes_total and it is not listed among the commitments. A
delivered, cancelled or deleted note does not count either.
What a sales order holds is measured in the base unit of the article. On a line
sold in a presentation — a box of twelve, a pallet — the reservation counts the
real units (quantity × the factor of the presentation), so reserved_total and
available_total always add up in the unit the physical balance uses. On a line
without presentation nothing changes, and the sales order itself keeps showing
each line in its own unit.
The same split holds in every per_warehouse row: reserved_quantity and
in_delivery_notes_quantity add up to committed_quantity, and available is
physical_quantity − committed_quantity, for that warehouse. It is a different
number for each warehouse and the reason to read the breakdown when you decide
where to ship from. available_total stays the authoritative figure: it is not
rebuilt by adding up the rows.
The storefront publishes the same available figure, the one that already discounts the delivery notes of an order, with the same shape as before: a single total and no breakdown, so an anonymous shopper never sees warehouses or commitments. See the storefront guide.
Incoming purchases
Goods ordered from suppliers and not received yet are published next to the
balances, so you can answer "when is it back" without leaving the read. Each
per_warehouse row carries incoming, one entry per sent, confirmed or partially
received purchase order with quantity still to receive in that warehouse. An order
already sent to the supplier counts as incoming, even before the supplier confirms
it:
| Field | What it is |
|---|---|
purchase_order | The order that brings the goods: id and number. |
status | The status of that purchase order: sent (sent to the supplier and not confirmed yet), confirmed or partially_received. |
quantity | What is still to receive: ordered minus received, in the base unit of the article. What a receipt rejects does not count as received. |
pending_purchase_quantity, purchase_unit_code | The same pending quantity expressed in the purchase unit of the order lines (twelve units bought in boxes of twelve read 1.0000) and the code of that unit. Both are null when the lines of the order for the article use different purchase units. |
expected_date | The expected delivery date (YYYY-MM-DD), or null when the order has none. |
is_late | Whether the expected date has already passed. The expected day itself is not late. |
is_overdue | Whether the purchase order is overdue by the purchase order rule: its expected date is more than three grace days in the past. |
days_overdue | Calendar days since the expected date while is_overdue is true; null otherwise. |
days_in_grace | Calendar days since the expected date (1 to 3) while the order is late but still within its grace days; null otherwise. |
Entries come earliest date first and those without a date last. next_incoming
is the first of them, on each warehouse row, and on the availability itself it is
the nearest incoming purchase of the whole breakdown, or null when nothing is on
order. incoming_total adds up the quantities over every warehouse, and is
null for an article that does not manage stock. Draft, received, billed and
cancelled purchase orders never appear. The goods on their way
between your own warehouses have their own list, in_transit_transfers, with
the transfer (id and number), the quantity still on the way and the
dispatched_at instant.
is_late and is_overdue answer two different questions, and is_late keeps
meaning what it always did. An order whose expected date passed yesterday is late
and not yet overdue: it is in its three grace days and days_in_grace says which
one. From the fourth day on it is overdue, is_overdue is true and
days_overdue counts the days. The rule is the one the purchase order itself
applies, so the figure agrees with what the order shows in Factuarea.
days_overdue and days_in_grace are never both filled. The same three fields
travel on next_incoming, on the warehouse row and on the availability.
Everything incoming is informative. It never adds to physical_total nor to
available_total: the goods count when they are received, not when they are
ordered. Purchasing and receiving explains
how a receipt turns them into stock.
What is left for one order
Once an order has reserved or packed its goods, the available figure no longer
says what that order can still take: its own units are already subtracted. Pass
for_sales_order — the public id of one of your sales orders — to the
availability read,
to the list
or in the body of the batch read,
and each answer adds what belongs to that order:
| Field | What it is |
|---|---|
reserved_own_total | The part of reserved_total held by that order. |
in_delivery_notes_own_total | The part of in_delivery_notes_total that travels in delivery notes of that order. |
reserved_own_quantity, in_delivery_notes_own_quantity | The same two parts, in each per_warehouse row. |
What is free for that order is available_total plus reserved_own_total plus
in_delivery_notes_own_total. Without the parameter these fields are not
published at all, which is not the same as zero. An order of another company, or
one that does not exist, is rejected with 422
invalid_param_value on for_sales_order. The
serving plan
of an order builds on this same read, line by line.
Warehouses and locations
A warehouse has a code unique within your company, a type, an address, and
optionally locations
— the shelf, the aisle, the cold room. One warehouse is
the default, and
mark as default
moves that flag.
The DELETE verb on a warehouse archives it. The row is not removed: the
documents, the stock movements and the transfers that point at it keep
pointing at something real. It stops being returned among the active ones and
its code is freed for reuse. A warehouse that still holds stock is refused
with warehouse_not_empty.
Which warehouse a movement lands in, when the line does not name one, is
resolved by a fixed chain — the line, then the document, then the article's own
warehouse (its default_warehouse_id, see the
product catalog; an archived
preference stops counting and the chain goes on), then the company default.
Resolution is never settled quietly: it
never picks an arbitrary warehouse and it never answers "no warehouse needed".
When the chain runs out on a stock movement, the call fails out loud with
warehouse_not_resolvable — a movement
without an imputable warehouse is a lost entry. Naming warehouse_id on the
line is how you stop depending on the chain. Creating an article with opening
stock books an initial movement through the same chain; the
product catalog has the details.
The first warehouse
Creating a warehouse
answers with the warehouse in data and, next to it, two booleans about stock
management. stock_management_enabled says whether it is on for the company after
this call, and stock_management_activated whether this creation switched it
on. That only happens with the first own warehouse of a company that has the
warehouses module and no active override: an override is respected, on or off,
and later creations never touch it. Both keys travel on every response, an
idempotent replay included, which repeats the first values. The MCP tool
create_warehouse returns the same two keys.
When a company that uses warehouses has none at all and an operation that moves or
holds stock needs one — a document that moves stock, a manual adjustment, an
opening stock or a reservation — Factuarea creates the warehouse "Almacén
principal" (code PRINCIPAL, own type, marked as default) with the tax address of
the company, and resolves the operation against it. The balances the company
already had are distributed into it in the same transaction, without writing
movements, so the sum by warehouse matches the total from the start. It is created
once and can be edited like any other warehouse. It is not created when the
company already has any warehouse (archived ones included), when stock management
is off, when the company lacks the module or when its tax address is incomplete:
in those cases the chain behaves as described above.
Transfers between your own warehouses
A stock transfer moves goods from one of your warehouses to another. It has four states:
draft ──dispatch──> dispatched ──receive (every line complete)──> received
│ │
└──────cancel──────────┴──> cancelleddraftis editable: you change its header and its lines, add lines and remove them.dispatchmoves stock: the goods leave the origin warehouse and stay in transit until they arrive. A transfer with no lines is refused. This is the call to read twice before wiring it.receivetakes, per line, the quantity received now — not the running total — and optionally thedestination_location_idwhere the goods are put away. A line you do not name receives nothing. Reception is cumulative: successive receptions add up towards what was dispatched. The whole body is validated before anything is written, so receiving more than a line has pending writes nothing at all. Every reception, partial ones included, writes the incoming movement at the destination and lowers what is in transit. The transfer becomesreceivedonly when every line is complete; until then it staysdispatchedwith the rest pending.cancelis available fromdraftanddispatched;receivedis refused with 422 andcancelledis terminal. Cancelling a dispatched transfer gives back to the origin warehouse what was dispatched and not yet received, in a movement with the reasonstock_transfer_cancelled; what was already received stays at the destination. Cancelling a draft moves nothing.
The location of a reception is informative: it has no balance of its own and moves
nothing. It must be an active location of the destination warehouse; an archived
one, or one of another warehouse, is refused with 422
business_rule_violation and the subcode
stock_transfer_location_invalid.
A transfer comes back ready to display. Next to the identifiers it carries
status_label (the status label in Spanish, null when it is not resolved), the
name and code of both warehouses (origin_warehouse_name, origin_warehouse_code,
destination_warehouse_name and destination_warehouse_code, each null when
unresolved), notes, total_gross_weight_kg and, in every line, the article
(product_name, product_sku, product_variant_name when the line pins a
variant, and base_unit_code), its three quantities, its note, its
gross_weight_kg and the locations (origin_location_id, origin_location_code,
origin_location_name and the same three for the destination, null when there
is none). The list
filters by warehouse_id — the warehouse taking part as origin or destination,
with warehouse_id[in] for several — besides the origin and destination filters
of their own. A warehouse of another company gives an empty page and a malformed
value is rejected.
Creating a transfer with its lines and transport
Creating a transfer
is one atomic step: besides origin_warehouse_id, destination_warehouse_id and
notes, the body can carry lines[] — up to 100, each with product_id,
product_variant_id, quantity, origin_location_id, destination_location_id
and note — and transport. A rejected line creates nothing. Without lines the
transfer is a draft you fill in afterwards, and the number is not fiscal: it
consumes no series.
transport is the planned transport and travels on the transfer in the same shape
on every read, with each key null when there is no data:
| Field | What it is |
|---|---|
carrier_id | A carrier of your carrier master, or null. The read adds carrier_name, carrier_code and carrier_is_own_fleet. |
planned_departure_at | Planned departure, ISO 8601. |
planned_arrival_on | Planned arrival day (YYYY-MM-DD), never before the departure day. A dispatched transfer whose planned arrival is before today is late. |
load | Free description of the load, up to 120 characters. |
tracking_number | The carrier's tracking number, up to 64 characters. The read adds tracking_url, composed from the tracking URL template of the carrier. |
Editing a draft
Updating the header
takes notes and transport, partially: a key you do not send keeps its value
and null clears it. Notes and transport change while the transfer is a draft;
once it is dispatched only tracking_number and planned_arrival_on can change,
and the rest answers 422
stock_transfer_transport_locked. The
warehouses cannot change after creation: 422
stock_transfer_warehouses_frozen.
Updating a line
of a draft takes quantity, origin_location_id and note; send at least one.
Changing the quantity clears the preparation mark of that line. Both operations
return the whole transfer.
Preparation by line
Saving the preparation
records, for one or more lines of a draft, the quantity already prepared
(lines[].line_id and lines[].prepared_quantity; 0 clears the mark). Each line
then publishes prepared_quantity and prepared_at, or null when it has not been
prepared. The preparation is informative: dispatching does not require it, and
the lines you do not name keep their mark. It is all or nothing: a quantity above
the one of its line answers 422
stock_transfer_prepared_exceeds_quantity
and changes nothing.
Cancelling with a reason
cancel accepts an optional reason of up to 500 characters. The transfer then
publishes cancelled_at and cancel_reason, and the stock_transfer.cancelled
event carries the same reason.
The printable note and its copies
The PDF of the transfer note
carries both warehouses, the planned transport, the lines with their location,
note and dispatched quantity, the received quantity once something has arrived,
the weight and two signature blocks, and no amounts. copies (1 to 3, 1 by
default) repeats the note in the same PDF, each copy on its own page, and
download=1 serves it as an attachment.
When revisioned presentation is active for your company
(render_activation), the note takes the logo, the
commercial identity, the typography and the colors of the company's own template for
warehouse sheets (document_kind logistic-sheet) when it has one and, otherwise, of its
main template in the template library, and
keeps its own layout and its copies. Its heading also carries the number of the transfer
as a Code 128 barcode. The code holds the number, never a URL: when a barcode reader types
it into the search of the transfers list of the app and it matches exactly one transfer,
that transfer opens. The goods receipt sheet of a single entry and the numbered return
sheet carry their number in the same way (see
the receiving sheet and
the return sheet).
send is a
different verb: it emails the transfer note with its printable document
attached. It does not move anything.
Webhooks of a transfer
The events stock_transfer.dispatched, stock_transfer.received and
stock_transfer.cancelled carry, beside object (the transfer as the API returns
it), the quantities of the operation, line by line. line_id is the public id of
the transfer line and quantities are decimal strings with four decimals:
| Event | Key | What it lists |
|---|---|---|
stock_transfer.dispatched | dispatched_lines | [{line_id, quantity}]: what left the origin. |
stock_transfer.received | received_lines | [{line_id, quantity, pending_after}]: what that reception booked and what is still pending on each line. A partial reception lists only the lines it received. |
stock_transfer.cancelled | reason | The reason given when cancelling, or null. |
stock_transfer.cancelled | returned_lines | [{line_id, quantity}]: what went back to the origin, empty when the transfer was still a draft. |
The events guide lists the whole catalog.
Adjusting stock by hand
Adjusting the stock of an article
books a manual movement (manual_adjustment). Besides stock, operation
(set, increase or decrease), variant_id and warehouse_id, the body takes
three optional fields:
| Field | What it is |
|---|---|
adjustment_reason | Why you adjust: count (stock count), breakage, expired, loss, own_use, entry_error (correction of an earlier entry), goods_in (goods received without a purchase document) or other. It is recorded on the movement; omitted, the movement carries none. |
note | A free note of up to 255 characters, recorded on the movement. |
quantity_scope | What stock refers to: total (default) applies the operation to the total balance of the article or variant; warehouse applies it to the balance of the warehouse in warehouse_id, which becomes required. |
With quantity_scope set to warehouse, set takes stock as the final balance of
that warehouse, and increase or decrease as the amount added to or subtracted
from it; the total moves by the same amount. Whenever warehouse_id is sent, an
adjustment that would leave that warehouse below zero is rejected with 422
business_rule_violation and the subcode
warehouse_stock_cannot_be_negative,
with param warehouse_id and the balance of that warehouse and the quantity requested in details
(warehouse_id, physical_quantity and requested_quantity, the quantities as decimal strings). The answer carries movement_id, the id of the row the adjustment wrote
in the ledger.
The batch
takes the same three fields in each entry of updates and, at the top level, as a
value common to every entry that the entry overrides. If one entry would leave its
warehouse below zero, the whole batch is rejected with the same code and nothing is
applied. The MCP tools update_product_stock and bulk_update_stock take the same
fields.
The batch validates each entry before it resolves any identifier: the product is a UUID, stock is a number that is not negative, with up to four decimals and within the ceiling of the column (.5 and 5. are valid), operation is a known one, and warehouse_id and variant_id are text in UUID form. An invalid entry is 422 invalid_param_value with param updates.N.<field>. Adding to a balance that is at the ceiling, 9999999999.9999, is 422 parameter_invalid_value with param stock, in the batch and in the stock of a single product.
The response lists in data.skipped one {product_id, reason: "not_found"} per entry that was not applied, in the order sent: its product, variant or warehouse does not exist or belongs to another company, and both cases are reported the same way. It is [] when nothing was skipped, and updated does not count the skipped entries.
The stock movement ledger of the company
Listing the stock movements
reads the append-only ledger of the whole company, newest first, so you can
audit and reconcile inventory without walking the catalog article by article. It
needs products:read and has an MCP mirror, search_stock_movements. Each row is
a product ledger row plus product_id, product_name and product_sku, and it
names the warehouse and the variant it was booked to. To read the ledger of a
single article there is
its own list.
Each row names the document that caused it in source_type, source_id and
source_label. When the movement comes from a posted goods receipt, source_type
is goods_receipt, source_id is the id of that receipt and source_label its
number (REC-2026-00031), so you can show where the goods came in without a
second call. Both stay null when the document is no longer reachable and for a
manual adjustment.
The row also describes the adjustment and the balance it leaves:
| Field | What it is |
|---|---|
adjustment_reason, note | The reason and the note of a manual adjustment (see adjusting stock); null on any other movement and when the adjustment declared none. |
undone | true when a later reversing adjustment, which appears as its own row, has already undone this manual adjustment; always false on other movements. |
warehouse_stock_after | The balance of the warehouse of the row right after the movement, while stock_after is the total of the article or variant. null when the movement has no warehouse. |
The filters follow the v1 convention and combine:
| Filter | What it narrows |
|---|---|
product_id, warehouse_id | The movements of one article or one warehouse. |
variant_id | The movements booked to one variant of product_id. It needs product_id (one variant). |
reason, source_type | The reason or the origin of the movement; each also has an [in] form that takes a comma-separated list. |
source_id | The movements of one source document. It needs exactly one source_type that names a document; a document of another company gives an empty page. |
direction | in for incoming movements, out for outgoing ones. |
occurred_at[gte], occurred_at[lte] | A period, in ISO 8601. |
Pagination is by cursor with limit and starting_after; the ledger only moves
forward, so there is no ending_before. A well-formed product_id,
warehouse_id or variant_id that is not yours (or, for variant_id, that is not a
variant of the product_id) returns an empty page, never an unfiltered
listing; a malformed one, or a value outside the reason or source_type
catalog, is rejected. In MCP the period is occurred_from and occurred_to
(ISO 8601, both inclusive; a date without a time covers the whole day) and
reason and source_type take a comma-separated list.
The reason of a movement comes from a closed catalog that grows with the
platform. A transfer writes stock_transfer_dispatched at the origin,
stock_transfer_received at the destination on every reception, partial ones
included, and stock_transfer_cancelled at the origin when a dispatched
transfer is cancelled. An integration that enumerates reason must accept
stock_transfer_cancelled.
The opening group has two reasons. initial is the entry of the opening stock
of a warehouse. initial_split is the exit from the default warehouse when the
opening stock of another warehouse is recorded from goods the default warehouse
already held, so the total of the article does not change. An integration that
enumerates reason must also accept initial_split, and can filter by it with
reason=initial_split.
One variant of an article
When the variants of an article manage their own stock, each one is a stock destination of its
own. Three reads take an optional variant_id, the public id of a variant of the article:
the ledger of an article,
the ledger of the company, which
takes it together with product_id (without it the request is a 400 parameter_missing on
product_id), and
the commitments
over an article.
GET /v1/companies/{company}/stock-movements?product_id=01931b3e-7c4a-7f2e-9a8b-3c5d6e7f8a10&variant_id=01931b3e-7c4a-7f2e-9a8b-3c5d6e7f8a21- The ledger. Only the movements booked to that variant are listed. The balance of each row
does not change:
stock_afteris still the balance of the article at that moment, because the filter decides which rows are listed and not how the balance is derived. A variant that was deleted can still be read. - The commitments. Only the ones that lower the stock of that variant are listed, and they
add up to its physical balance minus its available balance. Each commitment publishes
variant_id: the variant whose stock it lowers, ornullwhen it lowers the stock of the article itself, which is also the case of a variant that does not manage its own stock. A commitment of one variant never lowers the availability of another. - An id that is not a variant of the article —one of another article or company, or one
that does not exist— returns an empty page, an empty list in the commitments, never the whole
ledger. An id that is not valid is rejected:
422invalid_param_valueonvariant_idin the ledger of an article and in the commitments, and400parameter_invalid_uuidin the ledger of the company, like the other identifiers of that endpoint.
The MCP tools list_product_stock_movements, search_stock_movements and
list_stock_availability_commitments take variant_id with the same contract.
Reorder point and reorder quantity of a variant
A variant that manages its own stock (manage_stock: true) declares two thresholds next to
low_stock_threshold, with the same rules as an article:
| Field | What it is |
|---|---|
reorder_point | When the physical stock of the variant is at or below it, the variant enters the reorder suggestions. It replaces low_stock_threshold as the trigger of the purchase. |
reorder_quantity | The quantity to replenish when the variant crosses its reorder point; without it the suggestion proposes the missing quantity. A declared 0 counts as not declared. |
Both are in base units, decimal strings with four decimals ("10.0000") or null when they are
not configured. They are written with POST and PATCH on
the variants of a product and read
with the list of variants, with the variants embedded in the product and in the snapshot of the
product.* events.
PATCH /v1/companies/{company}/products/{product}/variants/{variant}{
"reorder_point": "10.0000",
"reorder_quantity": "60.0000"
}- Optional and nullable. Non-negative, with up to four decimals. On
PATCH, an absent key keeps the current value,nullremoves it and a number sets it.create_product_variantandupdate_product_varianttake the same fields. - Only with their own stock. A variant that does not manage its own stock refuses a value
that is not
nullwith422business_rule_violation, subcodeproduct_invalid_reorder_pointandparamreorder_pointorreorder_quantity;nullis always accepted. A variant that stops managing its own stock loses both values. - No inheritance, in either direction. The variant does not use the reorder point or the
quantity of the article, and the article is not triggered by those of its variants. They are
independent from
low_stock_threshold, which keeps driving the low-stock alert.
The suggestion of a variant is described in Purchasing and receiving.
How a variant keeps its stock
manage_stock in
the update of a variant
(and in the MCP tool update_product_variant) decides whether the variant keeps its own stock
(true) or sells from the stock of the product (false). The change is accepted only when the
variant holds no stock that the other mode would lose track of. Otherwise it is a 422
variant_stock_mode_change_blocked with param
manage_stock, details.variant_id and the cause in subcode:
subcode | The variant has | Blocks |
|---|---|---|
has_own_stock | A total balance other than zero. | Own stock to the stock of the product. |
has_warehouse_balances | A total of zero but a warehouse that keeps a balance other than zero: a +5 and a −5 add up to zero and are still two balances. | Own stock to the stock of the product. |
has_live_reservations | Held reservations that have not expired. | Both directions. |
has_open_delivery_notes | Quantity committed on delivery notes of a sales order that were not delivered. | Both directions. |
has_stock_in_transit | Quantity shipped by a transfer and not yet received. | Both directions. |
To go from own stock to the stock of the product, bring the balance to zero in every warehouse
(with a transfer or a stock adjustment) and release or serve the reservations,
deliver or cancel the delivery notes and receive the transfers; then repeat the same request. The
other direction only checks the three commitments, because what the variant set aside from the
stock of the product while it sold from it would be served against an own balance that starts at
zero. Once accepted, the variant starts with zero own stock, its earlier movements stay on the
stock of the product, and a stock other than zero sent in the same request is recorded as an
entry in the ledger (goods_in).
The stock summary of the product adds up these balances: each variant with its own stock is a destination, and the stock of the product is another one when the variants without stock of their own sell from it.
Reservations: holding without moving
A reservation holds stock for a holder — a cart, an order, whatever your
system commits against — expressed as a pair of type and id. Its three states
are held, released and consumed, and the last two are terminal.
| Event | What happens to the hold |
|---|---|
| Confirming a sales order | holds the pending quantity of the lines that name a catalog article |
| Serving a line (delivery note) | consumes the hold by that quantity; the units count in in_delivery_notes_total until the note is delivered |
| Invoicing or returning a line | nothing |
| Cancelling or closing the order | releases whatever was still held |
Creating a hold never fails for lack of goods. It holds up to what is available and reports the shortfall, because whether one missing unit should abort the cart or be back-ordered is your decision, not the platform's. Check the outcome — do not assume a 200 means the full quantity was held.
A line whose article does not manage stock — a service, a fee — is skipped: it is neither held nor reported as short. A concept without stock has no constraint to declare, and calling it short would turn every services order into an outcome with shortfalls you would have to learn to ignore.
A hold can carry a lifetime in seconds. An expired hold stops counting towards
committed_total on its own; you do not have to sweep it. When a flow ends —
the cart was abandoned, the order fell through —
release by holder
releases everything that holder still holds and answers with the count, so a
holder that was holding nothing succeeds with zero instead of erroring. That
makes it safe to call at the end of any flow.
Errors worth branching on
| Code | When |
|---|---|
warehouse_not_found | The id is not yours, or does not exist. |
warehouse_not_empty | You tried to archive a warehouse that still holds stock. |
warehouse_not_resolvable | No warehouse could be resolved and none was named. Creating an article with opening stock answers it with param default_warehouse_id, and the article is not created. |
stock_transfer_already_dispatched | You dispatched twice. |
stock_transfer_not_dispatched | You tried to receive something that never left. |
stock_transfer_transport_locked | You changed, on a dispatched transfer, something other than the tracking number or the planned arrival. |
stock_transfer_warehouses_frozen | You tried to change the origin or the destination warehouse of an existing transfer. |
stock_transfer_prepared_exceeds_quantity | A prepared quantity is above the quantity of its line; nothing is saved. |
business_rule_violation with subcode warehouse_stock_cannot_be_negative | An adjustment by warehouse would leave that warehouse below zero (param warehouse_id). |
business_rule_violation with subcode stock_transfer_location_invalid | The location named in a reception is archived or belongs to another warehouse (param lines). |
stock_reservation_expired | The hold you named had already lapsed. |
variant_stock_mode_change_blocked | You switched manage_stock of a variant that still holds stock, reservations, delivery notes or transfers in transit (the cause is in subcode). |
insufficient_available_stock | What was asked for does not fit in the available balance. |
The full lists are the warehouse error index and the stock reservation error index.
Where to go next
- Sales orders — what confirming an order does here.
- Purchasing and receiving — where new stock comes from.
- Storefront — the available figure an anonymous shopper reads.
- Product catalog — the articles these balances are about.
- Warehouse and stock tools in MCP — the same reads for an agent.