Skip to main content

API overview

:::info Implemented by cmd/api, cmd/mcp and cmd/a2a cmd/api serves the REST routes below (internal/adapters/inbound/http) on HTTP_ADDR (default :8080). The contracts are apis/openapi.yaml (OpenAPI 3.0.3, version 0.1.0) and apis/asyncapi.yaml (AsyncAPI 3.0.0, version 1.0.0), pinned by ADR 0001 and ADR 0004. The router registers exactly the three session routes plus /healthz and /readyz; the spec lists the three session routes and not the two probes. See the Quickstart for real responses. :::

InterfaceSource of truthNotes
RESTapis/openapi.yamlThe pages under REST are generated from the spec with npm run gen-api-docs; do not edit them by hand. Server named in the spec: http://localhost:8080; through the cluster gateway the route is /api/checkout with the prefix stripped (Kong :8000 on the local cluster).
Eventsapis/asyncapi.yamlSeven published events on two topics, none consumed. Summarised on the event catalogue; every field on Domain events.
MCPADR 0005, internal/adapters/inbound/mcpcmd/mcp serves Streamable HTTP on /mcp and / (port 8090; through Kong /api/mcp/checkout, rewritten to /mcp). One read-only tool, get_checkout_session; no write tool. No auth, by fleet decision. See MCP tools.
A2AADR 0007, internal/adapters/inbound/a2acmd/a2a serves JSON-RPC 2.0 on / and /a2a (port 8093; through Kong /api/a2a/checkout, rewritten to /), the Agent Card at /.well-known/agent-card.json and GET /healthz. One read-only skill, checkout_session_status (sessionId), no write skill. A rejection is answered in the message envelope as a problem, never as a JSON-RPC error: malformed-skill-request, unknown-skill and invalid-argument (400), not-found (404) or internal-error (500). No auth, by fleet decision.

Endpoints​

TagEndpointOperation idSuccess
CheckoutSessionsPOST /checkout-sessionsopenCheckoutSession201, the session OPEN with its binding total; Idempotency-Key required
CheckoutSessionsGET /checkout-sessions/{sessionId}getCheckoutSession200, the session; 404 not-found
CheckoutSessionsPOST /checkout-sessions/{sessionId}/confirmationsconfirmCheckoutSession200 with the session in a definitive state (COMPLETED, DECLINED, REQUOTE_REQUIRED, FAILED); 202 while an outcome is unknown (AUTHORIZING or PLACING); Idempotency-Key required
HealthGET /healthznone (not in the spec)200 {"status":"ok"}, liveness only
HealthGET /readyznone (not in the spec)200 {"status":"ready"}, or 503 while draining or while Postgres or Kafka is unreachable

Conventions in the contract​

  • Session state is one of OPEN, AUTHORIZING, DECLINED, PLACING, REQUOTE_REQUIRED, COMPLETED, EXPIRED, FAILED. Money is an integer in minor units with an ISO currency; the delivery tier is SAME_DAY, NEXT_DAY, TWO_DAY, STANDARD or CONSOLIDATED (a group may then carry the optional consolidationEligible and capacityBand). authorizationId, orderId and failureCode are null until they exist; requotedOffers appears only on a REQUOTE_REQUIRED session. version grows by one per change.
  • Idempotency-Key. Required on both POST routes (internal/adapters/inbound/http/idempotency.go): 1 to 128 printable ASCII characters, otherwise 400 idempotency-key-required (absent) or 400 idempotency-key-invalid (malformed or longer than 128). The key is global to the service, not per route. The first response below 500 is stored under the key for 24 h with the request fingerprint (method, path and SHA-256 of the body). An equal request replays it with the header Idempotency-Replayed: true (only on a replay); the same key with a different method, path or body, after a stored answer, is 409 idempotency-key-reused. A 2xx and a refusal that is final for the request (malformed-request, session-closed, price-quote-expired) or that committed state (authorization-mismatch) are stored; a refusal a retry can pass (not-found, cart-not-checkout-ready, placement-in-doubt, void-pending, concurrent-update, illegal-transition, offer-not-quotable, validation-failed, price-quote-rejected) and every 5xx are not: the key is released, the same request runs again and another body under it is a new request (ADR 0011).
  • 202 is not an error. It means the authorization or the place-order outcome is unknown; the session is saved and a policy resolves it. Poll GET /checkout-sessions/{sessionId}.
  • Errors are RFC 9457 application/problem+json with type = /problems/<slug> (a relative URI), title, status, detail and instance (the request path). The slugs the code can answer: malformed-request (400), idempotency-key-required (400), idempotency-key-invalid (400), not-found (404), resource-not-found (404, a NUL character in the path), cart-not-checkout-ready, session-closed, authorization-mismatch, placement-in-doubt, void-pending, illegal-transition, concurrent-update, idempotency-key-reused (all 409), validation-failed, price-quote-expired, offer-not-quotable, price-quote-rejected (all 422), upstream-contract-violation (502), shopping-cart-unavailable, delivery-promise-unavailable, pricing-unavailable, customer-payments-unavailable, customer-ordering-unavailable, dependency-unavailable (the /readyz answer) (all 503) and internal-error (500, the message is never leaked). Remedies are on Troubleshooting.
  • Strict bodies. Unknown fields, trailing data, an empty body and a body over 64 KiB are 400 malformed-request; a NUL character in the path, query or body is the same uniform client error.
  • Auth: none. The fleet reverted REST, MCP and A2A auth on 2026-09-11, and TestNoAuthMiddlewareReintroduced fails CI if auth middleware returns.
  • PII: none. A session holds shopperId and shipToAddressId references; the payment-method token is kept only while AUTHORIZING and is never returned by any interface.
  • Events are CloudEvents 1.0, structured mode, with a stable id across redelivery; see the event catalogue.