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 (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. :::

InterfaceSource of truthNotes
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.
Eventsapis/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.
MCPADR 0006, internal/adapters/inbound/mcpcmd/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.
A2AADR 0009, internal/adapters/inbound/a2acmd/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.

TagEndpointOperation idSuccess
VendorsPOST /vendorsonboardVendor201 with the account; 200 with the unchanged account when the vendorId exists
VendorsGET /vendors/{vendorId}getVendor200
VendorsPOST /vendors/{vendorId}/suspensions, POST /vendors/{vendorId}/reinstatementssuspendVendor, reinstateVendor200 with the account
Purchase OrdersGET /vendor/purchase-orderspollPurchaseOrders200, a page {items, nextCursor}
Purchase OrdersGET /vendor/purchase-orders/{poNumber}getPurchaseOrder200
AcknowledgementsPOST /vendor/acknowledgementssubmitAcknowledgement202 {transactionId}
InventoryPOST /vendor/inventorysubmitInventory202 {transactionId}
NodesGET /vendor/nodes, GET /vendor/nodes/{nodeId}listVendorNodes, getNode200
NodesPOST /vendor/nodesregisterVendorNode202 {transactionId}; the new nodeId appears on the processed transaction
NodesPUT /vendor/nodes/{nodeId}/profiledeclareNodeProfile202 {transactionId}
NodesGET /vendor/nodes/{nodeId}/scorecardgetScorecard200; 503 when node-performance does not answer
Shipping LabelsPOST /vendor/shipping-labelsrequestLabel200 with the labels (the one synchronous write); 503 or 502 on a neighbour failure
ShipmentPOST /vendor/shipment-confirmationssubmitShipmentConfirmation202 {transactionId}
InboundGET /vendor/inbound-shipments, GET /vendor/inbound-shipments/{shipmentId}pollInboundShipments, getInboundShipment200
InboundPOST /vendor/inbound-receiptssubmitInboundReceipt202 {transactionId}
TransactionsGET /vendor/transactions/{transactionId}getTransaction200 with status PROCESSING, SUCCESS or FAILURE
HealthGET /healthz, GET /readyznot in the spec200; /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. vendorId names 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. 202 with a transactionId. The write takes effect only when GET /vendor/transactions/{transactionId} reports SUCCESS. Processing waits at least TX_PROCESSING_DELAY, and a share TX_FAILURE_RATE of transactions fails on purpose with ErrSimulatedFailure; a neighbour refusal fails a transaction with the neighbour's Err... code, except a refusal the neighbour releases for a retry (ADR 0016), which keeps the transaction PROCESSING and is retried before it fails with that same code. A failed acknowledgement returns the order to ISSUED (so the vendor may try again inside the window) and a failed shipment confirmation returns it to ACCEPTED.
  • 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 same transactionId) with the header Idempotency-Replayed: true; the same key with a different method, path or body is 409 idempotency-key-reused; a missing key is 400 idempotency-key-required and a malformed one 400 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-update and 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 opaque cursor (the nextCursor of the previous page); no nextCursor marks the last page. Every list answers {items, nextCursor}, and a query parameter a list does not declare (such as the retired nextToken) is 400 unknown-query-parameter. Polling is oldest-first, and with PO_REDELIVERY_RATE a page may repeat its first order, so consumers must be idempotent on poNumber.
  • Rate limit. 429 rate-limited with Retry-After (whole seconds, at least 1) when the per-process token bucket is empty.
  • No PII. A label is labelRef, trackingNumber and carrier; no response carries a ship-to address, name or phone.
  • Errors are RFC 9457 application/problem+json, type ending 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); and internal-error (500). The map is internal/adapters/inbound/http/errors.go; remedies are on Troubleshooting.
  • Ordering of checks on an acknowledgement: order state, then the window (now equal to ackBy is still inside), then completeness (every line once, at its ordered quantity), then the decision (ACCEPT carries no reasonCode; REJECT needs OUT_OF_STOCK, UNKNOWN_LISTING, CANNOT_MEET_SHIP_BY or DISCONTINUED).
  • Auth: none. The fleet reverted REST, MCP and A2A auth on 2026-09-11, and TestNoAuthMiddlewareReintroduced fails CI if auth middleware returns under internal/adapters/inbound.