Orders
Read and cancel customer orders (GetOrder, GetTracking, CancelOrder) and list a shopper's order history (ListOrdersByShopper).
Introduction
REST contract of the customer-ordering bounded context of the retail network, derived from the retail-network model (warehouse-docs network/model/model.yaml, contexts[customer-ordering].rest) and adjusted by the final cross-context decisions (contracts-delta E7, E9, E11 and Gap Register G7, G10, G12, G25, and the storefront extension NG1-NG3: saved addresses, checkout by saved address, shopper by e-mail and the order history). It turns a shopper's cart into a customer order: checkout promises and confirms every shipment group at delivery-promise before the order is placed, the order carries the ship-to address (synthetic PII, held only here), the tracking view is fed by events, and a customer cancellation is a request that order-sourcing decides. One restricted in-organization route, GET /orders/{orderId}/ship-to, is called only by shipping-and-tracking to print a label and is the only route that returns the address. There is no authentication anywhere in the network; 'restricted' means the route is not exposed through the storefront edge. Errors are RFC 9457 problem details (application/problem+json) whose type is /problems/<slug>. The shared problem types are not-found (404), illegal-transition (409), concurrent-update (409) and validation-failed (422). A POST or PUT retried under the same Idempotency-Key is answered from the store only when its first answer is final for the request; see the Idempotency-Key parameter for the refusals that are not stored. Optional fields are omitted when absent, never null. The one exception is the read-only analytics reports (tag reports, ADR 0018): served by cmd/co-reports on its own port (per-path server) from the separate analytical database, snake_case, with explicit nulls where a figure has no defined value.
Save an address on a shopper
AddSavedAddress. The addressId derives from the Idempotency-Key, so a replay (even after the idempotency record expired) returns the same address. A shopper holds at most 20 saved addresses; the twenty-first is 422 too-many-addresses (ErrTooManyAddresses). A checkout can then name the address by its id (CheckoutRequest.shipToAddressId) and the address is copied into the order at placement.
Request the cancellation of every group that is not yet locked (creates a cancellation request)
CancelOrder is a request (G12, G25). Every group still PROMISED (no node locked yet) moves to CANCELLATION_REQUESTED and CustomerOrderCancelled is published through the outbox with those groupNos; locked, shipped and delivered groups are untouched. order-sourcing decides: FulfillmentCancelled makes the group CANCELLED (the order is CANCELLED once every group is), FulfillmentCancelRefused returns the group to fulfilment (the vendor ships; the shopper path becomes a return). Refused with 409 cancel-after-lock (ErrCancelAfterLock) when no group is unlocked. Repeating the request, or cancelling a CANCELLED order, returns the order unchanged and publishes nothing.
Checkout
Checkout
Find a shopper by e-mail
FindShopperByEmail. The match is trimmed and lower-cased, like the uniqueness of the registration (case-insensitive). No shopper with that e-mail is 404 not-found; an absent or empty e-mail matches nothing and is 404 too. The e-mail is unique, so this is a lookup of one shopper (a single resource that merely contains its saved addresses), not a collection.
Liveness probe
Always 200 while the process runs; it checks no dependency.
Read the notification policy (who notifies the shopper per event family)
The versioned NotificationPolicy document (ADR 0017). Version 0 is the built-in default: every family NOBODY, nothing delivered. The document decides the notifier stamp of every ShopperNoticeDecided fact; the notice itself is delivered outside the network (the marketplace notifier is the storefront consuming the event).
Get the order's tracking view per shipment group and package
Served from the event-fed read model OrderTrackingView (delivery-promise, order-sourcing and shipping-and-tracking events) joined with the order's groups. A package scanned before its label or shipment event arrived is listed once the order is known. One composite view of a single order, bounded by the order's shipment groups, so it is not paginated.
Get a customer order with its status and the promise per group
Returns the order without the ship-to address; the address is only on the restricted ship-to route.
Order-side KPIs per UTC day
Per UTC day (of placedAt, cancelledAt and decidedAt respectively), from this context's own events only: orders_placed (CustomerOrderPlaced); orders_cancelled (DISTINCT orders with a CustomerOrderCancelled request that day: a request, order-sourcing may still refuse it, and not a cohort of that day's placements); consolidated_tier_orders (placed orders with at least one CONSOLIDATED group, ADR 0013); pickup_point_orders (placed orders to a pickup point, ADR 0016); split_shipment_orders (placed orders with two or more shipment groups) and split_shipment_share = split_shipment_orders / orders_placed, null on a day without placed orders; shopper_notices_decided (ShopperNoticeDecided, ADR 0017, whatever the notifier) with shopper_notices_by_kind (at most 5 families, most frequent first, ties by family) and shopper_notices_other (the notices of the families left out, so the total is always exact). Days with none of these facts are omitted. The response carries the projection's freshness (the same as GET /reports/freshness).
Readiness probe
200 when the drain gate is open, Postgres answers a ping and Kafka answers a metadata request (an empty, non-nil topic list). Otherwise 503 with the problem type dependency-unavailable.
How far the analytics projection is behind
as_of is the CloudEvents time of the newest event the projector applied; lag_seconds is now minus as_of, never negative. Both are null until the first event. One endpoint for every report: they all read the same projection.
Get the ship-to address of an order (restricted, label printing only)
In-organization, restricted route for shipping-and-tracking (GetShipTo), called when it issues a label. The only route that returns ship-to PII (synthetic). A pickup order answers its destination kind and point instead - no PII at all (ADR 0016). Not exposed through the storefront edge.
Get a shopper profile with its saved addresses
GetShopper. The saved addresses are synthetic PII; they leave the service only on the shopper routes (and the restricted ship-to route of an order), never an event.
List a shopper's order history, newest first
ListOrdersByShopper. Keyset pagination: the page is ordered placedAt descending with the orderId as the ascending tiebreak, `limit` defaults to 100 and is at most 500, and `cursor` is the nextCursor of the previous page (opaque). A bad limit is 400 invalid-limit, an undecodable cursor is 400 invalid-cursor and any other query parameter is 400 unknown-query-parameter. An unknown shopper is 404 not-found; a shopper without orders is an empty page. The items never carry the ship-to address.
Operations
Operations
Orders
Orders
Place a customer order, promising and confirming every shipment group
PlaceOrder. For each shipment group the service calls delivery-promise MakePromise (POST /promises) with the offer the shopper saw and then ConfirmPromise (POST /promises/{promiseId}/confirmations) before anything is stored. If an offer expired or was consumed, or a confirm fails, it re-quotes (QuoteDeliveryOffers, POST /delivery-quotes) and answers 409 offer-not-quotable with the new offers; no order is placed. On success the order is PLACED and CustomerOrderPlaced is published through the outbox in the same transaction. The order id is derived from the Idempotency-Key, so a retry after a timeout reuses the same promises.
Publish the next version of the notification policy (whole document)
Whole-document PUT (ADR 0017): the body carries one row per family. The next version number is derived (current + 1); every version is kept. Publishing version 1 is what wakes a family up — until then the posture is silence. No event is raised: v1 is analytics-free.
Register a synthetic shopper
RegisterShopper. The email is unique, compared case-insensitively; a duplicate is refused with 409 shopper-exists (ErrShopperExists).
reports
reports
Ship-To
Ship-To
Shoppers
Shoppers