Skip to main content

API overview

:::info Implemented by cmd/api cmd/api serves every route below (internal/adapters/inbound/http), on HTTP_ADDR (default :8080). The contracts are apis/openapi.yaml and apis/asyncapi.yaml. There is no route in the code that the spec does not list: the router registers exactly the 14 API operations plus /healthz and /readyz. See the Quickstart for a walk through the seller API. :::

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. The spec names the server http://localhost:8000/api/seller-inbound, the gateway route in warehouse-infra (prefix stripped); cmd/api itself serves the routes at the root of :8080.
Eventsapis/asyncapi.yaml (AsyncAPI 3.0.0, version 1.0.0)Ten published and eleven consumed event types; summarised on the event catalogue, every field on Domain events.
MCPADR 0006, internal/adapters/inbound/mcpcmd/mcp serves Streamable HTTP on /mcp (port 8090; through Kong /api/mcp/seller-inbound). Six read-only tools, no write tool: get_inbound_plan, get_inbound_shipment, get_shipment_labels, get_seller_scorecard, get_placement_plan, list_placement_plans. See MCP tools. No auth, by fleet decision.
A2AADR 0009, internal/adapters/inbound/a2acmd/a2a serves JSON-RPC 2.0 on / and /a2a (port 8093; through Kong /api/a2a/seller-inbound), the Agent Card at /.well-known/agent-card.json. Two read-only skills, no write skill: seller_compliance (sellerId, optional window 7d or 30d) and inbound_status (exactly one of planId or shipmentId). No auth, by fleet decision.

Endpoints​

TagEndpointOperation idSuccess
SellersPOST /sellersonboardSeller201, the account, ACTIVE
SellersPOST /sellers/{sellerId}/suspensionssuspendSeller200, the account (a repeat is a no-op, no event)
SellersPOST /sellers/{sellerId}/reinstatementsreinstateSeller200, the account (a repeat is a no-op, no event)
SellersGET /sellers/{sellerId}/scorecardgetSellerScorecard200, the scorecard; window 7d or 30d (default 30d)
Inbound PlansPOST /inbound-planscreateInboundPlan201, the plan, DRAFT
Inbound PlansGET /inbound-plans/{planId}getInboundPlan200, the plan with its lines
Inbound PlansPOST /inbound-plans/{planId}/confirmationsconfirmInboundPlan200, CONFIRMED
Inbound PlansPOST /inbound-plans/{planId}/cancellationscancelInboundPlan200, CANCELLED
Inbound PlansPOST /inbound-plans/{planId}/shipmentscreateInboundShipment201, an empty DRAFT shipment
Inbound ShipmentsPOST /inbound-shipments/{shipmentId}/cartonsaddCarton201, the carton, ssccIssued, label data
Inbound ShipmentsPOST /inbound-shipments/{shipmentId}/labelslabelInboundShipment200, LABELLED
Inbound ShipmentsGET /inbound-shipments/{shipmentId}/labelsgetShipmentLabels200, one label per carton
Inbound ShipmentsPOST /inbound-shipments/{shipmentId}/dispatchesshipInboundShipment200, SHIPPED
Inbound ShipmentsGET /inbound-shipments/{shipmentId}getInboundShipment200, the shipment with its cartons
HealthGET /healthz, GET /readyznone (not in the spec)200; 503 while draining or when Postgres or Kafka is unreachable

The :verb actions share a chi pattern per resource (/sellers/{sellerAction}, /inbound-plans/{planAction}, /inbound-shipments/{shipmentAction}) and are dispatched on the suffix; an unknown suffix is 404 not-found (internal/adapters/inbound/http/server.go).

Conventions in the contract​

  • Eaches. Every quantity is qtyEaches; a bare quantity never changes meaning. GTINs are 14 digits (shorter forms are normalised), SSCCs 18, both with a GS1 mod-10 check digit.
  • Idempotency-Key. Required on every POST (1 to 128 characters), implemented by internal/adapters/inbound/http/idempotency.go. The key is global and the request fingerprint is method + path + SHA-256 of the body. The same fingerprint replays the stored answer for 24 h (a 4xx replays too) with the response header Idempotency-Replayed: true; the same key on a different method, path or body is 409 idempotency-key-reused; a missing key is 400 idempotency-key-required and a key that is not 1 to 128 printable ASCII characters is 400 idempotency-key-invalid. A 5xx is never stored. See ADR 0010.
  • Errors are RFC 9457 application/problem+json with type = the bare slug (not a URL), title, status, detail and instance. The slugs are not-found, illegal-transition, concurrent-update, validation-failed, invalid-window, invalid-cover-days, seller-exists, seller-suspended, node-cannot-receive, sscc-not-unique, invalid-sscc, case-pack-not-uniform, case-qty-mismatches-gtin, carton-overweight, carton-oversize, carton-contents-mismatch-plan, shipment-not-labelled, idempotency-key-required, idempotency-key-invalid, idempotency-key-reused, dependency-unavailable and internal-error. The full status table is on Troubleshooting.
  • Optimistic concurrency. Aggregates carry a version that is not exposed on the wire; a lost race is 409 concurrent-update, which the client resolves by re-fetching and retrying.
  • Omitted rates. In the scorecard, a rate whose denominator is zero is omitted, never 0 or NaN.
  • Request bodies are strict. Unknown fields, trailing data and an empty body are 422 validation-failed; a body is limited to 4 MiB; a NUL character anywhere is a uniform client error.
  • Auth: none. The fleet reverted REST and MCP auth, and TestNoAuthMiddlewareReintroduced fails CI if auth middleware returns under internal/adapters/inbound.
  • CloudEvents. Every Kafka message is CloudEvents 1.0 in structured mode with content-type: application/cloudevents+json; charset=UTF-8; the Kafka key is the subject.

A2A skill requests​

A2A is the delegation channel (ADR 0009); facts still travel only as CloudEvents on Kafka. A client sends a message whose first part is a data part (or a text part holding the same JSON):

{"skill": "seller_compliance", "arguments": {"sellerId": "seller-77", "window": "7d"}}
{"skill": "inbound_status", "arguments": {"shipmentId": "shp-0f3a91"}}

The reply is one agent message carrying a data part {"skill", "data" | "problem"} and a one-line text summary. Domain and request problems are answered inside the envelope (problem with type, title, detail, status), never as a JSON-RPC error: malformed-skill-request, unknown-skill, invalid-argument (all 400), invalid-window (400), not-found (404), validation-failed (422) and internal-error (500). Unknown request fields are rejected rather than ignored. The agent is message-only: no Task lifecycle, no streaming, and the Agent Card declares no security scheme.

Source: internal/adapters/inbound/a2a/{server,skills,mapping}.go, cmd/a2a/router.go.