Receive a new order — allocates and releases automatically
POST/orders
Intake — the ReceiveOrder use case. Validates every requested line (SKU non-empty, quantity > 0), mints an OrderId, and persists the order in Received status, publishing OrderReceived unconditionally.
Immediately afterward, in the SAME call, this service attempts allocation-then-release: it reserves stock per line via inventory-storage's POST /reservations (see the Allocation tag), and for every line that ends up Allocated and eligible under BR3 (see below), releases it — announced via the enriched OrderAllocated / OrderPartiallyAllocated Kafka events, never a second synchronous call. If that implicit allocation attempt hits a hard (non-business) failure, this endpoint still returns 201: the order genuinely was received, and a caller expressing "place an order" must never be told that failed just because an internal, best-effort next step could not complete. The returned body reflects whatever the allocation pass actually achieved.
allowPartialShipment defaults to false — ship-complete (BR3). Every line's pathId is chosen by this service, not the caller (ADR 0021): the active process paths in the process-path catalogue are filtered by their declared eligibility and the shortest known cycle time wins (ties: lower path id), falling back to the default pick when no catalogue is configured or no path is active. A caller placing an order has no business supplying wes-work-planning's process-path vocabulary at intake; pathId is visible on every line in the response, but not settable on the request.
Idempotent (REST guideline, ADR 0023/0048): send an Idempotency-Key header. A retry with the same key, method, path and body replays the stored answer (with Idempotency-Replayed: true) and creates no second order; the same key with another body is 409 idempotency-key-reused. Only a final answer is stored: a 2xx, or a refusal that is a function of the request (400 malformed-request-body, order-without-lines, empty-sku, invalid-fulfillment-site-id, 422 non-positive-quantity, held-order-must-be-ship-complete). A refusal that depends on state that can change (unknown-process-path, line-ineligible-for-resolved-path) and every 5xx are not stored: the key is released and a retry under the same key executes again.
Request
Responses
- 201
- 400
- 409
- 422
- 500
- 503
Order received. Reflects whatever the immediate allocation-then-release attempt achieved — Received, Backordered, PartiallyAllocated/PartiallyReleased, Allocated, or Released — a caller inspects status/line status for the outcome rather than assuming Received.
Response Headers
Present, with the value true, ONLY when this response is a replay of the stored answer for the request's Idempotency-Key (the handler did not run again). The first execution of a key never carries it.
Canonical URI of the created order.
/orders/ord-a1b2c3d4-0000-0000-0000-000000000001The request body is malformed or invalid — an empty or missing SKU, a body with no lines, an explicit null on a non-nullable field, or a fulfillmentSiteId that is not a site code of uppercase letters and digits (problem type invalid-fulfillment-site-id, ADR 0044), or a body that is not valid JSON (malformed-request-body), or a resolved process path that is not active in the process-path catalogue (unknown-process-path). A missing or malformed Idempotency-Key header is also a 400 (idempotency-key-required / idempotency-key-invalid).
The Idempotency-Key was already used with a different method, path or body (idempotency-key-reused), or the write lost an optimistic-concurrency race (concurrent-modification).
A line quantity is not greater than zero (non-positive-quantity), a line's attributes are not eligible for its resolved process path (line-ineligible-for-resolved-path), or a held order (releaseOnAllocation: false) was combined with allowPartialShipment: true (held-order-must-be-ship-complete).
An unexpected internal error occurred.
inventory-storage could not be reached (transport error, timeout, open circuit breaker), answered with an unexpected status, or is wired in permissive (no-op) mode, or reported insufficient usable stock. Problem type is downstream-unavailable for an infrastructure failure, downstream-not-configured for permissive mode and insufficient-stock for the latter. Never papered over with a 2xx: allocating real stock must not appear to succeed when it did not.