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 (the Vendor API) and apis/asyncapi.yaml,
pinned by ADR 0002,
ADR 0004 and
ADR 0005. The router
registers the 19 operations of the spec plus /healthz and /readyz. Nothing here is
authenticated.
:::
| Interface | Source of truth | Notes |
|---|---|---|
| REST (Vendor API) | 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. Server named in the spec: http://localhost:8000/api/retail-network/vendor-connectivity (kind cluster through Kong); direct to the pod it is http://localhost:8080. |
| Events | apis/asyncapi.yaml (AsyncAPI 3.0.0, version 1.0.0) | Eleven published and fourteen consumed types, summarised on the event catalogue; every payload field on Domain events. |
| MCP | ADR 0006, internal/adapters/inbound/mcp | cmd/mcp serves Streamable HTTP on /mcp and / (port 8090; through Kong /api/mcp/vendor-connectivity). Nine read-only tools, no write tool; see MCP tools. |
| A2A | ADR 0009, internal/adapters/inbound/a2a | cmd/a2a serves JSON-RPC 2.0 on / and /a2a (port 8093; through Kong /api/a2a/vendor-connectivity) and the Agent Card at /.well-known/agent-card.json. A message-only agent with two read-only skills, no write skill and no streaming: get_purchase_order (vendorId, poNumber) and get_node_scorecard (vendorId, nodeId), named like the MCP tools. A skill request is the first message part, a data object {"skill": "...", "arguments": {...}}; unknown fields are refused and a problem is answered in the reply envelope, not as a JSON-RPC error. |
Endpoints
All /vendor/* routes sit behind the RATE_LIMIT_RPS limiter; every POST and PUT takes an
Idempotency-Key. Reads take vendorId as a required query parameter; writes carry it in the
body.
| Tag | Endpoint | Operation id | Success |
|---|---|---|---|
| Vendors | POST /vendors | onboardVendor | 201 with the account; 200 with the unchanged account when the vendorId exists |
| Vendors | GET /vendors/{vendorId} | getVendor | 200 |
| Vendors | POST /vendors/{vendorId}/suspensions, POST /vendors/{vendorId}/reinstatements | suspendVendor, reinstateVendor | 200 with the account |
| Purchase Orders | GET /vendor/purchase-orders | pollPurchaseOrders | 200, a page {items, nextCursor} |
| Purchase Orders | GET /vendor/purchase-orders/{poNumber} | getPurchaseOrder | 200 |
| Acknowledgements | POST /vendor/acknowledgements | submitAcknowledgement | 202 {transactionId} |
| Inventory | POST /vendor/inventory | submitInventory | 202 {transactionId} |
| Nodes | GET /vendor/nodes, GET /vendor/nodes/{nodeId} | listVendorNodes, getNode | 200 |
| Nodes | POST /vendor/nodes | registerVendorNode | 202 {transactionId}; the new nodeId appears on the processed transaction |
| Nodes | PUT /vendor/nodes/{nodeId}/profile | declareNodeProfile | 202 {transactionId} |
| Nodes | GET /vendor/nodes/{nodeId}/scorecard | getScorecard | 200; 503 when node-performance does not answer |
| Shipping Labels | POST /vendor/shipping-labels | requestLabel | 200 with the labels (the one synchronous write); 503 or 502 on a neighbour failure |
| Shipment | POST /vendor/shipment-confirmations | submitShipmentConfirmation | 202 {transactionId} |
| Inbound | GET /vendor/inbound-shipments, GET /vendor/inbound-shipments/{shipmentId} | pollInboundShipments, getInboundShipment | 200 |
| Inbound | POST /vendor/inbound-receipts | submitInboundReceipt | 202 {transactionId} |
| Transactions | GET /vendor/transactions/{transactionId} | getTransaction | 200 with status PROCESSING, SUCCESS or FAILURE |
| Health | GET /healthz, GET /readyz | not in the spec | 200; /readyz is 503 while draining or when Postgres or Kafka is down (see the Runbook) |
/healthz and /readyz are hand-written routes: they are in internal/adapters/inbound/http/server.go
but not in apis/openapi.yaml. The :suspend and :reinstate actions share one chi pattern
(/vendors/{vendorAction}) and are dispatched on the suffix; any other suffix is 404 not-found.
Conventions in the contract
- Identity without authentication.
vendorIdnames the caller in every request. Ownership of the addressed node, order or shipment is checked against it (node-not-owned-by-vendor,404), so one vendor cannot probe another. This is a consistency check, not security. - Asynchronous writes.
202with atransactionId. The write takes effect only whenGET /vendor/transactions/{transactionId}reportsSUCCESS. Processing waits at leastTX_PROCESSING_DELAY, and a shareTX_FAILURE_RATEof transactions fails on purpose withErrSimulatedFailure; a neighbour refusal fails a transaction with the neighbour'sErr...code, except a refusal the neighbour releases for a retry (ADR 0016), which keeps the transactionPROCESSINGand is retried before it fails with that same code. A failed acknowledgement returns the order toISSUED(so the vendor may try again inside the window) and a failed shipment confirmation returns it toACCEPTED. - Idempotency.
Idempotency-Key(1 to 128 printable ASCII characters) is global, not per route, and every POST is behind it. A 2xx and a refusal that is final for the request (partial-acknowledgement,ack-window-closed) are stored for 24 h and replayed for the same key, method, path and body (for an asynchronous write, the sametransactionId) with the headerIdempotency-Replayed: true; the same key with a different method, path or body is409 idempotency-key-reused; a missing key is400 idempotency-key-requiredand a malformed one400 idempotency-key-invalid. A refusal that can pass on a retry is NOT stored and its key is released, so the same request under the same key executes again and a different body under it is a new request:validation-failed,ack-window-out-of-range,not-found,node-not-owned-by-vendor,vendor-suspended,already-acknowledged,label-before-acceptance,confirm-without-label,illegal-transition,concurrent-updateand every 5xx (upstream-unavailable,upstream-refused). Retry those under the same key once the state changed (ADR 0015). - Paging. Polls take
nodeId,createdAfter(RFC 3339),limit(default 100, maximum 500) and the opaquecursor(thenextCursorof the previous page); nonextCursormarks the last page. Every list answers{items, nextCursor}, and a query parameter a list does not declare (such as the retirednextToken) is400 unknown-query-parameter. Polling is oldest-first, and withPO_REDELIVERY_RATEa page may repeat its first order, so consumers must be idempotent onpoNumber. - Rate limit.
429 rate-limitedwithRetry-After(whole seconds, at least 1) when the per-process token bucket is empty. - No PII. A label is
labelRef,trackingNumberandcarrier; no response carries a ship-to address, name or phone. - Errors are RFC 9457
application/problem+json,typeending in the slug. Shared slugs:not-found(404),illegal-transition,concurrent-update(409),validation-failed(422). One slug per domain error:partial-acknowledgement,ack-window-out-of-range(422);node-not-owned-by-vendor(404);vendor-suspended,already-acknowledged,ack-window-closed,label-before-acceptance,confirm-without-label,cancel-after-acknowledgement,submission-already-processed,submission-not-due(409);rate-limited(429);idempotency-key-reused(409);idempotency-key-required,idempotency-key-invalid,invalid-limit,invalid-cursor,unknown-query-parameter(400);upstream-unavailable(503);upstream-refused(502); andinternal-error(500). The map isinternal/adapters/inbound/http/errors.go; remedies are on Troubleshooting. - Ordering of checks on an acknowledgement: order state, then the window (
nowequal toackByis still inside), then completeness (every line once, at its ordered quantity), then the decision (ACCEPTcarries noreasonCode;REJECTneedsOUT_OF_STOCK,UNKNOWN_LISTING,CANNOT_MEET_SHIP_BYorDISCONTINUED). - Auth: none. The fleet reverted REST, MCP and A2A auth on 2026-09-11, and
TestNoAuthMiddlewareReintroducedfails CI if auth middleware returns underinternal/adapters/inbound.