Skip to main content

API overview

:::info Implemented by cmd/api cmd/api serves every route below (internal/adapters/inbound/http) on PORT (default :8080). The contract is apis/openapi.yaml (OpenAPI 3.0.3, version 0.1.0, server /api/storefront), and TestRoutesMatchOpenAPI pins the router to it. The router registers exactly the 23 API routes of the spec plus /healthz and /readyz, which the spec does not list. See the Quickstart for the first calls. :::

InterfaceSource of truthNotes
RESTapis/openapi.yaml (OpenAPI 3.0.3, version 0.1.0)The pages under REST are generated from the spec with npm run gen-api-docs; do not edit them by hand. Server in the spec: /api/storefront (Kong strips the prefix; the binary answers with or without it).
EventsnoneThe BFF publishes and consumes nothing: no AsyncAPI document, no event catalogue (Domain events).
MCPnoneNo cmd/mcp.
A2AnoneNo cmd/a2a.

Endpoints​

Public paths are REST-style; the BFF maps them to the upstream custom verbs (ADR 0002, A1).

TagEndpointOperation idUpstream callSuccess
CatalogGET /productssearchProductsproduct-discovery GET /productsupstream body, filters q, categoryId, inStock, priceMin, priceMax, sort, after, limit
CatalogGET /categorieslistCategoriesproduct-discovery GET /categoriesthe category tree, relayed unchanged
CatalogGET /products/{id}getProductproduct-discovery GET /products/{id}upstream body
CatalogPOST /products/{id}:delivery-datesquoteProductDeliveryDatesdelivery-promise quote + pricing charge schedule200 {postalPrefix, tiers[], unavailable[]}
CartsPOST /cartscreateCartshopping-cart POST /cartsupstream body; sets sf_state
CartsGET /cartslistCartsshopping-cart GET /cartsupstream body
CartsGET /carts/{id}getCartshopping-cart GET /carts/{id}upstream body
CartsPOST /carts/{id}/linesaddCartLineshopping-cart POST /carts/{id}/linesupstream body
CartsPATCH /carts/{id}/lines/{item}setCartLineQuantityshopping-cart POST .../lines/{item}:set-quantityupstream body
CartsDELETE /carts/{id}/lines/{item}removeCartLineshopping-cart POST .../lines/{item}:removeupstream body
CartsPOST /carts/{id}/destinationsetCartDestinationshopping-cart POST /carts/{id}:set-destinationupstream body
CartsPOST /carts/{id}/delivery:quotequoteCartDeliveryshopping-cart POST /carts/{id}:quote-deliveryupstream body
CartsPOST /carts/{id}/delivery:selectselectCartDeliveryshopping-cart POST /carts/{id}:select-deliveryupstream body
CheckoutPOST /checkoutopenCheckoutcheckout POST /checkout-sessionsupstream body; sets sf_state
CheckoutGET /checkout/{id}getCheckoutcheckout GET /checkout-sessions/{id}upstream body
CheckoutPOST /checkout/{id}:confirmconfirmCheckoutcheckout POST /checkout-sessions/{id}:confirmupstream body (a 202 means the placement is in doubt: poll)
OrdersGET /orderslistOrderscustomer-ordering GET /ordersupstream body
OrdersGET /orders/{id}getOrdercustomer-ordering order + tracking, joined with checkout totals200, the order with tracking and totals when available
OrdersPOST /orders/{id}:cancelcancelOrdercustomer-ordering POST /orders/{id}:cancelupstream body
AccountPOST /shoppersregisterShoppercustomer-ordering POST /shoppersupstream body; sets sf_state
AccountPOST /sessionscreateSessioncustomer-ordering GET /shoppers?email=the shopper; sets sf_state
AccountGET /megetMecustomer-ordering GET /shoppers/{id}the shopper
AccountPOST /me/addressesaddMyAddresscustomer-ordering POST /shoppers/{id}/addressesupstream body
HealthGET /healthz, GET /readyznone (not in the spec)none200 {"status":"ok"}, static; readiness does not probe the upstreams

Conventions in the contract​

  • Relay, not reshape. Except the two composed routes (delivery-dates, GET /orders/{id}), the upstream status, Content-Type and body are returned untouched, so a 409 or a 422 from checkout reaches the page as checkout sent it. The generated reference therefore documents the edge's own fields; the body schemas of relayed routes belong to the upstream's OpenAPI.
  • Errors are RFC 9457 application/problem+json with type = /problems/<slug>. The edge's own slugs: malformed-request (400), resource-not-found (404), method-not-allowed (405), payload-too-large (413), validation-failed (422), session-required (422), client-closed-request (499), internal-error (500), route-not-allowed (500), upstream-unavailable (503) and gateway-timeout (504). detail is a fixed sentence and never carries request or upstream data. The causes are listed on Use cases and, with remedies, on Troubleshooting.
  • State cookie. sf_state carries c (cart), s (shopper) and k (last checkout session) as an unsigned query string: HttpOnly, SameSite=Lax, Path=/api/storefront, 30 days, Secure unless COOKIE_SECURE=false. It is state, not authentication. A malformed cookie decodes to an empty state.
  • Idempotency-Key. Required on every POST and PATCH (1-128 visible ASCII characters): a missing key is 400 idempotency-key-required, a malformed one 400 idempotency-key-invalid. PUT and DELETE take none. The client mints one key per user action and reuses it on retry. The BFF stores nothing: it derives the upstream key from route, subject and the client's key, so a retry reaches the provider with the same key. A provider's 409 idempotency-key-reused and its Idempotency-Replayed: true header pass through unchanged.
  • Time budgets. 2 s for queries, 5 s for commands, 15 s for checkout confirm, each for the whole composition; expiry is 504 gateway-timeout and is never retried.
  • Limits. Request bodies above 1 MiB are 413; a NUL character in the path, query or body is refused; upstream replies above 4 MiB are 503.
  • Prefix. Routes answer under /api/storefront and also without it.
  • Auth: none. The fleet reverted REST auth on 2026-09-11, and TestNoAuthMiddlewareReintroduced fails CI if auth middleware returns under internal/adapters/inbound. The cookie is not a credential.
  • No card data. Confirm accepts only a PSP paymentMethodToken; card-shaped keys and card-number tokens are refused with 422 before anything leaves the process.