Skip to main content

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​

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
    Idempotency-Replayed

    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.

    Location

    Canonical URI of the created order.

    Example: /orders/ord-a1b2c3d4-0000-0000-0000-000000000001