API overview
| Interface | Source of truth | Notes |
|---|---|---|
| REST | apis/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. |
| Events | apis/asyncapi.yaml | Summarised on the event catalogue; every field on Domain events. |
| Reports | apis/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. |
| MCP | internal/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. |
| A2A | internal/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
| Tag | Endpoint | Use case | Success |
|---|---|---|---|
| Policies | GET /policies | ListPolicies | 200 {items, nextCursor?} ordered by site then SKU |
| Policies | PUT /policies/{siteId}/{sku} | DeclarePolicy | 200, the policy, version also as ETag |
| Policies | GET /policies/{siteId}/{sku} | GetPolicy | 200, the policy, ETag |
| Policies | DELETE /policies/{siteId}/{sku} | RemovePolicy | 204; needs If-Match |
| Pick faces | GET /pick-faces | ListPickFaces | 200 {items, nextCursor?} ordered by forward bin |
| Replenishments | POST /replenishments | RaiseManualRequest | 201, Location: /replenishments/<requestId> |
| Replenishments | GET /replenishments | ListRequests | 200 {items, nextCursor?}, newest first |
| Replenishments | GET /replenishments/{requestId} | GetRequest | 200, the request |
| Replenishments | POST /replenishments/{requestId}/cancellations | CancelRequest | 200, the Cancelled request |
| Sites | POST /sites/{siteId}/evaluations | EvaluateSite | 200, the sweep summary |
| Health | GET /healthz, GET /readyz | 200 / 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 eventdata. Idempotency-Keyis 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 is400 idempotency-key-required, the same key, method, path and body replays the stored answer (4xx included, byte-identical, with the response headerIdempotency-Replayed: true; a first execution never carries it), the same key with another method, path or body is409 idempotency-key-reused. A 5xx is never stored. The PUT and DELETE of a policy do not take it: they are guarded byIf-Match.- Policy versions.
PUT /policies/{siteId}/{sku}withoutIf-Matchcreates the policy at version 1 (409 policy-already-existswhen it exists); withIf-Match: <version>(quoted or bare integer) it replaces the policy only when that is the current version (409 concurrent-modificationotherwise).DELETEwithoutIf-Matchis400 invalid-if-match. - Paging.
limit(1 to 500, default 100) and the opaquecursor(the previous page'snextCursor, base64url of the last key). A response withoutnextCursoris the last page.GET /pick-facestakes the requiredsiteIdand an optionalstatus(BELOW_MIN,OK,NO_SOURCE,NO_POLICY);GET /replenishmentstakessiteId,skuandstate(Requested,Completed,Cancelled);GET /policiestakessiteIdandsku.limitandcursorare single-valued: an empty or repeatedlimitis400 invalid-limit, a repeatedcursoris400 invalid-cursor, and any query parameter a paged list does not declare is400 unknown-query-parameter(naming the first one). - Errors are RFC 7807
application/problem+jsonwithtype = https://errors.pick-face-replenishment.warehouse-systems.dev/<slug>from one table (problemCatalogueininternal/adapters/inbound/http/errors.go). The slugs aremalformed-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-reusedandinternal-error. Causes and fixes are on Troubleshooting. - Auth: none. The fleet removed REST and MCP bearer auth on 2026-09-11 and
TestNoAuthMiddlewareReintroducedfails CI if auth middleware returns. - CORS: the router installs no CORS middleware.