Skip to main content

API Reference

This service exposes three contracts, all of which live in apis/ in the repository and are linted by Spectral on every push:

ContractFileRendered here
Synchronous RESTapis/openapi.yaml (OpenAPI 3.0.3)REST API — generated directly from the spec
Reports REST (cmd/fulfillment-reports)apis/openapi-reports.yaml (OpenAPI 3.0.3)Reports API — generated directly from the spec (ADR-0043)
Asynchronous eventsapis/asyncapi.yaml (AsyncAPI 2.6.0)Events — hand-authored from the spec

The REST pages under REST API and Reports API are generated from the real spec files by docusaurus-plugin-openapi-docs (npm run clean-api-docs:all && npm run gen-api-docs:all) and committed; npm run build does not regenerate them. They are not transcribed by hand, and the docs-api-drift CI job regenerates them on every push and pull request and fails on any diff, so they cannot silently drift from the contract.

Endpoint coverage: 19 / 19​

Cross-checked against internal/adapters/inbound/http/router.go:

MethodPathUse caseIn openapi.yaml?
POST/tasksCreateTask (every POST requires an Idempotency-Key header when Postgres is wired, ADR-0028)Yes
GET/tasks?orderRef=&limit=&cursor=GetTasksByOrderRef (paged, ADR-0013)Yes
POST/stationsRegisterStation (optional locationCode, ADR-0024)Yes
POST/stations/{stationId}/task-claimsClaimNextYes
POST/stations/{stationId}/check-insCheckInStationYes
POST/stations/{stationId}/check-outsCheckOutStationYes
POST/tasks/{id}/lease-renewalsRenewLeaseYes
POST/tasks/{id}/completionsCompleteTaskYes
POST/tasks/{id}/package-sealsSealPackageYes
GET/packages/{id}GetPackage (ADR-0033)Yes
GET/packages?orderRef=&limit=&cursor=GetPackagesByOrderRef (paged, ADR-0033)Yes
POST/packages/{id}/slam-runsRunSlam (204 in both outcomes)Yes
GET/queues/{taskType}/depthGetQueueDepthYes
GET/capacity/{capability}GetInstalledCapacity (ADR-0018)Yes
POST/task-lease-expirationsExpireLeasesYes
POST/cpt-miss-sweepsSweepCPTMisses (ADR-0025)Yes
POST/rebin/arrivalsArriveAtRebin (ADR-0016)Yes
GET/healthz(liveness)Yes
GET/readyz(readiness, ADR-0029)Yes

Every route on the router is declared in the spec and every spec operation is a real route. That two-way match is enforced by internal/adapters/inbound/http/openapi_routes_test.go (it walks the chi router and diffs it against paths: in apis/openapi.yaml), which covers the one kind of drift the PR-time docs-api-drift check cannot see: a live route the spec omits. POST /rebin/arrivals was that kind of drift until it was added to the spec under its own Rebin tag.

The read-only analytics endpoints (GET /reports/throughput, GET /reports/throughput/freshness and that process's GET /healthz) are served by the separate cmd/fulfillment-reports process and specified in apis/openapi-reports.yaml (gap fix D18, ADR-0043). Schemathesis cannot boot that binary without an analytical database, so internal/adapters/inbound/http/reports_contract_test.go holds the spec and NewReportsRouter to each other: TestReportsSpecAndRouterAgree (routes, both directions) and TestReportsResponsesConformToSpec (every documented status, media type and property). See also Throughput report.

No route or MCP tool is authenticated: ADR-0022 removed the static-bearer layer and supersedes ADR-0021.

Conventions​

Richardson Maturity Level 2, deliberately not Level 3. Resource nouns, correct verbs, correct status codes, Location headers on creation — but no HATEOAS. Clients are expected to know the URL structure rather than discover it from response links, and the spec says so explicitly.

Actions are POSTs that create a noun (ADR-0060). task-claims, lease-renewals, completions, package-seals, slam-runs and task-lease-expirations are state transitions with side effects, not resource replacements — so they are POST creating the record of the act, not PUT on a field and never a verb in the path. POST /stations/{stationId}/task-claims in particular reads correctly as "this station asks for its next task," which is the pull semantics made visible in the URL.

Domain structs never leak. Every request and response body is a DTO defined in internal/adapters/inbound/http/dto.go. Aggregates are unexported internally and are mapped explicitly on the way out.

Validation happens twice, for different reasons. DTO-level validation catches malformed requests (missing stationId, empty type) and returns 400. Domain-level invariants (ErrNoScannedContents, ErrCapabilityMismatch) return 422 — the request was well-formed, the operation was not allowed. sealPackageRequest.validate() shows the line clearly: it checks stationId is present but deliberately does not check that contents is non-empty, because "you cannot seal an empty carton" is a domain rule, not a syntax error.

Errors: RFC 7807 application/problem+json​

Every error response — without exception — is an RFC 7807 problem document:

{
"type": "https://errors.fulfillment-execution.warehouse-systems.dev/task-already-claimed",
"title": "Task already claimed by another station",
"status": 409,
"detail": "task: already claimed",
"instance": "/tasks/task-8a1f/completions"
}

type is a stable identifier a client can branch on — a URI, but not a fetchable document (RFC 7807 §3.1 explicitly permits this). title is the category-level human summary; detail is the specific error text; instance is the request path that produced it. On bare collection-create endpoints (POST /tasks, POST /stations) instance is omitted, because the path identifies no specific resource.

Rationale is in ADR-0005.

Status-code mapping​

The mapping lives in internal/adapters/inbound/http/errors.go and is exhaustive over the typed error set.

StatusMeaning hereErrors mapped
400Malformed or incomplete request bodyinvalid JSON, missing required DTO field (invalid-request)
404Referenced aggregate does not existErrTaskNotFound, ErrStationNotFound, ErrPackageNotFound
409Well-formed request, but the aggregate's state forbids itErrAlreadyClaimed, ErrAlreadyCompleted, ErrNotClaimed, ErrNotOwner, ErrOccupied, ErrNotOccupied, ErrAlreadySealed, ErrAlreadyProcessed, ErrNotSealed, ErrPackageSegregationViolation, ErrNoClaimableTask
422Well-formed request, but the content violates a domain ruleErrCapabilityMismatch (task and station), ErrNoScannedContents, consolidation.ErrUnknownLine, ErrWrongTaskType, ErrStationLocationNotWorkCenter
500Anything unmappedfallback (internal-error)

The 409 versus 422 split is the one worth internalising: 409 means "try again later or against different state" — the task is claimed now, the lease may lapse and free it. 422 means "this will never work as asked" — the station lacks hazmat certification and retrying changes nothing.

ErrNoClaimableTask is mapped to 409 rather than 404 on purpose: the pool is a valid resource that is momentarily empty of work this station can do, not a missing resource. An idle station polls again; it does not treat the answer as a permanent failure.

Every problem type​

SlugStatusTitle
invalid-request400The request is malformed or missing a required field
idempotency-key-required400Idempotency-Key header is required (every POST, with Postgres; ADR-0028, ADR-0060)
idempotency-key-invalid400Idempotency-Key is not 1-128 printable ASCII characters
invalid-limit400limit is not an integer 1-500 (collections, ADR-0060)
invalid-cursor400cursor does not decode (collections)
unknown-query-parameter400A query parameter the collection does not declare (e.g. the retired after, offset)
malformed-request-body400The request body could not be read (idempotency middleware)
task-not-found404Task not found
station-not-found404Station not found
package-not-found404Package not found
task-already-claimed409Task already claimed by another station
task-already-completed409Task already completed
task-not-claimed409Task is not currently claimed
task-not-owner409Station does not own the active claim on this task
station-occupied409Station is already occupied
station-not-occupied409Station is not occupied
package-already-sealed409Package already sealed
package-already-processed409Package SLAM already processed
package-not-sealed409Package must be sealed before SLAM
package-segregation-violation409Scanned item's DOT hazard class is incompatible with an already-scanned item
no-claimable-task409No claimable task for station capabilities
task-capability-mismatch422Station capabilities do not match task requirements
station-capability-mismatch422Capabilities do not match
package-no-scanned-contents422Cannot seal a package without scanned contents
rebin-unknown-line422Line is not part of this order's required consolidation set
wrong-task-type422Wrong task type for this operation
station-location-not-workcenter422Station's locationCode does not resolve to a facility-layout WorkCenter
idempotency-key-reused409Idempotency-Key was already used with a different method, path or body
internal-error500Internal server error

All types share the base URI https://errors.fulfillment-execution.warehouse-systems.dev/.

Not on this API​

  • Work release. wes-work-planning decides what to release; it arrives over Kafka, not HTTP.
  • Inventory reservations. inventory-storage owns stock truth; this service does not call it. Per-SKU hazard classification comes from a local copy of product-master's ProductClassified events (ADR-0039).
  • WCS / equipment commands. A separate command channel, not built.