Carts
Cart lifecycle and reads (Cart aggregate).
Introduction
REST contract of the shopping-cart bounded context of the digital storefront, derived from storefront/model/model.yaml (contexts[shopping-cart].rest) and the FINAL model-gap decisions (H1-H6 and checkout H10). The cart holds a shopper's intent: lines, destination postal prefix, the delivery quote delivery-promise returned for the cart (per shipment group, with offers and expiry), the shopper's tier selection per group, and a labelled, non-binding estimate (effective prices + selected tier charges + tax band) so the total cost is visible up front. Without a destination the estimate shows the item subtotal only and estimateComplete is false. One line per item; adding an existing item merges quantities. Any line or destination change clears the quote and the selections. Errors are RFC 9457 problem details (application/problem+json) whose type is /problems/<slug>; shared types are not-found (404), illegal-transition (409), concurrent-update (409) and validation-failed (422), plus one kebab-case slug per Err of the model, and the idempotency problems idempotency-key-required and idempotency-key-invalid (400) and idempotency-key-reused (409). Every POST takes an Idempotency-Key header: a retry with the same key and the same request replays the stored answer (Idempotency-Replayed: true). A 2xx is stored for 24 hours, and so is a refusal that is final for the request (malformed-request, quantity-out-of-range, validation-failed, cart-closed); a refusal that depends on state that can change (not-found, concurrent-update, stale-delivery-selection, item-not-purchasable, too-many-lines, no-destination, merge-target, illegal-transition) and a 5xx are never stored: the key is released, the same Idempotency-Key runs the request again, and another request under it is a new request. Otherwise the same key with another request is 409 idempotency-key-reused. PUT and DELETE are idempotent by method. GET /carts is keyset-paged ({items, nextCursor}; invalid-limit, invalid-cursor and unknown-query-parameter are 400). No authentication; shopperId is optional (guest-first).
Write the offers of a checkout requote into the cart
AcceptRequotedOffers. Checkout reports REQUOTE_REQUIRED with the requotedOffers it obtained for the groups it had selected; the BFF writes them here. The supplied set REPLACES the cart's delivery quote (one offer per group) and each offer is the selection of its group, WITHOUT calling delivery-promise. A group keeps the lineNos of the previous quote's group of the same number (a single-group quote spans every line). Lines and destination are untouched. Checkout re-verifies every offer with its pre-authorize check, so nothing is trusted here. Publishes nothing.
Add a line to the cart (merges into an existing line of the item)
AddLine. One line per item: adding an item already in the cart merges quantities; nothing is ever rejected as a duplicate. Clears the current delivery quote and selections. Publishes CartLineAdded (analytics).
Carts
Carts
Create a cart
CreateCart. shopperId is optional (guest-first, D4; the body itself may be empty) but, when sent, must be a valid id (1 to 64 characters, letters or digits first, then letters, digits and . _ : -), else 422 validation-failed. A guest cart can be merged into a shopper's cart later.
Delivery
Delivery
Get a cart with its quote, selections and estimate
GetCart. Includes the CheckoutReadiness view (every group selected, no offer expired) and the labelled, non-binding estimate. Called by the BFF and, at checkout session open, by checkout.
Lines
Lines
List carts of a shopper
ListCarts, filtered by shopperId and optionally state, newest first (createdAt, cartId descending). Keyset-paged: follow nextCursor until it is absent and repeat the filters on every page request.
Merge this cart into another OPEN cart of the same shopper
MergeInto. The source cart becomes MERGED; the target must be OPEN, belong to the same shopper and never be the cart itself (ErrMergeTarget).
Quote delivery offers for the cart
QuoteDelivery. Calls delivery-promise POST /delivery-quotes (network OHS, with the request's Idempotency-Key) synchronously and stores the returned quote: groups with their lines and offers (offerId, tier, window, expiresAt) plus the unavailable tiers. The quote holds no capacity. Publishes CartDeliveryQuoted (analytics).
Remove a cart line
RemoveLine. Idempotent by method (no Idempotency-Key). Clears the current delivery quote and selections.
Select a delivery offer for a shipment group
SelectDelivery. Replaces the selection of one shipment group. The selection must name an offer of the current quote (ErrStaleDeliverySelection; a groupNo the quote does not have is the same 409). Idempotent by method (no Idempotency-Key).
Set the destination postal prefix
SetDestination. Replaces the destination of the cart. Idempotent by method (no Idempotency-Key). Clears the current delivery quote and selections.
Set the quantity of a cart line
SetLineQuantity. Replaces the quantity of the line of the item. Idempotent by method (no Idempotency-Key). Clears the current delivery quote and selections.