Skip to main content

API overview

InterfaceSource of truthNotes
RESTapis/openapi.yaml (OpenAPI 3.0.3, version 1.0.0)Pages under REST are generated from the spec; do not edit them by hand. Servers: http://localhost:8080 (local) and http://localhost:8000/api/product-master (kind cluster through Kong). The Reports paths name their own server, http://localhost:8092 (cmd/product-reports).
MCPinternal/adapters/inbound/mcp (registry golden internal/adapters/inbound/mcp/testdata/tool_registry.golden.json)Read-only tools get_product, list_products, get_product_classification, get_physical_profile, resolve_gtin, get_pack_levels and the two write tools declare_pack_level, retire_pack_level (ADR 0011 amends ADR 0005 for those two) on cmd/mcp (:8090, / and /mcp); ADR 0005.
Eventsapis/asyncapi.yaml (AsyncAPI 2.6.0, version 1.1.0)Summarised on the event catalogue.

Conventions​

  • Every write is idempotent. Repeating a request with the same body changes nothing, bumps no version and publishes no event. Every write is a PUT, except POST /products/{sku}/pack-levels/{level}/retirements (ADR 0011), which records the act as a noun and is idempotent too: retiring a retired level changes nothing. It sits behind the fleet Idempotency-Key middleware (ADR 0013): the header is required (400 idempotency-key-required / idempotency-key-invalid), a replay carries Idempotency-Replayed: true, and the same key with a different request is 409 idempotency-key-reused.
  • Collections are keyset-paged. GET /products and GET /products/{sku}/pack-levels take limit (1-500, default 100) and cursor and answer {items,nextCursor}; 400 invalid-limit, invalid-cursor and unknown-query-parameter are the paging problems.
  • Register first. PUT /products/{sku} must succeed before the classification or dimension endpoints accept the SKU; otherwise they answer 404 product-not-found.
  • Errors are RFC 7807 application/problem+json with type = https://errors.product-master.warehouse-systems.dev/<slug>. The slugs come from one table (problemCatalogue in internal/adapters/inbound/http/errors.go): malformed-request, invalid-sku, invalid-description, no-handling-tags, unknown-handling-tag, duplicate-handling-tag, temperature-class-required, temperature-class-not-applicable, unknown-temperature-class, invalid-dot-hazard-class, dot-hazard-class-not-applicable, invalid-dimension, invalid-weight, measured-at-in-future, product-not-found, product-classification-not-found, stale-measurement, concurrent-modification and internal-error, plus the packaging slugs (ADR 0011): invalid-gtin, variable-measure-unsupported, invalid-pack-level, invalid-pack-quantity, invalid-reason, gtin-not-found, pack-level-not-found (404), gtin-already-assigned, pack-quantity-immutable, pack-level-order and pack-dimensions-below-contents (409).
  • Request bodies reject unknown fields; JSON field names are camelCase on REST (handlingTags, lengthMm, measuredAt) and snake_case on the events.
  • Auth: none. The fleet reverted REST and MCP auth on 2026-09-11, and TestNoAuthMiddlewareReintroduced fails CI if auth middleware returns.
  • CORS: GET and PUT from CORS_ALLOWED_ORIGINS (default http://localhost:5173).

Endpoint groups (tags)​

TagEndpoints
ProductsGET /products (cursor pagination, limit 1..500 default 100, filters handlingTag and classified), PUT /products/{sku} (201 registered / 200 existing), GET /products/{sku}
ClassificationPUT /products/{sku}/classification (201 first / 200 replaced or unchanged), GET /products/{sku}/classification
Physical profilePUT /products/{sku}/dimensions/declared, PUT /products/{sku}/dimensions/measured (409 stale-measurement), GET /products/{sku}/physical-profile
HealthGET /healthz (liveness), GET /readyz (503 once shutdown has started)
ReportsGET /reports/master-data-quality, GET /reports/freshness, served by cmd/product-reports (:8092), not by cmd/api (ADR 0006)

cmd/api also serves GET /metrics (Prometheus, Go runtime and process collectors); it is not in the spec.

:::caution Known issue: reports through Kong In the kind cluster, http://localhost:8000/api/product-master/reports/* returns 404: warehouse-infra's reports route is shadowed by the /api/product-master route, so the request reaches cmd/api, which has no /reports/* path. The reports service works in-cluster (Service product-master-reports); use kubectl -n warehouse-systems port-forward svc/product-master-reports 8092:80 until the route is fixed in warehouse-infra. :::

Regenerating the REST reference​

The reference is generated by docusaurus-plugin-openapi-docs into docs/docs/api-reference/rest and committed. After changing apis/openapi.yaml, run inside docs/:

npm run clean-api-docs product-master
npm run gen-api-docs product-master

The docs-api-drift CI job repeats this and fails if the committed output differs. Always run the clean step first: the generator skips files it believes are unchanged.