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: 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.
Eventsapis/asyncapi.yaml (AsyncAPI 2.6.0, version 1.0.0)Summarised on the event catalogue; every field on Domain events.
MCPcmd/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.
A2Acmd/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​

TagEndpointUse caseSuccess
Slot plansPOST /slot-plansGeneratePlan201, Location: /slot-plans/<planId>, the Draft plan
Slot plansGET /slot-plansListPlans200 {items, nextCursor?}, newest first
Slot plansGET /slot-plans/{planId}GetPlan200, the plan with its execution progress (ADR 0010)
Slot plansPOST /slot-plans/{planId}/approvalsApprovePlan200, the Approved plan
Slot plansPOST /slot-plans/{planId}/rejectionsRejectPlan200, the Rejected plan
Forward slotsGET /forward-slotsListForwardSlots200 {siteId, planId?, approvedAt?, assignments}
VelocityGET /sku-velocityListSkuVelocity200 {siteId, windowFrom, windowTo, items}
HealthGET /healthz, GET /readyz200 / 503 (Runbook)
Reports (cmd/slotting-reports)GET /reports/slot-plan-funnelreport.Reader.FunnelDays200 {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/freshnessreport.Reader.LastEventAt200 {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-plans takes {siteId?, lookbackDays?} and POST /slot-plans/{planId}/rejections takes {reason?}; an empty body is valid. Unknown fields, trailing data and bodies over 64 KiB are 400 malformed-request. JSON names are camelCase on REST and snake_case on the events.
  • Default site. siteId may be omitted on generate, /forward-slots and /sku-velocity when DEMAND_SITE_ID or DEFAULT_SITE_ID is configured; otherwise it is 400 invalid-site-id.
  • Idempotency-Key is required on every POST (/slot-plans, /slot-plans/{planId}/approvals, /slot-plans/{planId}/rejections): missing is 400 idempotency-key-required, not 1 to 128 printable ASCII characters is 400 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) with Idempotency-Replayed: true; the same key with another method, path or body is 409 idempotency-key-reused. A 5xx is never cached.
  • Collections answer {items, nextCursor} (limit 1 to 500, default 100, opaque cursor); an undeclared query parameter is 400 unknown-query-parameter. GET /forward-slots is 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 no ETag or If-Match; concurrent writers are told apart by 409 concurrent-modification and 409 approved-plan-conflict.
  • Paging. GET /slot-plans uses limit (1 to 500, default 100) and the opaque cursor (the previous page's nextCursor, base64url of the last plan id). Filters: siteId, state (Draft, Approved, Rejected, Superseded). GET /sku-velocity takes limit and windowDays (1 to 365, default 28).
  • Errors are RFC 7807 application/problem+json with type = https://errors.slotting-optimization.warehouse-systems.dev/<slug> from one table (problemCatalogue in internal/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-reused and internal-error; GET /readyz adds dependency-unavailable (readiness.go) and the reports binary invalid-report-range, invalid-report-granularity and report-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 TestNoAuthMiddlewareReintroduced fails CI if auth middleware returns.
  • CORS: GET and POST from CORS_ALLOWED_ORIGINS (default http://localhost:5173), headers Accept, Content-Type, Idempotency-Key.