Skip to main content

Reservations

Revocable bindings of usable stock to demand. A Reservation can be revoked (returning its quantity to usable) or confirmed as picked (consuming it) — it never permanently binds to one physical bin, so a failed pick can be re-satisfied elsewhere.

📄️Look up every reservation for a demand reference

Returns every Reservation ever created against a caller-supplied demandRef (an external system's order+line reference, e.g. from order-management). A demandRef can have MULTIPLE reservations across its lifetime — a reservation that was revoked, followed by a successful retry — so this returns a collection, not a single resource; an unknown demandRef returns 200 with an empty `items` array, not 404. The collection is keyset-paginated (REST guideline section 3): one page of `{items, nextCursor}` ordered by (createdAt, id), `limit` (1-500, default 100) and the opaque `cursor` from the previous page's `nextCursor`; `demandRef` is repeated on every page request and `nextCursor` is absent on the last page. Any query parameter other than `demandRef`, `limit` and `cursor` is 400 `unknown-query-parameter` (a retired paging parameter such as `after` fails loudly instead of reading page one forever). This is the read side backing a cross-service order-lifecycle console screen that needs to answer 'what did inventory-storage do for order X, line N'. Side-effect-free.

📄️Create a revocable reservation against usable inventory

Binds a quantity of a SKU's usable inventory (on-hand minus existing reservations, drawn forward-first: a SKU's forward pick face before its reserve bins, then smaller usable first, bin id, stock unit id (ADR 0050), across whichever StockUnits have usable quantity) to a piece of demand identified by demandRef. The reservation is NOT permanently bound to one physical StockUnit — the specific units/quantities drawn from are recorded as Allocations, but a subsequent revoke-and-reserve cycle is free to draw from a different holding. This is what lets a failed physical pick be retried without stranding the order. The reservation expires automatically after a timeout if never confirmed or revoked. Idempotent (best-effort) by (demandRef, sku, quantity): retrying this call after a dropped response returns the existing ACTIVE reservation for the same demandRef, SKU and quantity instead of creating a second one (see REST_AUDIT.md's idempotency notes). One demandRef (e.g. an order) may hold several ACTIVE reservations at once -- one per line/SKU -- so a request for a different SKU or quantity under the same demandRef is always a new reservation. The optional `lineNo` (ADR 0036) names the order line the reservation is for: it is stored, returned, and also taken into account by the replay guard (two lines of one order with the same SKU and quantity stay two reservations when their `lineNo` differ). Replays of the same Idempotency-Key with an identical body still return the cached success (with `Idempotency-Replayed: true`); a refusal that depends on stock (`insufficient-usable`, `concurrent-modification`) is not cached: the same key executes again (ADR 0053). Adding `lineNo` to a key first used without it is a different request (409 `idempotency-key-reused`). When automated storage holds the SKU, one container covering the remainder after the forward faces is drawn first and every allocation names its container in `containerId` (ADR 0054).

📄️Revoke a reservation

Cancels an ACTIVE reservation and returns its full reserved quantity to usable inventory on every StockUnit it had allocated from. This is the mechanism that makes reservations safe against physical delivery failure: revoke, then reserve again — the second reservation is free to draw from a different physical holding. Idempotent in effect (a resource that no longer exists or is already resolved simply can't be revoked again), though a second call on an already-resolved reservation is reported as 409, not a silent 204.

📄️Confirm a reservation's physical pick

Consumes a reservation: for every Allocation it holds, the allocated quantity is physically removed from its StockUnit (StockUnit transitions toward PICKED/REMOVED) and the corresponding bin capacity is released. This is a terminal, one-way command on the resource in the domain command style (not forced into PUT/PATCH) — a reservation that is already resolved, expired, or has no allocations cannot be confirmed again. Superseded by the TaskCompleted consumer (K37: fulfillment-execution's TaskCompleted for a PICK task confirms the reservation — ADR 0035 / ADR 0036); removal planned with the next breaking window.