ADR 0006: Adopt the fleet REST API guideline
Status
Accepted (2026-11-01). Supersedes ADR 0002 A3 (Idempotency-Key minting) and the custom-verb routes listed in ADR 0002 and ADR 0005.
Context
The warehouse fleet adopted one REST API guideline (warehouse-docs, REST
guideline R1-R9): nouns, never :verb suffixes or verb segments (R1, R2); every
POST and PATCH takes an Idempotency-Key (R3), answers 400
idempotency-key-required without one and 409 idempotency-key-reused when the
same key carries a different method, path or body (R4, R8); a replay carries
Idempotency-Replayed: true (R5, R6); collections page with limit and an
opaque cursor and answer {items, nextCursor} (R7), rejecting undeclared query
parameters with 400 unknown-query-parameter. PUT and DELETE are idempotent
by method and take no key. The cutover is hard: no aliases, no coexistence.
The BFF is stateless (no database): it never stored keys. It minted a
deterministic upstream key from route, subject and an optional X-Action-Id, or
from the body digest inside a ten minute window.
Decision
-
Routes. The edge routes follow the rename map:
Old New POST /products/{id}:delivery-datesPOST /products/{id}/delivery-date-quotesPOST /carts/{id}/destinationPUT /carts/{id}/destinationPOST /carts/{id}/delivery:quotePOST /carts/{id}/delivery-quotesPOST /carts/{id}/delivery:selectPUT /carts/{id}/delivery-selectionPOST /checkout/{id}:confirmPOST /checkout/{id}/confirmationsPOST /orders/{id}:cancelPOST /orders/{id}/cancellationsoperationIds are unchanged.TestRetiredRoutesAreGonepins that every old route answers 404 or 405. The upstream calls (and the allowlist) use the providers' new routes: delivery-promisePOST /delivery-quotes; shopping-cartPUT|DELETE /carts/{id}/lines/{item},PUT /carts/{id}/destination,POST /carts/{id}/delivery-quotes,PUT /carts/{id}/delivery-selection; checkoutPOST /checkout-sessions/{id}/confirmations; customer-orderingPOST /orders/{id}/cancellations. -
Idempotency.
X-Action-Idis removed. Every edgePOSTandPATCHrequires the page'sIdempotency-Key(a freshcrypto.randomUUID()per user submit, reused on retry): missing is 400idempotency-key-required, longer than 128 characters, not visible ASCII or repeated is 400idempotency-key-invalid. The upstream key isMintKey(route, subject, pageKey): no window and no body digest, the page owns the identity. The same page key on a retry reaches the provider with the same key and is replayed; the same page key with a different body reaches it with the same key and a different fingerprint, and the provider's 409idempotency-key-reusedis relayed unchanged. The BFF stores nothing. -
Replay header. When an upstream write hop answers with
Idempotency-Replayed: truethe edge answer carries it too (a composition is replayed when any write hop was). It is declared on every 2xx of every POST and PATCH inapis/openapi.yaml. -
Pagination.
GET /products,GET /cartsandGET /orderstakelimit(1-500) andcursor, relay them to the provider and relay its{items, nextCursor}page (product search alsofacetsandcategorySuggestions).afteris retired; an undeclared parameter is 400unknown-query-parameter, a bad limit 400invalid-limit; a bad cursor is the provider's 400invalid-cursor. Thepagepackage is the fleet reference. -
Exemption.
GET /categoriesisx-pagination-exempt: view: the category tree is one bounded navigation document, not a resource collection. -
Lint.
.spectral.yamlruns the fleetrest-guidelinerule;spectral lint apis/openapi.yaml --ruleset .spectral.yaml --fail-severity=warnis clean.
Consequences
- The BFF must deploy together with the REST cutover set (shopping-cart,
checkout, customer-ordering, delivery-promise, product-discovery) and with
storefront-web, its only browser client, which sends the new routes and the
Idempotency-Keyheader and followsnextCursor. - A page that sends a fresh key per click instead of per submit loses dedup on retry; a page that reuses a key for a different action gets a 409.
- Consumers changed in this repository:
internal/adapters/outbound/rest(readsIdempotency-Replayed),internal/application/usecases(upstream routes and methods, cursor forwarding),internal/domain/composition(allowlist,MintKey), the architecture fitness test, and the integration tests undercmd/api.