Skip to main content

API overview

InterfaceSource of truthNotes
RESTapis/openapi.yaml (OpenAPI 3.0.3, version 1.0.0)The pages under REST are generated from the spec with npm run gen-api-docs; do not edit them by hand. Servers declared in the spec: http://localhost:8080 (local) and http://localhost:8000/api/pick-face-replenishment (Kong in the kind cluster). warehouse-infra on develop routes the API through Kong at that address (helm-values/pick-face-replenishment.yaml, gatewayApi); the reports Service has no route.
Eventsapis/asyncapi.yamlSummarised on the event catalogue; every field on Domain events.
Reportsapis/openapi.yaml (tag Reports)GET /reports/replenishment-funnel and GET /reports/freshness, served by cmd/pfr-reports on http://localhost:8092 (ADR 0008), not by cmd/api.
MCPinternal/adapters/inbound/mcp (ADR 0007, ADR 0012)cmd/mcp, Streamable HTTP (stateless) on :8090 at /mcp: read-only tools list_policies, get_policy, list_pick_faces, list_replenishments, get_replenishment — every one authority L1 (com.warehouse/authority in tools/list _meta) — plus the resource template warehouse://pick-face-replenishment/policies/{siteId}/{sku} and the SOP prompt cover_below_min_pick_faces. Writes stay on REST.
A2Ainternal/adapters/inbound/a2a (ADR 0010, ADR 0012)cmd/a2a, JSON-RPC over HTTP on :8093 at / and /a2a, Agent Card at /.well-known/agent-card.json: read-only skills pick_face_status and replenishment_lookup (both tagged authority:L1), rejections answered in-band as RFC 7807-shaped problems. Writes stay on REST.

Endpoints​

TagEndpointUse caseSuccess
PoliciesGET /policiesListPolicies200 {items, nextCursor?} ordered by site then SKU
PoliciesPUT /policies/{siteId}/{sku}DeclarePolicy200, the policy, version also as ETag
PoliciesGET /policies/{siteId}/{sku}GetPolicy200, the policy, ETag
PoliciesDELETE /policies/{siteId}/{sku}RemovePolicy204; needs If-Match
Pick facesGET /pick-facesListPickFaces200 {items, nextCursor?} ordered by forward bin
ReplenishmentsPOST /replenishmentsRaiseManualRequest201, Location: /replenishments/<requestId>
ReplenishmentsGET /replenishmentsListRequests200 {items, nextCursor?}, newest first
ReplenishmentsGET /replenishments/{requestId}GetRequest200, the request
ReplenishmentsPOST /replenishments/{requestId}/cancellationsCancelRequest200, the Cancelled request
SitesPOST /sites/{siteId}/evaluationsEvaluateSite200, the sweep summary
HealthGET /healthz, GET /readyz200 / 503 (Runbook)

The router serves exactly these 12 operations: TestRouterServesExactlyTheDocumentedOperations in internal/adapters/inbound/http/contract_internal_test.go fails when the router and the spec differ. The service serves no /metrics endpoint (see Observability).

Conventions​

  • Bodies. Strict JSON: unknown fields, trailing data, an empty required body and bodies over 64 KiB are 400 malformed-request. JSON names are camelCase on REST and snake_case in event data.
  • Idempotency-Key is required on the three POSTs (/replenishments, /replenishments/{requestId}/cancellations, /sites/{siteId}/evaluations) when the service runs on Postgres: a missing or over-128-character key is 400 idempotency-key-required, the same key, method, path and body replays the stored answer (4xx included, byte-identical, with the response header Idempotency-Replayed: true; a first execution never carries it), the same key with another method, path or body is 409 idempotency-key-reused. A 5xx is never stored. The PUT and DELETE of a policy do not take it: they are guarded by If-Match.
  • Policy versions. PUT /policies/{siteId}/{sku} without If-Match creates the policy at version 1 (409 policy-already-exists when it exists); with If-Match: <version> (quoted or bare integer) it replaces the policy only when that is the current version (409 concurrent-modification otherwise). DELETE without If-Match is 400 invalid-if-match.
  • Paging. limit (1 to 500, default 100) and the opaque cursor (the previous page's nextCursor, base64url of the last key). A response without nextCursor is the last page. GET /pick-faces takes the required siteId and an optional status (BELOW_MIN, OK, NO_SOURCE, NO_POLICY); GET /replenishments takes siteId, sku and state (Requested, Completed, Cancelled); GET /policies takes siteId and sku. limit and cursor are single-valued: an empty or repeated limit is 400 invalid-limit, a repeated cursor is 400 invalid-cursor, and any query parameter a paged list does not declare is 400 unknown-query-parameter (naming the first one).
  • Errors are RFC 7807 application/problem+json with type = https://errors.pick-face-replenishment.warehouse-systems.dev/<slug> from one table (problemCatalogue in internal/adapters/inbound/http/errors.go). The slugs are malformed-request, invalid-if-match, invalid-site-id, invalid-sku, invalid-policy, invalid-quantity, invalid-request-id, invalid-state, invalid-status, invalid-limit, invalid-cursor, unknown-query-parameter, policy-not-found, replenishment-not-found, policy-already-exists, replenishment-already-open, replenishment-not-open, concurrent-modification, no-forward-assignment, no-policy, no-source-stock, nothing-to-replenish, quantity-exceeds-max, idempotency-key-required, idempotency-key-reused and internal-error. Causes and fixes are on Troubleshooting.
  • Auth: none. The fleet removed REST and MCP bearer auth on 2026-09-11 and TestNoAuthMiddlewareReintroduced fails CI if auth middleware returns.
  • CORS: the router installs no CORS middleware.