API overview
cmd/api serves every route below (internal/adapters/inbound/http) on
HTTP_ADDR (default :8080); cmd/a2a serves the A2A agent. The contracts are
apis/openapi.yaml and apis/asyncapi.yaml. The router registers exactly the
thirteen API operations of the spec plus GET /healthz and GET /readyz, which
the spec does not list. There is no auth: the whole surface is unauthenticated.
See the Quickstart for example calls.
Interfaces
| Interface | Source of truth | Notes |
|---|---|---|
| REST | apis/openapi.yaml (OpenAPI 3.0.3, version 1.0.0) | The pages under Pricing API in this section are generated from the spec with npm run gen-api-docs; do not edit them by hand. The spec names http://localhost:8080; through Kong on the kind cluster the base path is /api/pricing. |
| Events | apis/asyncapi.yaml (AsyncAPI 3.0.0, version 1.0.0) | Summarised on the event catalogue; every field on Domain events. Five published types on retailnetwork.pricing.events and retailnetwork.pricing.analytics; two consumed from retailnetwork.offer-availability.events. |
| MCP | ADR 0009, MCP tools, internal/adapters/inbound/mcp | cmd/mcp serves stateless Streamable HTTP on /mcp and / (port 8090; through Kong /api/mcp/pricing once mcp.route.enabled is set). Two read-only tools, each authority L1: get_item_price (catalogItemId) and get_price_quote (quoteId), plus one resource and one prompt. Failures are isError results prefixed with the REST slug. No auth, by fleet decision. GET /healthz is {"status":"ok"}. |
| A2A | ADR 0007, internal/adapters/inbound/a2a | cmd/a2a serves JSON-RPC 2.0 on / and /a2a (port 8093; through Kong /api/a2a/pricing) and the Agent Card at /.well-known/agent-card.json. Two read-only skills, no write skill: item_price (catalogItemId) and quote_status (quoteId), each returning what the matching REST GET returns. The skill request is the first message part, {"skill": "<id>", "arguments": {...}}, strict about unknown fields. Domain rejections are answered in the message envelope as problems (types under https://errors.pricing.warehouse-systems.dev), never as JSON-RPC errors. No auth, by fleet decision. cmd/a2a GET /healthz is {"status":"ok"}. |
Endpoints
| Tag | Endpoint | Operation id | Success |
|---|---|---|---|
| ItemPrices | POST /item-prices | createItemPrice | 201, the item price at version 1 |
| ItemPrices | GET /item-prices | listItemPrices | 200 {items, nextCursor}, keyset-paged, ordered by catalogItemId, limit 1 to 500 (default 100) and cursor |
| ItemPrices | GET /item-prices/{catalogItemId} | getItemPrice | 200, state, list price, effective price now, sales, version |
| ItemPrices | PUT /item-prices/{catalogItemId}/list-price | setListPrice | 200, body listPrice and optional version guard; idempotent by method, no Idempotency-Key |
| ItemPrices | POST /item-prices/{catalogItemId}/withdrawals | withdrawPrice | 200, state WITHDRAWN |
| ItemPrices | POST /item-prices/{catalogItemId}/sales | scheduleSale | 201, the sale window with its saleId |
| ItemPrices | POST /item-prices/{catalogItemId}/sales/{saleId}/cancellations | cancelSale | 200, the item price |
| DeliveryCharges | POST /delivery-charge-schedules | publishChargeSchedule | 201, the schedule CURRENT |
| DeliveryCharges | GET /delivery-charge-schedules/current | getCurrentChargeSchedule | 200, or 404 not-found before the first publish |
| TaxTables | POST /tax-tables | publishTaxTable | 201, the table CURRENT |
| TaxTables | GET /tax-tables/current | getCurrentTaxTable | 200, or 404 not-found |
| PriceQuotes | POST /price-quotes | issuePriceQuote | 201, the quote ISSUED with expiresAt |
| PriceQuotes | GET /price-quotes/{quoteId} | getPriceQuote | 200, ISSUED or EXPIRED now |
| Health | GET /healthz, GET /readyz | none (not in the spec) | 200 {"status":"ok"} / 200 {"status":"ready"}; /readyz is 503 while draining or while Postgres or Kafka is unreachable. Neither is logged. |
| A2A | POST / and POST /a2a on cmd/a2a | none (not in the spec) | JSON-RPC 2.0 SendMessage, see above |
Conventions in the contract
- Money is
{amountMinor, currency}with integer minor units; the currency is alwaysPRICING_CURRENCY. Instants are RFC 3339 UTC. Idempotency-Key. Required on all sevenPOSTroutes (400 idempotency-key-requiredwhen absent,400 idempotency-key-invalidwhen not 1 to 128 printable ASCII characters);PUTis idempotent by method and takes none. The key is global, not per route. The first response below 500 for a key is stored for 24 hours; the same key with the same method, path and body replays it withIdempotency-Replayed: true; the same key with a different request is409 idempotency-key-reused. A 5xx is never stored. The key row commits in the same transaction as the aggregate change and the outbox rows (ADR 0008).- Optimistic concurrency. Aggregates carry a
versionthat grows with every change.PUT .../list-pricetakes an optionalversionthat must equal the stored one when above zero; a lost race is409 concurrent-updateand is safe to retry. - Versioned publications. A delivery charge schedule or tax table is published
with a
versionthat must exceed the current one (409 non-increasing-version); the previous one is superseded, never edited. - Paging.
GET /item-pricestakeslimitand the opaquecursor(thenextCursorof the previous page) and answers{items, nextCursor}; nonextCursormarks the last page. A badlimitis400 invalid-limit, a bad cursor400 invalid-cursor, any other query parameter400 unknown-query-parameter. It exists for projection bootstrap and rebuild, not for shopper requests. - Errors are RFC 9457
application/problem+jsonwithtype/problems/<slug>,title,status,detail,instance. The slugs, their causes and fixes are on Troubleshooting and the errors per use case on Use cases. - Limits. Request bodies are capped at 64 KiB; a NUL character in the path,
query or body is
400 malformed-request; ids are 1 to 64 characters ofA-Z a-z 0-9 . _ : -. - Auth: none. The fleet removed REST, MCP and A2A auth, and
TestNoAuthMiddlewareReintroducedfails CI if auth middleware returns underinternal/adapters/inbound.