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: http://localhost:8080 (local) and http://localhost:8000/api/slotting-optimization (kind cluster through Kong: warehouse-infra turns the chart's gatewayApi route on). The two /reports/* operations carry their own server, http://localhost:8092: they are served by cmd/slotting-reports, not by cmd/api. |
| Events | apis/asyncapi.yaml (AsyncAPI 2.6.0, version 1.0.0) | Summarised on the event catalogue; every field on Domain events. |
| MCP | cmd/mcp (ADR 0005) | Read-only tools get_slot_plan (with the plan's execution progress, ADR 0010), list_slot_plans, get_forward_slots, get_sku_velocity; unauthenticated, Streamable HTTP at / and /mcp on :8090; in the kind cluster through Kong at http://localhost:8000/api/mcp/slotting-optimization. |
| A2A | cmd/a2a (ADR 0013) | Read-only skills forward_slot_map and slot_plan_review over the same read use cases, as an Agent2Agent agent (JSON-RPC at / and /a2a on :8093, Agent Card at /.well-known/agent-card.json); unauthenticated; domain rejections are answered in-band as problems with the REST statuses and slugs; in the kind cluster through Kong at http://localhost:8000/api/a2a/slotting-optimization once warehouse-infra enables a2a. |
Endpoints
| Tag | Endpoint | Use case | Success |
|---|---|---|---|
| Slot plans | POST /slot-plans | GeneratePlan | 201, Location: /slot-plans/<planId>, the Draft plan |
| Slot plans | GET /slot-plans | ListPlans | 200 {items, nextCursor?}, newest first |
| Slot plans | GET /slot-plans/{planId} | GetPlan | 200, the plan with its execution progress (ADR 0010) |
| Slot plans | POST /slot-plans/{planId}/approvals | ApprovePlan | 200, the Approved plan |
| Slot plans | POST /slot-plans/{planId}/rejections | RejectPlan | 200, the Rejected plan |
| Forward slots | GET /forward-slots | ListForwardSlots | 200 {siteId, planId?, approvedAt?, assignments} |
| Velocity | GET /sku-velocity | ListSkuVelocity | 200 {siteId, windowFrom, windowTo, items} |
| Health | GET /healthz, GET /readyz | 200 / 503 (Runbook) | |
Reports (cmd/slotting-reports) | GET /reports/slot-plan-funnel | report.Reader.FunnelDays | 200 {from, to, site_id?, granularity, days[{day, plans_generated, plans_approved, plans_rejected, approval_latency{count, p50_seconds, p95_seconds}, supersessions}]} |
Reports (cmd/slotting-reports) | GET /reports/freshness | report.Reader.LastEventAt | 200 {as_of, lag_seconds} (both null until the projector applied an event) |
The reports binary also serves GET /healthz (not in the spec). Its query
parameters are from and to (RFC 3339, half-open [from, to), default
the 30 days ending now, at most 366 days), siteId (optional, every site
when omitted) and granularity (only day, the default). Its JSON is
snake_case, unlike the camelCase of the OLTP API. In the kind cluster the
reports Service (slotting-optimization-reports:80) is reachable in-cluster
only: the chart renders no Kong route for it.
GET /metrics (Prometheus) is served by the binary but is not part of
apis/openapi.yaml.
Conventions
- Optional bodies.
POST /slot-planstakes{siteId?, lookbackDays?}andPOST /slot-plans/{planId}/rejectionstakes{reason?}; an empty body is valid. Unknown fields, trailing data and bodies over 64 KiB are400 malformed-request. JSON names are camelCase on REST and snake_case on the events. - Default site.
siteIdmay be omitted on generate,/forward-slotsand/sku-velocitywhenDEMAND_SITE_IDorDEFAULT_SITE_IDis configured; otherwise it is400 invalid-site-id. Idempotency-Keyis required on everyPOST(/slot-plans,/slot-plans/{planId}/approvals,/slot-plans/{planId}/rejections): missing is400 idempotency-key-required, not 1 to 128 printable ASCII characters is400 idempotency-key-invalid. The key is global; the request fingerprint is method + path + SHA-256 of the body. The same key and fingerprint replays the stored response (4xx included) withIdempotency-Replayed: true; the same key with another method, path or body is409 idempotency-key-reused. A 5xx is never cached.- Collections answer
{items, nextCursor}(limit1 to 500, default 100, opaquecursor); an undeclared query parameter is400 unknown-query-parameter.GET /forward-slotsis the one exemption (x-pagination-exempt: view: one composite resource, the site's current map). - Versions. Every plan carries
version(1 at generation, +1 per decision). There is noETagorIf-Match; concurrent writers are told apart by409 concurrent-modificationand409 approved-plan-conflict. - Paging.
GET /slot-plansuseslimit(1 to 500, default 100) and the opaquecursor(the previous page'snextCursor, base64url of the last plan id). Filters:siteId,state(Draft,Approved,Rejected,Superseded).GET /sku-velocitytakeslimitandwindowDays(1 to 365, default 28). - Errors are RFC 7807
application/problem+jsonwithtype = https://errors.slotting-optimization.warehouse-systems.dev/<slug>from one table (problemCatalogueininternal/adapters/inbound/http/errors.go):malformed-request,invalid-plan-id,invalid-site-id,invalid-lookback,invalid-limit,invalid-cursor,invalid-state,reject-reason-too-long,plan-not-found,plan-not-draft,approved-plan-conflict,concurrent-modification,idempotency-key-required,idempotency-key-reusedandinternal-error;GET /readyzaddsdependency-unavailable(readiness.go) and the reports binaryinvalid-report-range,invalid-report-granularityandreport-store-error(reports_handler.go). Causes and fixes are on Troubleshooting. - Auth: none. The fleet reverted REST and MCP auth on 2026-09-11, and
TestNoAuthMiddlewareReintroducedfails CI if auth middleware returns. - CORS:
GETandPOSTfromCORS_ALLOWED_ORIGINS(defaulthttp://localhost:5173), headersAccept,Content-Type,Idempotency-Key.