Skip to main content

API overview

All interfaces are unauthenticated (fleet decision 2026-09-11; the fitness test TestNoAuthMiddlewareReintroduced fails CI if auth middleware comes back under internal/adapters/inbound). Access control is the cluster boundary.

Interfaces​

InterfaceServed bySource of truthNotes
REST (commands and queries)cmd/api, :8080apis/openapi.yaml (OpenAPI 3.0.3, version 1.0.0)The pages under REST are generated from the spec (npm run gen-api-docs); do not edit them by hand. Through Kong: /api/yard-management/.... The spec's server list still names a "local kind cluster through Kong" (http://localhost:8000/api/yard-management); kind is retired.
REST (reports)cmd/yard-reports, :8092 (and optionally cmd/api)the Reports tag of apis/openapi.yaml, ADR 0006, ADR 0011read-only, from the analytics schema; chart route /api/yard-management/reports. On cmd/api the same routes answer from the analytics database only when ANALYTICS_READER_DATABASE_URL is set, else with no rows
EventsKafka, produced by cmd/relayapis/asyncapi.yaml (AsyncAPI 3.0, version 1.0.0)Event catalogue; every field on Domain events
MCPcmd/mcp, :8090ADR 0007, internal/adapters/inbound/mcpStreamable HTTP at / and /mcp (through Kong /api/mcp/yard-management); eight read tools (L1) and six write tools (L3), a resource pair and the review_yard prompt. See MCP tools
A2Anonen/aThere is no cmd/a2a in this repository
Probesevery binary with HTTP/healthz, /readyzsee Runbook

Endpoints​

cmd/api registers exactly these routes (internal/adapters/inbound/http/server.go, NewRouter); there is no route in the code that the spec does not list. "Key" is whether Idempotency-Key is required.

TagEndpointOperation idKeySuccess
VisitsPOST /visitscheckInVisityes201, the check-in (visit, trailers, first moves), or a REJECTED visit under the REJECT seal policy
VisitsGET /visitslistVisits200 {items, nextCursor?}; filters siteId, state, tractorPlate
VisitsGET /visits/{visitId}getVisit200
VisitsPOST /visits/{visitId}/check-outscheckOutVisityes200, state CHECKED_OUT; body trailersOut
VisitsPOST /visit-rejectionsrejectAtGateyes201, a REJECTED visit
TrailersGET /trailerslistTrailers200; filters siteId, state, kind, locationCode, unitNumber, visitId
TrailersGET /trailers/{trailerId}getTrailer200
TrailersPOST /trailers/{trailerId}/door-work-startsstartDoorWorkyes200
TrailersPOST /trailers/{trailerId}/door-work-completionscompleteDoorWorkyes200; body loadState
TrailersPOST /trailers/{trailerId}/holdsplaceHoldyes200; body reason
TrailersPOST /trailers/{trailerId}/hold-releasesreleaseHoldyes200
TrailersPOST /trailers/{trailerId}/sealsrecordSealyes200
MovesPOST /movesrequestMoveyes201, the move
MovesGET /moveslistMoves200; filters siteId, state, trailerId, hostlerRef
MovesPOST /moves/claimsclaimNextMoveyes201, the claimed move; 404 no-claimable-move when none waits
MovesPOST /moves/{moveId}/completionscompleteMoveyes200
MovesPOST /moves/{moveId}/cancellationscancelMoveyes200
Yard checksPOST /yard-checksopenYardCheckyes201
Yard checksPOST /yard-checks/{yardCheckId}/observationsrecordObservationyes200
Yard checksPOST /yard-checks/{yardCheckId}/closurescloseYardCheckyes200, with the discrepancies
Yard boardGET /sites/{siteId}/yard-boardgetYardBoard200, the live spot and door map
Yard policyGET /sites/{siteId}/yard-policygetYardPolicy200 with ETag; the defaults (declared: false) when none was declared
Yard policyPUT /sites/{siteId}/yard-policydeclareYardPolicyyes200, honours If-Match
SweepsPOST /dwell-sweepssweepDwelloptional200, count of TrailerDwellExceeded raised; body {siteId?}
SweepsPOST /move-lease-sweepssweepMoveLeasesoptional200, count of leases returned to REQUESTED
ReportsGET /reports/yard-dwellgetYardDwellReport200; from, to, siteId?
ReportsGET /reports/door-utilisationgetDoorUtilisationReport200
ReportsGET /reports/hostler-productivitygetHostlerProductivityReport200
ReportsGET /reports/turn-timegetTurnTimeReport200 (KPI standard v1)
ReportsGET /reports/detention-exposuregetDetentionExposureReport200; thresholdMinutes (1 to 10080, default the two-hour norm)
ReportsGET /reports/exceptionsgetExceptionsReport200
ReportsGET /reports/freshnessgetReportsFreshness200, time of the last event folded in
HealthGET /healthz, GET /readyzgetHealthz, getReadyz200; /readyz is 503 while draining or a dependency is down

The write routes of this table are the REST side of the use cases on Use cases.

Conventions in the contract​

  • Idempotency. Every state-changing POST and PUT except the two sweeps requires Idempotency-Key (1 to 128 printable ASCII characters): 400 idempotency-key-required / idempotency-key-invalid; the same key with a different method, path or body is 409 idempotency-key-reused; an equal request replays the stored answer with Idempotency-Replayed: true. A 2xx commits with its key; a 4xx refusal is stored and replays as the same refusal (its partial writes are rolled back, except for 409 carrier-suspended: the REJECTED visit and its event commit with the stored answer, ADR 0016, so a replay records nothing new); a 5xx rolls back and is never stored. The sweeps accept the key but do not need it (internal/adapters/inbound/http/idempotency.go).
  • Versioning and conflicts. Aggregates carry a version. A write that loses a race is 409 concurrent-modification: any POST or PUT except the two sweeps, which skip the trailer or move that changed. The refusal is stored under its key like every 4xx, so re-read and retry with a new key. The yard policy has a weak ETag of its version: PUT honours If-Match; a stale value is 412 precondition-failed, an unparsable one 400 invalid-if-match.
  • Paging. List endpoints take limit (1 to 500, default 100) and the opaque cursor (the previous page's nextCursor); no nextCursor marks the last page. A parameter the operation does not declare is 400 unknown-query-parameter; a bad state is 400 invalid-state.
  • Reports take from and to as RFC 3339 instants (to after from, at most 92 days: 400 invalid-report-range). The body is {from, to, siteId, rows}; siteId is null for every site.
  • Errors are RFC 7807 application/problem+json with type = https://errors.yard-management.warehouse-systems.dev/<slug>, the slug being the kebab case of the domain error without Err. Status classes: 400 the request itself, 404 a missing resource, 409 a conflict with state or a lost race, 412 a stale If-Match, 422 a value or reference rule, 503 dependency-unavailable, 500 internal-error (the cause only in the log). Two more belong to no operation: 404 resource-not-found for a path that matches no route and 405 method-not-allowed (with an Allow header) for a method the path does not take. The catalogue is problemCatalogue in internal/adapters/inbound/http/errors.go; causes and fixes are on Troubleshooting. apis/openapi.yaml names every problem type the adapter can answer, and shows none it cannot: spec_problems_test.go in the adapter fails otherwise (TestTheSpecDeclaresEveryProblemTypeTheAdapterAnswers).
  • NUL guard. A U+0000 is a uniform client error: 404 resource-not-found in the path, 400 malformed-request-body in the query or body.
  • Events are CloudEvents 1.0 (structured JSON, application/cloudevents+json) on warehouse.yard-management.events and .analytics, key = aggregate root id; a breaking payload change is a new .v2 type, never a mutation.
  • Sites and locations are addressed by the facility-layout siteCode and location code; the API never calls a sibling context (the copies are event-fed, ADR 0003).