{"openapi":"3.1.0","info":{"title":"Purchasing Manager API","version":"0.1.0","description":"Event-sourced purchase-order (receiving) service. Owns the PO lifecycle, expected vs confirmed costs, landed costs, and unit/lot identity capture at receipt (it is the serial-uniqueness authority). Quantity movements are commanded through the inventory service, which remains the platform's source of truth for stock levels."},"paths":{"/supplier-prices":{"get":{"tags":["pos"],"operationId":"pos.supplierPrices","parameters":[{"name":"supplierId","in":"query","schema":{"$ref":"#/components/schemas/CmpId"},"required":false,"example":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b"},{"name":"sku","in":"query","schema":{"type":"string"},"required":false},{"name":"limit","in":"query","schema":{"type":"string"},"required":false},{"name":"offset","in":"query","schema":{"type":"string"},"required":false}],"security":[{"bearer":[]}],"responses":{"200":{"description":"SupplierPricePage","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SupplierPricePageEncoded"},"examples":{"contract":{"summary":"pos.supplierPrices","value":{"items":[{"supplierId":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","sku":"WIDGET-BLUE","unitCostCents":1250,"currency":"AUD","supplierSku":"NW-40-BLU","updatedAt":"2026-09-22T01:10:00.000Z"}],"total":1,"limit":100,"offset":0}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"What suppliers charge: one row per (supplier, SKU) — unit cost, currency and the supplier's own code — by supplier then SKU. `supplierId` narrows to one supplier, `sku` to named SKUs (comma-separated). `limit` is 1–500, 100 when omitted.\n\nRequires `purchasing:read`.","x-mcp-tool":{"name":"purchasing_list_supplier_prices","title":"Purchasing: List supplier prices","toolset":"purchasing","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["purchasing:read"],"x-example-source":{"origin":"contract"}}},"/supplier-prices/{supplierId}/{sku}":{"put":{"tags":["pos"],"operationId":"pos.setSupplierPrice","parameters":[{"name":"supplierId","in":"path","schema":{"$ref":"#/components/schemas/CmpId"},"required":true,"example":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b"},{"name":"sku","in":"path","schema":{"$ref":"#/components/schemas/Sku"},"required":true,"example":"WIDGET-BLUE"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"SupplierPrice","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SupplierPriceEncoded"},"examples":{"contract":{"summary":"pos.setSupplierPrice","value":{"supplierId":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","sku":"WIDGET-BLUE","unitCostCents":1250,"currency":"AUD","supplierSku":"NW-40-BLU","updatedAt":"2026-09-22T01:10:00.000Z"}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Set what a supplier (a CRM company) charges for a SKU: the unit cost in a currency, and the supplier's own code for it. A purchase-order line sent without a cost takes it. Replace semantics: what is sent is the row. Appends `purchasing.supplier-price-set`. Idempotent by content: a retry that says what the row already says appends nothing.\n\nRequires `purchasing:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SetSupplierPriceEncoded"},"example":{"unitCostCents":1250,"currency":"AUD","supplierSku":"NW-40-BLU"}}},"required":true},"x-mcp-tool":{"name":"purchasing_set_supplier_price","title":"Purchasing: Set supplier price","toolset":"purchasing","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["purchasing:write"],"x-example-source":{"origin":"contract"}},"delete":{"tags":["pos"],"operationId":"pos.removeSupplierPrice","parameters":[{"name":"supplierId","in":"path","schema":{"$ref":"#/components/schemas/CmpId"},"required":true,"example":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b"},{"name":"sku","in":"path","schema":{"$ref":"#/components/schemas/Sku"},"required":true,"example":"WIDGET-RED"}],"security":[{"bearer":[]}],"responses":{"204":{"description":"<No Content>"},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Forget what a supplier charges for a SKU. Appends `purchasing.supplier-price-removed`. Idempotent by state: a price already gone is acknowledged and appends nothing.\n\nRequires `purchasing:write`.","x-mcp-tool":{"name":"purchasing_remove_supplier_price","title":"Purchasing: Remove supplier price","toolset":"purchasing","readOnlyHint":false,"destructiveHint":true,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["purchasing:write"],"x-example-source":{"origin":"contract"}}},"/pos":{"get":{"tags":["pos"],"operationId":"pos.list","parameters":[{"name":"q","in":"query","schema":{"type":"string","maxLength":120},"required":false},{"name":"status","in":"query","schema":{"type":"string"},"required":false,"example":"authorised,partially-received"},{"name":"supplierId","in":"query","schema":{"$ref":"#/components/schemas/CmpId"},"required":false,"example":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b"},{"name":"owing","in":"query","schema":{"$ref":"#/components/schemas/BooleanString"},"required":false},{"name":"ref","in":"query","schema":{"type":"string","maxLength":120},"required":false},{"name":"ids","in":"query","schema":{"type":"string"},"required":false},{"name":"sort","in":"query","schema":{"$ref":"#/components/schemas/PoSortKey"},"required":false},{"name":"order","in":"query","schema":{"$ref":"#/components/schemas/SortOrder"},"required":false},{"name":"limit","in":"query","schema":{"type":"string"},"required":false,"example":"50"},{"name":"offset","in":"query","schema":{"type":"string"},"required":false}],"security":[{"bearer":[]}],"responses":{"200":{"description":"PurchaseOrderPage","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PurchaseOrderPageEncoded"},"examples":{"contract":{"summary":"pos.list","value":{"items":[{"id":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d","number":"PO-00001","serial":1,"reference":"PO-WIDGET-BLUE","supplier":"Northwind Components","supplierId":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","currency":"AUD","status":"authorised","lines":[{"sku":"WIDGET-BLUE","ordered":40,"received":0,"cancelled":0,"unitCostCents":1250}],"landedCosts":[],"payables":[],"payments":[],"revision":0,"createdAt":"2026-09-22T01:15:00.000Z","updatedAt":"2026-09-23T04:00:00.000Z","expectedOn":"2026-10-01"}],"total":1,"limit":50,"offset":0}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"A page of purchase orders from the current read model: `q` narrows by reference or supplier (case-insensitive substring), `status` to a comma-separated set of statuses, `supplierId` to the orders placed with one CRM company (`GET /pos?supplierId=cmp_…`, an exact match), `ids` to exactly those `po_` ids (comma-separated, up to 200 — how a screen holding ids shows their numbers), `sort`/`order` pick the column and direction (default: newest first). `total` counts every match regardless of the page; `limit` defaults to 100 and is capped at 1000 (an over-cap request is clamped, not honoured); page with `offset`.\n\nRequires `purchasing:read` or `receiving:read`.","x-mcp-tool":{"name":"purchasing_list_pos","title":"Purchasing: List POs","toolset":"purchasing","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["purchasing:read","receiving:read"],"x-example-source":{"origin":"contract"}},"post":{"tags":["pos"],"operationId":"pos.create","parameters":[],"security":[{"bearer":[]}],"responses":{"201":{"description":"PurchaseOrder","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PurchaseOrderEncoded"},"examples":{"procure-to-pay":{"summary":"Procure to pay","value":{"id":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d","reference":"PO-WIDGET-BLUE","supplier":"Northwind Components","currency":"AUD","number":"PO-00001","serial":1,"status":"draft","lines":[{"sku":"WIDGET-BLUE","ordered":40,"received":0,"unitCostCents":1250}],"createdAt":"2026-08-17T09:00:00.000Z","updatedAt":"2026-08-17T09:00:00.000Z"}}}}}},"400":{"description":"DayInFuture","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DayInFutureEncoded"}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"409":{"description":"LineUncosted | KitNotBuyable | StockSkuOnTwoLines | MirroredFromSource","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/LineUncostedEncoded"},{"$ref":"#/components/schemas/KitNotBuyableEncoded"},{"$ref":"#/components/schemas/StockSkuOnTwoLinesEncoded"},{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}]}}}},"502":{"description":"InventoryUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InventoryUnavailableEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Raise a draft purchase order with a supplier, one line per SKU (quantity + expected unit cost in cents, in the order's `currency` — ISO 4217, default AUD). The order is numbered from the tenant's purchasing settings (`number`, e.g. `PO-00042`; the serial is consumed and never reused). `supplierId` optionally names the CRM company the order is placed with (`supplier` stays the name as shown on the document). `expectedOn` optionally records the day the supplier is expected to deliver; `placedOn` the day the order was really placed with the supplier when that was earlier (a phoned order, a migration) — lead time counts from it (400 `DayInFuture` for a day to come). A line naming a one-SKU kit (a case of 12) buys packs, priced per pack (409 `KitNotBuyable` for other kits, `StockSkuOnTwoLines` for two lines of one SKU). Appends `purchasing.po-created`. `reference` (the buyer's own PO number) is required and is the idempotency key: a retry with the same reference returns the order it already opened and appends nothing.\n\nRequires `purchasing:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreatePurchaseOrderEncoded"},"example":{"reference":"PO-WIDGET-BLUE","supplier":"Northwind Components","supplierId":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","lines":[{"sku":"WIDGET-BLUE","quantity":40}]}}},"required":true},"x-mcp-tool":{"name":"purchasing_create_po","title":"Purchasing: Create PO","toolset":"purchasing","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["purchasing:write"],"x-example-source":{"origin":"workflow","workflow":"procure-to-pay","step":4}}},"/incoming":{"get":{"tags":["pos"],"operationId":"pos.incoming","parameters":[{"name":"skus","in":"query","schema":{"type":"string"},"required":true,"example":"WIDGET-BLUE"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"IncomingStockList","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IncomingStockListEncoded"},"examples":{"contract":{"summary":"pos.incoming","value":{"items":[{"sku":"WIDGET-BLUE","poId":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d","poNumber":"PO-00001","quantity":40,"expectedOn":"2026-10-01"}]}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Stock on its way for `skus` (comma-separated, up to 200): each open purchase order's outstanding units, its number and expected delivery day, soonest first. No cost, no supplier — readable with `stock:read`; the orders with prices are `GET /pos`. Read-only.\n\nRequires `stock:read` or `purchasing:read`.","x-mcp-withheld":"the stock on order without its prices, for a rep's screens; an agent that may see purchase orders reads them whole with `purchasing_list_pos`","x-required-scopes":["stock:read","purchasing:read"],"x-example-source":{"origin":"contract"}}},"/pos/{poId}":{"get":{"tags":["pos"],"operationId":"pos.get","parameters":[{"name":"poId","in":"path","schema":{"$ref":"#/components/schemas/PoId"},"required":true,"example":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"PurchaseOrder","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PurchaseOrderEncoded"},"examples":{"contract":{"summary":"pos.get","value":{"id":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d","number":"PO-00001","serial":1,"reference":"PO-WIDGET-BLUE","supplier":"Northwind Components","supplierId":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","currency":"AUD","status":"invoiced","lines":[{"sku":"WIDGET-BLUE","ordered":40,"received":40,"cancelled":0,"unitCostCents":1250,"confirmedUnitCostCents":1310}],"landedCosts":[],"payables":[{"currency":"AUD","billedCents":52400,"paidCents":0}],"payments":[],"revision":0,"createdAt":"2026-09-22T01:15:00.000Z","updatedAt":"2026-10-03T00:30:00.000Z","expectedOn":"2026-10-01","receipts":[{"receiptId":"rcpt_01a15864-bc4f-7f80-b1c3-5d6e7f809a1b","receivedOn":"2026-10-01","lines":[{"sku":"WIDGET-BLUE","quantity":40}]}],"invoicedAt":"2026-10-03T00:30:00.000Z"}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"PoNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PoNotFoundEncoded"}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"One purchase order by its `po_` id: number, supplier, currency, status, every line with what has been received against it, landed costs, and when it was invoiced or closed. Read-only.\n\nRequires `purchasing:read` or `receiving:read`.","x-mcp-tool":{"name":"purchasing_get_po","title":"Purchasing: Get PO","toolset":"purchasing","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["purchasing:read","receiving:read"],"x-example-source":{"origin":"contract"}},"put":{"tags":["pos"],"operationId":"pos.update","parameters":[{"name":"poId","in":"path","schema":{"$ref":"#/components/schemas/PoId"},"required":true,"example":"po_01a1340f-9980-7c41-9d37-d97a5cec069b"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"PurchaseOrder","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PurchaseOrderEncoded"},"examples":{"contract":{"summary":"pos.update","value":{"id":"po_01a1340f-9980-7c41-9d37-d97a5cec069b","number":"PO-00002","serial":2,"reference":"NW-REORDER-RED","supplier":"Northwind Components","supplierId":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","currency":"AUD","status":"draft","lines":[{"sku":"WIDGET-RED","ordered":30,"received":0,"cancelled":0,"unitCostCents":1180},{"sku":"WIDGET-BLUE","ordered":10,"received":0,"cancelled":0,"unitCostCents":1250}],"landedCosts":[],"payables":[],"payments":[],"revision":0,"createdAt":"2026-10-06T23:40:00.000Z","updatedAt":"2026-10-07T00:05:00.000Z"}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"PoNotFound | ItemNotFound","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/PoNotFoundEncoded"},{"$ref":"#/components/schemas/ItemNotFoundEncoded"}]}}}},"409":{"description":"PoNotEditable | PoLineReceived | LineUncosted | KitNotBuyable | StockSkuOnTwoLines | MirroredFromSource","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/PoNotEditableEncoded"},{"$ref":"#/components/schemas/PoLineReceivedEncoded"},{"$ref":"#/components/schemas/LineUncostedEncoded"},{"$ref":"#/components/schemas/KitNotBuyableEncoded"},{"$ref":"#/components/schemas/StockSkuOnTwoLinesEncoded"},{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}]}}}},"502":{"description":"InventoryUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InventoryUnavailableEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Rewrite a purchase order: the supplier and/or the whole line set (replace semantics — the lines sent are the lines the order has afterwards). `supplierId` attaches the order to a CRM company, or detaches it when sent as `null` (the typed `supplier` name stays). A draft takes anything. Once authorised, a line with units already received is frozen — 409 `PoLineReceived` if its quantity would drop below what arrived or its cost changes — while unreceived lines may change, be removed or be added, and inventory's incoming expectations are re-registered to match (cancel, then expect the new outstanding quantity, keyed by the order's revision; 502 `InventoryUnavailable` if that fails). 409 `PoNotEditable` once received, invoiced, closed or cancelled. Appends `purchasing.po-updated`. Idempotent by content: a retry that says what the order already says is acknowledged and appends nothing. A stock-changing rewrite is saved as the order's plan first and its fact lands once inventory has every movement; a plan inventory cannot take yet is carried out by its own run when inventory answers.\n\nRequires `purchasing:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdatePurchaseOrderEncoded"},"example":{"lines":[{"sku":"WIDGET-RED","quantity":30},{"sku":"WIDGET-BLUE","quantity":10}]}}},"required":true},"x-mcp-tool":{"name":"purchasing_update_po","title":"Purchasing: Update PO","toolset":"purchasing","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["purchasing:write"],"x-example-source":{"origin":"contract"}},"delete":{"tags":["pos"],"operationId":"pos.cancel","parameters":[{"name":"poId","in":"path","schema":{"$ref":"#/components/schemas/PoId"},"required":true,"example":"po_01a1340f-9980-7c41-9d37-d97a5cec069b"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"PurchaseOrder","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PurchaseOrderEncoded"},"examples":{"contract":{"summary":"pos.cancel","value":{"id":"po_01a1340f-9980-7c41-9d37-d97a5cec069b","number":"PO-00002","serial":2,"reference":"NW-REORDER-RED","supplier":"Northwind Components","supplierId":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","currency":"AUD","status":"cancelled","lines":[{"sku":"WIDGET-RED","ordered":30,"received":0,"cancelled":0,"unitCostCents":1180},{"sku":"WIDGET-BLUE","ordered":10,"received":0,"cancelled":0,"unitCostCents":1250}],"landedCosts":[],"payables":[],"payments":[],"revision":0,"createdAt":"2026-10-06T23:40:00.000Z","updatedAt":"2026-10-08T02:30:00.000Z"}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"PoNotFound | ItemNotFound","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/PoNotFoundEncoded"},{"$ref":"#/components/schemas/ItemNotFoundEncoded"}]}}}},"409":{"description":"PoHasReceipts | MirroredFromSource","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/PoHasReceiptsEncoded"},{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}]}}}},"502":{"description":"InventoryUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InventoryUnavailableEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Cancel a purchase order before any goods arrive. The order stays on the books as `cancelled` (its reference remains taken); an authorised order's incoming expectations are withdrawn from inventory first (`inventory.incoming-cancelled` per line, keyed `<poId>:<sku>:cancel`; 502 `InventoryUnavailable` while inventory is away, the cancel finishing later). 409 `PoHasReceipts` once anything was received — short-close it instead. Appends `purchasing.po-cancelled`. Idempotent: a retry against an already-cancelled order is acknowledged and appends nothing.\n\nRequires `purchasing:write`.","x-mcp-tool":{"name":"purchasing_cancel_po","title":"Purchasing: Cancel PO","toolset":"purchasing","readOnlyHint":false,"destructiveHint":true,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["purchasing:write"],"x-example-source":{"origin":"contract"}}},"/pos/{poId}/expected":{"put":{"tags":["pos"],"operationId":"pos.expected","parameters":[{"name":"poId","in":"path","schema":{"$ref":"#/components/schemas/PoId"},"required":true,"example":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"PurchaseOrder","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PurchaseOrderEncoded"},"examples":{"contract":{"summary":"pos.expected","value":{"id":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d","number":"PO-00001","serial":1,"reference":"PO-WIDGET-BLUE","supplier":"Northwind Components","supplierId":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","currency":"AUD","status":"authorised","lines":[{"sku":"WIDGET-BLUE","ordered":40,"received":0,"cancelled":0,"unitCostCents":1250}],"landedCosts":[],"payables":[],"payments":[],"revision":0,"createdAt":"2026-09-22T01:15:00.000Z","updatedAt":"2026-09-23T04:00:00.000Z","expectedOn":"2026-10-01"}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"PoNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PoNotFoundEncoded"}}}},"409":{"description":"PoNotEditable | MirroredFromSource","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/PoNotEditableEncoded"},{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}]}}}},"502":{"description":"InventoryUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InventoryUnavailableEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Set the expected delivery day (`expectedOn`, `YYYY-MM-DD`), or clear it with `null` — what the dashboard's arriving and overdue deliveries are measured against. The date is planning, not a change to the lines, so it never re-registers inventory's incoming expectations the way a line rewrite does. 409 `PoNotEditable` once received, invoiced, closed or cancelled. Appends `purchasing.po-expected-changed`. Idempotent by content: sending the date already set appends nothing.\n\nRequires `purchasing:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SetPoExpectedEncoded"},"example":{"expectedOn":"2026-10-01"}}},"required":true},"x-mcp-tool":{"name":"purchasing_set_po_expected","title":"Purchasing: Set PO expected","toolset":"purchasing","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["purchasing:write"],"x-example-source":{"origin":"contract"}}},"/pos/{poId}/authorise":{"post":{"tags":["pos"],"operationId":"pos.authorise","parameters":[{"name":"poId","in":"path","schema":{"$ref":"#/components/schemas/PoId"},"required":true,"example":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"PurchaseOrder","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PurchaseOrderEncoded"},"examples":{"contract":{"summary":"pos.authorise","value":{"id":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d","number":"PO-00001","serial":1,"reference":"PO-WIDGET-BLUE","supplier":"Northwind Components","supplierId":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","currency":"AUD","status":"authorised","lines":[{"sku":"WIDGET-BLUE","ordered":40,"received":0,"cancelled":0,"unitCostCents":1250}],"landedCosts":[],"payables":[],"payments":[],"revision":0,"createdAt":"2026-09-22T01:15:00.000Z","updatedAt":"2026-09-22T01:20:00.000Z"}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"PoNotFound | ItemNotFound","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/PoNotFoundEncoded"},{"$ref":"#/components/schemas/ItemNotFoundEncoded"}]}}}},"409":{"description":"PoNotDraft | MirroredFromSource","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/PoNotDraftEncoded"},{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}]}}}},"502":{"description":"InventoryUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InventoryUnavailableEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Authorise a draft PO. Registers each line as an incoming expectation with the inventory service (502 `InventoryUnavailable` while it is away, the authorisation finishing later), then appends `purchasing.po-authorised`. Idempotent by state: a retry against an already-authorised PO is acknowledged — it appends nothing and issues nothing to inventory (the expectations it does issue carry the reference `<poId>:<sku>`, so inventory dedupes them as well). 409 `PoNotDraft` once the order has left authorisation — received, invoiced, closed or cancelled.\n\nRequires `purchasing:write`.","x-mcp-tool":{"name":"purchasing_authorise_po","title":"Purchasing: Authorise PO","toolset":"purchasing","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["purchasing:write"],"x-example-source":{"origin":"contract"}}},"/pos/{poId}/receipts":{"post":{"tags":["pos"],"operationId":"pos.receive","parameters":[{"name":"poId","in":"path","schema":{"$ref":"#/components/schemas/PoId"},"required":true,"example":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"PurchaseOrder","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PurchaseOrderEncoded"},"examples":{"contract":{"summary":"pos.receive","value":{"id":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d","number":"PO-00001","serial":1,"reference":"PO-WIDGET-BLUE","supplier":"Northwind Components","supplierId":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","currency":"AUD","status":"received","lines":[{"sku":"WIDGET-BLUE","ordered":40,"received":40,"cancelled":0,"unitCostCents":1250}],"landedCosts":[],"payables":[],"payments":[],"revision":0,"createdAt":"2026-09-22T01:15:00.000Z","updatedAt":"2026-10-01T03:42:00.000Z","expectedOn":"2026-10-01","receipts":[{"receiptId":"rcpt_01a15864-bc4f-7f80-b1c3-5d6e7f809a1b","receivedOn":"2026-10-01","lines":[{"sku":"WIDGET-BLUE","quantity":40}]}]}}}}}},"400":{"description":"DayInFuture","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DayInFutureEncoded"}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"PoNotFound | ItemNotFound | UnknownInboundShipment","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/PoNotFoundEncoded"},{"$ref":"#/components/schemas/ItemNotFoundEncoded"},{"$ref":"#/components/schemas/UnknownInboundShipmentEncoded"}]}}}},"409":{"description":"PoNotAuthorised | UnknownPoLine | OverReceipt | SerialAlreadyRegistered | TrackingMismatch | MirroredFromSource","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/PoNotAuthorisedEncoded"},{"$ref":"#/components/schemas/UnknownPoLineEncoded"},{"$ref":"#/components/schemas/OverReceiptEncoded"},{"$ref":"#/components/schemas/SerialAlreadyRegisteredEncoded"},{"$ref":"#/components/schemas/TrackingMismatchEncoded"},{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}]}}}},"502":{"description":"InventoryUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InventoryUnavailableEncoded"}}}},"503":{"description":"ReceiptPending | RequestLogUnavailable","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/ReceiptPendingEncoded"},{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}]}}}}},"description":"Record goods arriving against an authorised PO: one delivery, covering one or more of the order's lines (`lines`, each SKU at most once), as one fact. Each line captures unit/lot identity when its SKU requires it: serial-tracked SKUs need one serial per unit (409 `SerialAlreadyRegistered` if any serial was ever received before — purchasing is the uniqueness authority); batch-tracked SKUs need a `batchNumber`, optionally with `expiresAt` (409 `TrackingMismatch` when identity fields don't match the SKU's mode). A pack line is received in packs and books its contents at the pack's cost spread (never serial-tracked). Every line is checked (409 `UnknownPoLine`, 409 `OverReceipt`) before anything moves, so a refused receipt moves nothing. An accepted delivery is a durable saga: purchasing appends `purchasing.receipt-requested` first, then commands the inventory service to receive each line's quantity — `locationId` names the site the goods landed at (default: the tenant's default location); inventory draws the PO's incoming expectation down there first, then wherever else it was expected — and finally appends `purchasing.receipt-recorded` carrying every line's identity and PO-line cost (with the policy's `purchasing.invoice-authorised` and `purchasing.po-closed` in the same transaction when the tenant's settings say so), or `purchasing.receipt-refused` when inventory no longer knows a SKU (404 `ItemNotFound`). An inventory outage is retried inside the run, which a crash re-drives on boot; a request that outlives the service's wait for the run (30s) answers 503 `ReceiptPending` while the run continues. `receiptId`, a caller-minted `rcpt_…`, is required and is the idempotency key: a retry with the same id is acknowledged from the journal — attaching to a run still in flight, answering from it once done, including once the order has left the receiving states, which the receipt that completed it does itself — and receives nothing twice, and each line's inventory command carries `<receiptId>:<sku>` so a re-driven line is acknowledged there too (502 `InventoryUnavailable` is reserved for the acceptance check's SKU lookups). The fold stores the receipt state: the first units in make it `partially-received`, the receipt completing the last line makes it `received`. `receivedOn` is the day the goods came in when that was not today (400 `DayInFuture` for a day to come) and `shipmentId` the inbound shipment that brought them (404 `UnknownInboundShipment` for one the order does not have): the receipt joins the order's `receipts`, marks the shipment delivered, and is what supplier and carrier performance are measured by. Units that arrived damaged, short, over or wrong are not received here — report them with `POST /pos/:poId/issues`.\n\nRequires `receiving:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecordReceiptEncoded"},"example":{"receiptId":"rcpt_01a15864-bc4f-7f80-b1c3-5d6e7f809a1b","locationId":"loc_01a15856-c554-7a7b-8c9d-0e1f2a3b4c5d","lines":[{"sku":"WIDGET-BLUE","quantity":40}]}}},"required":true},"x-mcp-tool":{"name":"purchasing_record_receipt","title":"Purchasing: Record receipt","toolset":"receiving","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["receiving:write"],"x-example-source":{"origin":"contract"}}},"/pos/{poId}/invoice":{"post":{"tags":["pos"],"operationId":"pos.invoice","parameters":[{"name":"poId","in":"path","schema":{"$ref":"#/components/schemas/PoId"},"required":true,"example":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"PurchaseOrder","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PurchaseOrderEncoded"},"examples":{"contract":{"summary":"pos.invoice","value":{"id":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d","number":"PO-00001","serial":1,"reference":"PO-WIDGET-BLUE","supplier":"Northwind Components","supplierId":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","currency":"AUD","status":"invoiced","lines":[{"sku":"WIDGET-BLUE","ordered":40,"received":40,"cancelled":0,"unitCostCents":1250,"confirmedUnitCostCents":1310}],"landedCosts":[],"payables":[{"currency":"AUD","billedCents":52400,"paidCents":0}],"payments":[],"revision":0,"createdAt":"2026-09-22T01:15:00.000Z","updatedAt":"2026-10-03T00:30:00.000Z","expectedOn":"2026-10-01","receipts":[{"receiptId":"rcpt_01a15864-bc4f-7f80-b1c3-5d6e7f809a1b","receivedOn":"2026-10-01","lines":[{"sku":"WIDGET-BLUE","quantity":40}]}],"invoicedAt":"2026-10-03T00:30:00.000Z"}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"PoNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PoNotFoundEncoded"}}}},"409":{"description":"PoNotAuthorised | PoAlreadyInvoiced | UnknownPoLine | MirroredFromSource","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/PoNotAuthorisedEncoded"},{"$ref":"#/components/schemas/PoAlreadyInvoicedEncoded"},{"$ref":"#/components/schemas/UnknownPoLineEncoded"},{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}]}}}},"502":{"description":"InventoryUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InventoryUnavailableEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Authorise the supplier invoice, confirming per-line unit costs. This is the cost-confirmation point: until it happens, stock is valued at PO price. Accepted on an `authorised`, `partially-received` or `received` order, and — as a retry — on the `invoiced` order this command itself produces (409 `PoNotAuthorised` on a draft, closed or cancelled order): a fully received order becomes `invoiced` (and `closed` in the same commit when the tenant's `autoClose` setting is on); a partially received one records `invoicedAt` and stays where the goods say it is. Accounting derives cost corrections from the delta. Idempotent by content: a retry that confirms the same costs on an already-invoiced PO is acknowledged and appends nothing; different costs are refused with 409 `PoAlreadyInvoiced` (an invoice is not re-authorised, it is corrected). Appends `purchasing.invoice-authorised`.\n\nRequires `purchasing:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthoriseInvoiceEncoded"},"example":{"lines":[{"sku":"WIDGET-BLUE","unitCostCents":1310}]}}},"required":true},"x-mcp-tool":{"name":"purchasing_authorise_invoice","title":"Purchasing: Authorise invoice","toolset":"purchasing","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["purchasing:write"],"x-example-source":{"origin":"contract"}}},"/pos/{poId}/landed-costs":{"post":{"tags":["pos"],"operationId":"pos.landedCost","parameters":[{"name":"poId","in":"path","schema":{"$ref":"#/components/schemas/PoId"},"required":true,"example":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"PurchaseOrder","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PurchaseOrderEncoded"},"examples":{"contract":{"summary":"pos.landedCost","value":{"id":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d","number":"PO-00001","serial":1,"reference":"PO-WIDGET-BLUE","supplier":"Northwind Components","supplierId":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","currency":"AUD","status":"invoiced","lines":[{"sku":"WIDGET-BLUE","ordered":40,"received":40,"cancelled":0,"unitCostCents":1250,"confirmedUnitCostCents":1310}],"landedCosts":[{"amountCents":8000,"currency":"AUD","description":"Freight, Northwind consignment NW-88213","reference":"FRT-88213","lines":[{"sku":"WIDGET-BLUE","quantity":40,"amountCents":8000}]}],"payables":[{"currency":"AUD","billedCents":60400,"paidCents":0}],"payments":[],"revision":0,"createdAt":"2026-09-22T01:15:00.000Z","updatedAt":"2026-10-04T22:05:00.000Z","expectedOn":"2026-10-01","receipts":[{"receiptId":"rcpt_01a15864-bc4f-7f80-b1c3-5d6e7f809a1b","receivedOn":"2026-10-01","lines":[{"sku":"WIDGET-BLUE","quantity":40}]}],"invoicedAt":"2026-10-03T00:30:00.000Z"}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"PoNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PoNotFoundEncoded"}}}},"409":{"description":"PoNotAuthorised | UnknownPoLine | LandedCostExceedsLine | MirroredFromSource","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/PoNotAuthorisedEncoded"},{"$ref":"#/components/schemas/UnknownPoLineEncoded"},{"$ref":"#/components/schemas/LandedCostExceedsLineEncoded"},{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}]}}}},"502":{"description":"InventoryUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InventoryUnavailableEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Allocate an additional cost (freight, customs, duties) to an authorised, partially received, received or invoiced PO after the fact (409 `PoNotAuthorised` on a draft, a closed or a cancelled order — close after the freight bill, not before). The amount is spread equally per unit over the units the command names: the whole order when `lines` is omitted (every line, every unit not cancelled), or the named lines — each in full, or `quantity` units of it (409 `UnknownPoLine` for a SKU not on the order, 409 `LandedCostExceedsLine` for more units than the line carries; a pack line counts packs). The split is exact to the cent (largest remainders take the leftover) and is recorded per line on the order and in the event; accounting lifts that SKU's cost layers for this order by each line's share, over the units received so far. Corrections flow through accounting as new entries — history is never rewritten. Appends `purchasing.landed-cost-allocated`. `reference` is required and is the idempotency key: a retry with the same reference is acknowledged and appends nothing, including against an order that has since closed.\n\nRequires `purchasing:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AllocateLandedCostEncoded"},"example":{"amountCents":8000,"currency":"AUD","description":"Freight, Northwind consignment NW-88213","reference":"FRT-88213"}}},"required":true},"x-mcp-tool":{"name":"purchasing_allocate_landed_cost","title":"Purchasing: Allocate landed cost","toolset":"purchasing","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["purchasing:write"],"x-example-source":{"origin":"contract"}}},"/pos/{poId}/costs":{"post":{"tags":["pos"],"operationId":"pos.recordCost","parameters":[{"name":"poId","in":"path","schema":{"$ref":"#/components/schemas/PoId"},"required":true,"example":"po_01a15ad0-c2b1-7c3d-8e4f-5a6b7c8d9e0f"}],"security":[{"bearer":[]}],"responses":{"201":{"description":"PurchaseOrder","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PurchaseOrderEncoded"},"examples":{"journal-order-costs":{"summary":"Journal an additional cost on an order","value":{"id":"po_01a15ad0-c2b1-7c3d-8e4f-5a6b7c8d9e0f","number":"PO-00001","serial":1,"reference":"PO-POTTERY-0918","supplier":"Kiln Street Pottery","currency":"AUD","status":"authorised","authorisedOn":"2026-10-21","lines":[{"sku":"MUG-SPECKLED","ordered":40,"received":0,"cancelled":0,"unitCostCents":950}],"receipts":[],"issues":[],"shipments":[],"landedCosts":[],"costs":[{"costId":"cost_01a15ad0-f0d1-7662-82e0-1b2c3d4e5f60","amountCents":3500,"currency":"AUD","fx":{"currency":"AUD","home":"AUD","rate":1,"rateDate":"2026-10-21","source":"same"},"reason":"Customs broker's clearance fee","accountCode":"6300","date":"2026-10-21","recordedBy":{"_tag":"user","id":"usr_01a15ad0-a1b2-7c3d-8e4f-5a6b7c8d9e01"},"recordedAt":"2026-10-21T01:10:39.501Z","capitalised":false,"lines":[]}],"payables":[],"payments":[],"revision":0,"createdAt":"2026-10-21T01:10:37.821Z","updatedAt":"2026-10-21T01:10:39.501Z"}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"PoNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PoNotFoundEncoded"}}}},"409":{"description":"PoNotAuthorised | UnknownPoLine | AccountNotPostable | CostCurrencyRefused | NothingReceivedToCapitalise | MirroredFromSource","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/PoNotAuthorisedEncoded"},{"$ref":"#/components/schemas/UnknownPoLineEncoded"},{"$ref":"#/components/schemas/AccountNotPostableEncoded"},{"$ref":"#/components/schemas/CostCurrencyRefusedEncoded"},{"$ref":"#/components/schemas/NothingReceivedToCapitaliseEncoded"},{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}]}}}},"502":{"description":"InventoryUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InventoryUnavailableEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Journal an additional cost on the order by hand: an amount, a `reason` and the chart account it is charged to (`accountCode`), for the order or one line (`sku`; 409 `UnknownPoLine`). 409 `AccountNotPostable` for an account not in the chart, archived or kept by the ledger; 409 `CostCurrencyRefused` for a currency other than the order's or the home one; 409 `PoNotAuthorised` on a draft, closed or cancelled order. With `capitalise`, or on the inventory account, it is spread over the units received like a landed cost (409 `NothingReceivedToCapitalise` before any arrive); otherwise an expense. Credits 2160 accrued costs (`docs/order-costs.md`). Appends `purchasing.cost-recorded`. `costId` (a caller-minted `cost_…`) is required and is the idempotency key: a retry with the same id is acknowledged and appends nothing.\n\nRequires `financials:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecordPoCostEncoded"},"example":{"costId":"cost_01a15ad0-f0d1-7662-82e0-1b2c3d4e5f60","amountCents":3500,"reason":"Customs broker's clearance fee","accountCode":"6300"}}},"required":true},"x-mcp-tool":{"name":"purchasing_record_po_cost","title":"Purchasing: Record PO cost","toolset":"costs","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["financials:write"],"x-example-source":{"origin":"workflow","workflow":"journal-order-costs","step":14}}},"/pos/{poId}/costs/{costId}/reverse":{"post":{"tags":["pos"],"operationId":"pos.reverseCost","parameters":[{"name":"poId","in":"path","schema":{"$ref":"#/components/schemas/PoId"},"required":true,"example":"po_01a15ad0-c2b1-7c3d-8e4f-5a6b7c8d9e0f"},{"name":"costId","in":"path","schema":{"$ref":"#/components/schemas/CostId"},"required":true,"example":"cost_01a15ad0-f0d1-7662-82e0-1b2c3d4e5f60"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"PurchaseOrder","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PurchaseOrderEncoded"},"examples":{"journal-order-costs":{"summary":"Journal an additional cost on an order","value":{"id":"po_01a15ad0-c2b1-7c3d-8e4f-5a6b7c8d9e0f","number":"PO-00001","serial":1,"reference":"PO-POTTERY-0918","supplier":"Kiln Street Pottery","currency":"AUD","status":"authorised","authorisedOn":"2026-10-21","lines":[{"sku":"MUG-SPECKLED","ordered":40,"received":0,"cancelled":0,"unitCostCents":950}],"receipts":[],"issues":[],"shipments":[],"landedCosts":[],"costs":[{"costId":"cost_01a15ad0-f0d1-7662-82e0-1b2c3d4e5f60","amountCents":3500,"currency":"AUD","fx":{"currency":"AUD","home":"AUD","rate":1,"rateDate":"2026-10-21","source":"same"},"reason":"Customs broker's clearance fee","accountCode":"6300","date":"2026-10-21","recordedBy":{"_tag":"user","id":"usr_01a15ad0-a1b2-7c3d-8e4f-5a6b7c8d9e01"},"recordedAt":"2026-10-21T01:10:39.501Z","reversal":{"by":{"_tag":"user","id":"usr_01a15ad0-a1b2-7c3d-8e4f-5a6b7c8d9e01"},"at":"2026-10-21T01:10:40.464Z","reason":"Billed to the supplier instead"},"capitalised":false,"lines":[]}],"payables":[],"payments":[],"revision":0,"createdAt":"2026-10-21T01:10:37.821Z","updatedAt":"2026-10-21T01:10:40.464Z"}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"PoNotFound | CostNotFound","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/PoNotFoundEncoded"},{"$ref":"#/components/schemas/CostNotFoundEncoded"}]}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"502":{"description":"InventoryUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InventoryUnavailableEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Reverse a cost on the order (404 `CostNotFound`): it stays, marked reversed, and the ledger posts its opposite (a capitalised one lowers the layers it lifted). Appends `purchasing.cost-reversed`. Idempotent by state: a cost is reversed once, so a retry is acknowledged and appends nothing.\n\nRequires `financials:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReverseCostEncoded"},"example":{"reason":"Billed to the supplier instead"}}},"required":true},"x-mcp-tool":{"name":"purchasing_reverse_po_cost","title":"Purchasing: Reverse PO cost","toolset":"costs","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["financials:write"],"x-example-source":{"origin":"workflow","workflow":"journal-order-costs","step":16}}},"/supplier-payments":{"get":{"tags":["pos"],"operationId":"pos.supplierPayments","parameters":[{"name":"supplierId","in":"query","schema":{"$ref":"#/components/schemas/CmpId"},"required":false},{"name":"poId","in":"query","schema":{"$ref":"#/components/schemas/PoId"},"required":false,"example":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d"},{"name":"currency","in":"query","schema":{"$ref":"#/components/schemas/PoCurrency"},"required":false},{"name":"limit","in":"query","schema":{"type":"string"},"required":false},{"name":"offset","in":"query","schema":{"type":"string"},"required":false}],"security":[{"bearer":[]}],"responses":{"200":{"description":"SupplierPaymentPage","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SupplierPaymentPageEncoded"},"examples":{"contract":{"summary":"pos.supplierPayments","value":{"items":[{"paymentId":"spay_01a14c85-ce80-7b12-9329-9bd3b91535bf","supplier":"Northwind Components","supplierId":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","currency":"AUD","amountCents":60400,"paidOn":"2026-10-31","method":"bank-transfer","remittance":"EFT 4471-0931","fx":{"currency":"AUD","home":"AUD","rate":1,"rateDate":"2026-10-31","source":"same"},"allocations":[{"poId":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d","amountCents":60400}],"recordedAt":"2026-10-31T02:10:00.000Z"}],"total":1,"limit":100,"offset":0}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Money paid to suppliers, the latest day paid first: each payment's supplier, currency, amount, method, the day the money left, the bank's or remittance advice's reference, the rate the books post it at, and its share on each purchase order it settled. `supplierId` narrows to one CRM company, `poId` to the payments with a share on that order, `currency` to one currency. `limit` is 1–500, 100 when omitted.\n\nRequires `payments:read` or `purchasing:read`.","x-mcp-tool":{"name":"purchasing_list_supplier_payments","title":"Purchasing: List supplier payments","toolset":"accounting","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["payments:read","purchasing:read"],"x-example-source":{"origin":"contract"}},"post":{"tags":["pos"],"operationId":"pos.supplierPayment","parameters":[],"security":[{"bearer":[]}],"responses":{"200":{"description":"SupplierPayment","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SupplierPaymentEncoded"},"examples":{"contract":{"summary":"pos.supplierPayment","value":{"paymentId":"spay_01a14c85-ce80-7b12-9329-9bd3b91535bf","supplier":"Northwind Components","supplierId":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","currency":"AUD","amountCents":60400,"paidOn":"2026-10-31","method":"bank-transfer","remittance":"EFT 4471-0931","fx":{"currency":"AUD","home":"AUD","rate":1,"rateDate":"2026-10-31","source":"same"},"allocations":[{"poId":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d","amountCents":60400}],"recordedAt":"2026-10-31T02:10:00.000Z"}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"PoNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PoNotFoundEncoded"}}}},"409":{"description":"SupplierOverpayment | SupplierPaymentMixesSuppliers | SupplierPaymentHomeMismatch | MirroredFromSource","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/SupplierOverpaymentEncoded"},{"$ref":"#/components/schemas/SupplierPaymentMixesSuppliersEncoded"},{"$ref":"#/components/schemas/SupplierPaymentHomeMismatchEncoded"},{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}]}}}},"502":{"description":"InventoryUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InventoryUnavailableEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Record money paid to a supplier against what one or more of its purchase orders owe, in the currency they billed: `allocations` names each order (`poId`, once each) and its share in `currency`; the payment is their sum. Each order's `payables` shows what its supplier invoice and landed costs billed in each currency and what payments have settled; a share above what its order still owes there is 409 `SupplierOverpayment`, orders placed with different suppliers are 409 `SupplierPaymentMixesSuppliers`, and an unknown order is 404 `PoNotFound`. Any order that owes, closed ones included, takes a payment. The rate is captured on the fact: `homeAmountCents`, what the payment cost in the home currency as the bank charged it, books it at that actual rate (409 `SupplierPaymentHomeMismatch` when the payment is in the home currency and the two differ); omitted, the reference rate for `paidOn` (the day the money left, today when omitted) — 503 `InventoryUnavailable` when no rate is published, never a made-up one. `remittance` is the bank's or remittance advice's reference, kept verbatim, and `method` says how the money went (bank transfer, card, cheque, cash, direct debit or other). Appends `purchasing.supplier-payment-recorded`, which adds the payment to each order's `payments`; accounting relieves each order's payable at the home amount its invoice booked, credits 1195 supplier payments clearing with the payment at its own rate and posts the difference to 7100 realised exchange. `paymentId`, a caller-minted `spay_…`, is required and is the idempotency key: a retry with the same id is acknowledged and answers the payment as first recorded, appending nothing and asking no rate.\n\nRequires `payments:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecordSupplierPaymentEncoded"},"example":{"paymentId":"spay_01a14c85-ce80-7b12-9329-9bd3b91535bf","currency":"AUD","allocations":[{"poId":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d","amountCents":60400}],"method":"bank-transfer","paidOn":"2026-10-31","remittance":"EFT 4471-0931"}}},"required":true},"x-mcp-tool":{"name":"purchasing_settle_supplier_invoices","title":"Purchasing: Settle supplier invoices","toolset":"accounting","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["payments:write"],"x-example-source":{"origin":"contract"}}},"/pos/{poId}/close":{"post":{"tags":["pos"],"operationId":"pos.close","parameters":[{"name":"poId","in":"path","schema":{"$ref":"#/components/schemas/PoId"},"required":true,"example":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"PurchaseOrder","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PurchaseOrderEncoded"},"examples":{"contract":{"summary":"pos.close","value":{"id":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d","number":"PO-00001","serial":1,"reference":"PO-WIDGET-BLUE","supplier":"Northwind Components","supplierId":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","currency":"AUD","status":"closed","lines":[{"sku":"WIDGET-BLUE","ordered":40,"received":40,"cancelled":0,"unitCostCents":1250,"confirmedUnitCostCents":1310}],"landedCosts":[{"amountCents":8000,"currency":"AUD","description":"Freight, Northwind consignment NW-88213","reference":"FRT-88213","lines":[{"sku":"WIDGET-BLUE","quantity":40,"amountCents":8000}]}],"payables":[{"currency":"AUD","billedCents":60400,"paidCents":60400}],"payments":[{"paymentId":"spay_01a14c85-ce80-7b12-9329-9bd3b91535bf","currency":"AUD","amountCents":60400,"paidOn":"2026-10-31"}],"revision":0,"createdAt":"2026-09-22T01:15:00.000Z","updatedAt":"2026-10-31T02:15:00.000Z","expectedOn":"2026-10-01","receipts":[{"receiptId":"rcpt_01a15864-bc4f-7f80-b1c3-5d6e7f809a1b","receivedOn":"2026-10-01","lines":[{"sku":"WIDGET-BLUE","quantity":40}]}],"invoicedAt":"2026-10-03T00:30:00.000Z","closedAt":"2026-10-31T02:15:00.000Z"}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"PoNotFound | ItemNotFound","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/PoNotFoundEncoded"},{"$ref":"#/components/schemas/ItemNotFoundEncoded"}]}}}},"409":{"description":"PoNotClosable | MirroredFromSource","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/PoNotClosableEncoded"},{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}]}}}},"502":{"description":"InventoryUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InventoryUnavailableEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Close a purchase order: done, read only from here. From `received` or `invoiced` it simply ends the order. From `authorised` or `partially-received` it is a short-close, and `remainder` says what becomes of undelivered quantity: `cancel` withdraws it from inventory (`inventory.incoming-cancelled` per outstanding line, keyed `<poId>:<sku>:close`; 502 `InventoryUnavailable` while it is away, the close finishing later) and marks it `cancelled` on the line; `keep` leaves the shortfall on the lines for supplier follow-up; omitted, the tenant's `shortClose` setting decides. 409 `PoNotClosable` on a draft or a cancelled order. Appends `purchasing.po-closed`. Idempotent by state: an order closes once, so a retry on a closed order is acknowledged and appends nothing.\n\nRequires `purchasing:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ClosePurchaseOrderEncoded"},"example":{"reason":"Delivered, invoiced and paid in full"}}},"required":true},"x-mcp-tool":{"name":"purchasing_close_po","title":"Purchasing: Close PO","toolset":"purchasing","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["purchasing:write"],"x-example-source":{"origin":"contract"}}},"/pos/{poId}/issues":{"post":{"tags":["pos"],"operationId":"pos.receiptIssue","parameters":[{"name":"poId","in":"path","schema":{"$ref":"#/components/schemas/PoId"},"required":true,"example":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"PurchaseOrder","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PurchaseOrderEncoded"},"examples":{"contract":{"summary":"pos.receiptIssue","value":{"id":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d","number":"PO-00001","serial":1,"reference":"PO-WIDGET-BLUE","supplier":"Northwind Components","supplierId":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","currency":"AUD","status":"received","lines":[{"sku":"WIDGET-BLUE","ordered":40,"received":40,"cancelled":0,"unitCostCents":1250}],"landedCosts":[],"payables":[],"payments":[],"revision":0,"createdAt":"2026-09-22T01:15:00.000Z","updatedAt":"2026-10-01T03:50:00.000Z","expectedOn":"2026-10-01","receipts":[{"receiptId":"rcpt_01a15864-bc4f-7f80-b1c3-5d6e7f809a1b","receivedOn":"2026-10-01","lines":[{"sku":"WIDGET-BLUE","quantity":40}]}],"issues":[{"issueId":"rci_01a1586b-3d5f-7e62-8c4b-3f5a7b9d1e2f","receiptId":"rcpt_01a15864-bc4f-7f80-b1c3-5d6e7f809a1b","reportedOn":"2026-10-01","lines":[{"sku":"WIDGET-BLUE","condition":"damaged","quantity":2,"reason":"Carton crushed in transit"}]}]}}}}}},"400":{"description":"DayInFuture","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DayInFutureEncoded"}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"PoNotFound | UnknownInboundShipment","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/PoNotFoundEncoded"},{"$ref":"#/components/schemas/UnknownInboundShipmentEncoded"}]}}}},"409":{"description":"PoNotAuthorised | UnknownPoLine | MirroredFromSource","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/PoNotAuthorisedEncoded"},{"$ref":"#/components/schemas/UnknownPoLineEncoded"},{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}]}}}},"502":{"description":"InventoryUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InventoryUnavailableEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Report what was wrong with a delivery: per line, how many units arrived `damaged`, `short` (fewer than the supplier's paperwork said), `over` (more than ordered, not accepted) or as the `wrong-item`, each with an optional `reason`. None of them is taken into stock — the order still expects them until it is short-closed — and they are what a supplier's damage, short and over-shipment rates, and the carrier that brought them (`shipmentId`), are measured by. `receiptId` names the receipt the rest of the delivery came in on; `reportedOn` the day it was found when not today. 409 `UnknownPoLine` for a SKU not on the order, 409 `PoNotAuthorised` on a draft or cancelled order. Appends `purchasing.receipt-issue-recorded`, and `purchasing.supplier-alert-raised` when the supplier's damage rate crosses the tenant's threshold. `issueId`, a caller-minted `rci_…`, is required and is the idempotency key: a retry with the same id is acknowledged and appends nothing.\n\nRequires `receiving:write` or `purchasing:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecordReceiptIssueEncoded"},"example":{"issueId":"rci_01a1586b-3d5f-7e62-8c4b-3f5a7b9d1e2f","receiptId":"rcpt_01a15864-bc4f-7f80-b1c3-5d6e7f809a1b","lines":[{"sku":"WIDGET-BLUE","condition":"damaged","quantity":2,"reason":"Carton crushed in transit"}]}}},"required":true},"x-mcp-tool":{"name":"purchasing_report_receipt_issue","title":"Purchasing: Report receipt issue","toolset":"receiving","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["receiving:write","purchasing:write"],"x-example-source":{"origin":"contract"}}},"/pos/{poId}/shipments/{shipmentId}":{"put":{"tags":["pos"],"operationId":"pos.shipment","parameters":[{"name":"poId","in":"path","schema":{"$ref":"#/components/schemas/PoId"},"required":true,"example":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d"},{"name":"shipmentId","in":"path","schema":{"$ref":"#/components/schemas/IbsId"},"required":true,"example":"ibs_01a1586a-7c2e-7d41-9b3a-2e4f6a8c0d1e"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"PurchaseOrder","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PurchaseOrderEncoded"},"examples":{"contract":{"summary":"pos.shipment","value":{"id":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d","number":"PO-00001","serial":1,"reference":"PO-WIDGET-BLUE","supplier":"Northwind Components","supplierId":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","currency":"AUD","status":"authorised","lines":[{"sku":"WIDGET-BLUE","ordered":40,"received":0,"cancelled":0,"unitCostCents":1250}],"landedCosts":[],"payables":[],"payments":[],"revision":0,"createdAt":"2026-09-22T01:15:00.000Z","updatedAt":"2026-09-28T06:00:00.000Z","expectedOn":"2026-10-01","shipments":[{"shipmentId":"ibs_01a1586a-7c2e-7d41-9b3a-2e4f6a8c0d1e","carrier":"StarTrack","service":"Road Express","trackingNumbers":["ST4471093"],"dispatchedOn":"2026-09-28","eta":"2026-10-01","firstEta":"2026-10-01","source":"supplier","lines":[{"sku":"WIDGET-BLUE","quantity":40}],"status":"in-transit","events":[],"receiptIds":[]}]}}}}}},"400":{"description":"DayInFuture","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DayInFutureEncoded"}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"PoNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PoNotFoundEncoded"}}}},"409":{"description":"PoNotAuthorised | UnknownPoLine | MirroredFromSource","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/PoNotAuthorisedEncoded"},{"$ref":"#/components/schemas/UnknownPoLineEncoded"},{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}]}}}},"502":{"description":"InventoryUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InventoryUnavailableEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Record an inbound shipment carrying goods of the order — or correct one already recorded (replace semantics): the `carrier` (shipping provider) and `service`, its `trackingNumbers`, `dispatchedOn`, the `eta`, what it holds (`lines`) and who said so (`source`: the `buyer` — often from pasted tracking —, the `supplier`'s advance shipping notice, or a shipping `app`). An order may arrive in several shipments; a receipt names the one it took in. Its tracking events and the receipts that took it in are kept across a correction, and its first ETA is what the carrier's lateness is measured against. 409 `PoNotAuthorised` unless the order is with its supplier and still owed goods (a recorded shipment may be corrected while it is), 409 `UnknownPoLine` for a line it does not have. Appends `purchasing.inbound-shipment-recorded`. Idempotent by content: saying what the shipment already says appends nothing; `shipmentId`, a caller-minted `ibs_…` in the path, names it.\n\nRequires `purchasing:write` or `receiving:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecordInboundShipmentEncoded"},"example":{"carrier":"StarTrack","service":"Road Express","trackingNumbers":["ST4471093"],"dispatchedOn":"2026-09-28","eta":"2026-10-01","source":"supplier","lines":[{"sku":"WIDGET-BLUE","quantity":40}]}}},"required":true},"x-mcp-tool":{"name":"purchasing_record_inbound_shipment","title":"Purchasing: Record inbound shipment","toolset":"receiving","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["purchasing:write","receiving:write"],"x-example-source":{"origin":"contract"}}},"/pos/{poId}/shipments/{shipmentId}/tracking":{"post":{"tags":["pos"],"operationId":"pos.tracking","parameters":[{"name":"poId","in":"path","schema":{"$ref":"#/components/schemas/PoId"},"required":true,"example":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d"},{"name":"shipmentId","in":"path","schema":{"$ref":"#/components/schemas/IbsId"},"required":true,"example":"ibs_01a1586a-7c2e-7d41-9b3a-2e4f6a8c0d1e"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"PurchaseOrder","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PurchaseOrderEncoded"},"examples":{"contract":{"summary":"pos.tracking","value":{"id":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d","number":"PO-00001","serial":1,"reference":"PO-WIDGET-BLUE","supplier":"Northwind Components","supplierId":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","currency":"AUD","status":"authorised","lines":[{"sku":"WIDGET-BLUE","ordered":40,"received":0,"cancelled":0,"unitCostCents":1250}],"landedCosts":[],"payables":[],"payments":[],"revision":0,"createdAt":"2026-09-22T01:15:00.000Z","updatedAt":"2026-09-30T21:12:00.000Z","expectedOn":"2026-10-01","shipments":[{"shipmentId":"ibs_01a1586a-7c2e-7d41-9b3a-2e4f6a8c0d1e","carrier":"StarTrack","service":"Road Express","trackingNumbers":["ST4471093"],"dispatchedOn":"2026-09-28","eta":"2026-10-01","firstEta":"2026-10-01","source":"supplier","lines":[{"sku":"WIDGET-BLUE","quantity":40}],"status":"out-for-delivery","events":[{"at":"2026-09-30T21:10:00.000Z","status":"out-for-delivery","location":"Brisbane depot"}],"receiptIds":[]}]}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"PoNotFound | UnknownInboundShipment","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/PoNotFoundEncoded"},{"$ref":"#/components/schemas/UnknownInboundShipmentEncoded"}]}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"502":{"description":"InventoryUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InventoryUnavailableEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Record what the carrier said about an inbound shipment — by a person, or by a shipping app that polls or hears the carrier for the tenant: its tracking `events` (each a moment, a status, and optionally a description and location) and its `eta`. The shipment stands where its latest event says, unless a receipt already took it in; a `delivered` event sets its delivery day when no receipt did. 404 `UnknownInboundShipment` for a shipment the order does not have. Appends `purchasing.inbound-tracking-recorded`. Idempotent by content: events already held (the same moment and status) and an unchanged ETA append nothing.\n\nRequires `purchasing:write` or `receiving:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecordInboundTrackingEncoded"},"example":{"events":[{"at":"2026-09-30T21:10:00.000Z","status":"out-for-delivery","location":"Brisbane depot"}],"eta":"2026-10-01"}}},"required":true},"x-mcp-tool":{"name":"purchasing_record_inbound_tracking","title":"Purchasing: Record inbound tracking","toolset":"receiving","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["purchasing:write","receiving:write"],"x-example-source":{"origin":"contract"}}},"/supplier-performance":{"get":{"tags":["pos"],"operationId":"pos.scorecard","parameters":[{"name":"windowDays","in":"query","schema":{"anyOf":[{"type":"string"},{"type":"null"}]},"required":false,"example":"365"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"SupplierScorecard","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SupplierScorecardEncoded"},"examples":{"contract":{"summary":"pos.scorecard","value":{"asOf":"2026-10-29","windowDays":365,"suppliers":[{"supplierKey":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","supplierId":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","supplier":"Northwind Components","orders":11,"receipts":12,"unitsReceived":460,"leadTime":{"sample":12,"medianDays":9,"p80Days":11,"p90Days":13,"minDays":6,"maxDays":15,"driftDays":1},"lateness":{"sample":12,"medianDays":0,"p80Days":2,"p90Days":3,"minDays":-2,"maxDays":5,"driftDays":1},"onTime":{"measured":12,"met":9,"ratePercent":75},"otif":{"measured":10,"met":7,"ratePercent":70},"fillRatePercent":98.5,"damageRatePercent":0.4,"shortRatePercent":1.5,"overRatePercent":0,"wrongItemRatePercent":0,"priceVariancePercent":0.4,"invoiceAccuracy":{"measured":10,"met":9,"ratePercent":90},"score":84.8,"lastReceivedOn":"2026-10-01"}],"carriers":[{"carrier":"StarTrack","shipments":14,"delivered":14,"transit":{"sample":8,"medianDays":3,"p80Days":3,"p90Days":4,"minDays":2,"maxDays":5},"lateness":{"sample":8,"medianDays":0,"p80Days":1,"p90Days":1,"minDays":-1,"maxDays":2},"onTime":{"measured":8,"met":7,"ratePercent":87.5},"damageRatePercent":0.6,"unitsDelivered":610}],"lanes":[{"carrier":"StarTrack","shipments":8,"delivered":8,"transit":{"sample":8,"medianDays":3,"p80Days":3,"p90Days":4,"minDays":2,"maxDays":5},"lateness":{"sample":8,"medianDays":0,"p80Days":1,"p90Days":1,"minDays":-1,"maxDays":2},"onTime":{"measured":8,"met":7,"ratePercent":87.5},"damageRatePercent":0.6,"unitsDelivered":320,"supplierKey":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","supplier":"Northwind Components"}]}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"The supplier scorecard: every supplier with orders in the window (the last `windowDays`, default 365), best first — learned lead time (median, p80, p90, drift), on time against the day promised, on time in full (OTIF), fill rate, damage, short, over and wrong-item rates, price variance between invoice and order, invoice accuracy and a weighted score — with every carrier's transit time, lateness against its first ETA and damage, and each carrier × supplier lane, so a problem can be told to be the supplier's or the shipping provider's. Folded from the orders' receipts, issues and shipments; a rate is absent when nothing was measured.\n\nRequires `purchasing:read`.","x-mcp-tool":{"name":"purchasing_get_supplier_scorecard","title":"Purchasing: Get supplier scorecard","toolset":"reporting","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["purchasing:read"],"x-example-source":{"origin":"contract"}}},"/supplier-performance/{supplierId}":{"get":{"tags":["pos"],"operationId":"pos.supplierPerformance","parameters":[{"name":"supplierId","in":"path","schema":{"$ref":"#/components/schemas/CmpId"},"required":true,"example":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b"},{"name":"windowDays","in":"query","schema":{"anyOf":[{"type":"string"},{"type":"null"}]},"required":false,"example":"365"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"SupplierPerformanceDetail","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SupplierPerformanceDetailEncoded"},"examples":{"contract":{"summary":"pos.supplierPerformance","value":{"asOf":"2026-10-29","windowDays":365,"performance":{"supplierKey":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","supplierId":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","supplier":"Northwind Components","orders":11,"receipts":12,"unitsReceived":460,"leadTime":{"sample":12,"medianDays":9,"p80Days":11,"p90Days":13,"minDays":6,"maxDays":15,"driftDays":1},"lateness":{"sample":12,"medianDays":0,"p80Days":2,"p90Days":3,"minDays":-2,"maxDays":5,"driftDays":1},"onTime":{"measured":12,"met":9,"ratePercent":75},"otif":{"measured":10,"met":7,"ratePercent":70},"fillRatePercent":98.5,"damageRatePercent":0.4,"shortRatePercent":1.5,"overRatePercent":0,"wrongItemRatePercent":0,"priceVariancePercent":0.4,"invoiceAccuracy":{"measured":10,"met":9,"ratePercent":90},"score":84.8,"lastReceivedOn":"2026-10-01"},"skus":[{"sku":"WIDGET-BLUE","leadTime":{"sample":12,"medianDays":9,"p80Days":11,"p90Days":13,"minDays":6,"maxDays":15,"driftDays":1}}],"months":[{"month":"2026-10","receipts":1,"medianLeadDays":9,"onTimeRatePercent":100,"damageRatePercent":0}],"carriers":[{"carrier":"StarTrack","shipments":8,"delivered":8,"transit":{"sample":8,"medianDays":3,"p80Days":3,"p90Days":4,"minDays":2,"maxDays":5},"lateness":{"sample":8,"medianDays":0,"p80Days":1,"p90Days":1,"minDays":-1,"maxDays":2},"onTime":{"measured":8,"met":7,"ratePercent":87.5},"damageRatePercent":0.6,"unitsDelivered":320,"supplierKey":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","supplier":"Northwind Components"}],"arrivals":[{"poId":"po_01a1340f-9980-7c41-9d37-d97a5cec069b","number":"PO-00002","supplier":"Northwind Components","supplierId":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","status":"authorised","expectedOn":"2026-11-04","projectedOn":"2026-11-04","earliestOn":"2026-11-02","latestOn":"2026-11-07","basis":"expected","confidence":"high","risk":"at-risk","sample":12,"outstanding":30}]}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"SupplierHasNoOrders","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SupplierHasNoOrdersEncoded"}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"One supplier's performance in depth: its scorecard row, its learned lead time per SKU, the last twelve months (lead time, on time, damage), the carriers on its goods and the projected arrival of each of its open orders. 404 `SupplierHasNoOrders` for a company no order was placed with.\n\nRequires `purchasing:read`.","x-mcp-tool":{"name":"purchasing_get_supplier_performance","title":"Purchasing: Get supplier performance","toolset":"reporting","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["purchasing:read"],"x-example-source":{"origin":"contract"}}},"/arrivals":{"get":{"tags":["pos"],"operationId":"pos.arrivals","parameters":[],"security":[{"bearer":[]}],"responses":{"200":{"description":"ArrivalsPage","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ArrivalsPageEncoded"},"examples":{"contract":{"summary":"pos.arrivals","value":{"asOf":"2026-10-29","items":[{"poId":"po_01a1340f-9980-7c41-9d37-d97a5cec069b","number":"PO-00002","supplier":"Northwind Components","supplierId":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","status":"authorised","expectedOn":"2026-11-04","projectedOn":"2026-11-04","earliestOn":"2026-11-02","latestOn":"2026-11-07","basis":"expected","confidence":"high","risk":"at-risk","sample":12,"outstanding":30}]}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"When each open purchase order will really arrive: a projected day with a band (`earliestOn`–`latestOn`) and a confidence, standing on (`basis`) an inbound shipment's ETA and its carrier's record of meeting ETAs, else the expected day moved by the supplier's usual lateness, else the day placed plus the supplier's learned lead time — and a `risk`: `overdue`, `at-risk` (the projection or its late end falls after the expected day), `on-track` or `unknown`. Soonest first. What the dashboard's arriving and overdue deliveries read.\n\nRequires `purchasing:read` or `receiving:read`.","x-mcp-tool":{"name":"purchasing_list_arrivals","title":"Purchasing: List arrivals","toolset":"reporting","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["purchasing:read","receiving:read"],"x-example-source":{"origin":"contract"}}},"/restock-eta":{"get":{"tags":["pos"],"operationId":"pos.restockEta","parameters":[{"name":"sku","in":"query","schema":{"$ref":"#/components/schemas/Sku_1"},"required":false},{"name":"skus","in":"query","schema":{"type":"string"},"required":false,"example":"WIDGET-BLUE,WIDGET-RED"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"RestockEtaPage","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RestockEtaPageEncoded"},"examples":{"contract":{"summary":"pos.restockEta","value":{"asOf":"2026-10-29","items":[{"sku":"WIDGET-BLUE","asOf":"2026-10-29","basis":"inbound-po","availableOn":"2026-11-04","earliestOn":"2026-11-02","latestOn":"2026-11-07","daysAway":6,"confidence":"high","supplier":"Northwind Components","supplierId":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","poId":"po_01a1340f-9980-7c41-9d37-d97a5cec069b","poNumber":"PO-00002","inboundUnits":30,"backordered":12},{"sku":"WIDGET-RED","asOf":"2026-10-29","basis":"reorder-lead-time","availableOn":"2026-11-09","earliestOn":"2026-11-05","latestOn":"2026-11-16","daysAway":11,"confidence":"medium","supplier":"Northwind Components","supplierId":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","inboundUnits":0,"leadTime":{"sku":"WIDGET-RED","supplierKey":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","supplierId":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","supplier":"Northwind Components","expectedDays":10.8,"p10Days":7,"p50Days":10,"p80Days":14,"p90Days":18,"skuReceipts":2,"supplierReceipts":14,"effectiveSample":4.6,"skuWeightPercent":38.2,"halfLifeDays":180,"confidence":"medium","factors":["sku-history","supplier-history","recency"],"lastReceivedOn":"2026-09-30"}}]}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"When a unit of each SKU is likely to be in hand (`sku`, or `skus` comma-separated, up to 200): first the earliest open purchase order whose outstanding units are not already taken by the SKU's backorders (`basis: inbound-po`), at its projected arrival — a carrier ETA, the expected day moved by the supplier's lateness, or the SKU's own lead-time estimate from the day placed; else, if ordered today, the lead-time estimate of the SKU's priced supplier, or the soonest supplier (`reorder-lead-time`); else `none`. A lead-time estimate weighs each past delivery by its age (the tenant's `leadTimeHalfLifeDays`) and shrinks a SKU with little history toward its supplier's other SKUs (`leadTime`: expected days, p10/p50/p80/p90, effective sample, the factors used). `availableOn` with its band (`earliestOn`–`latestOn`), `daysAway`, `confidence` and the supplier; `backordered` is what the inbound supply was netted against, absent when inventory did not answer. Precomputed in the background as facts land and daily; a SKU never asked about is computed on the spot.\n\nRequires `purchasing:read` or `products:read`.","x-mcp-tool":{"name":"purchasing_get_restock_eta","title":"Purchasing: Get restock eta","toolset":"orders","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["purchasing:read","products:read"],"x-example-source":{"origin":"contract"}}},"/settings":{"get":{"tags":["settings"],"operationId":"settings.get","parameters":[],"security":[{"bearer":[]}],"responses":{"200":{"description":"PurchasingSettings","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PurchasingSettingsEncoded"},"examples":{"contract":{"summary":"settings.get","value":{"poNumberPrefix":"PO-","nextPoNumber":3,"autoInvoiceOnReceipt":false,"autoClose":false,"shortClose":"cancel-remainder","supplierAlerts":{"damageRatePercent":5,"lateRatePercent":20,"minimumSample":5,"windowDays":90}}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"The tenant's purchasing policy. A tenant that has set nothing gets the manual shape: no automatic invoice, no automatic close, and a short-close that cancels the remainder.\n\nRequires `settings:read`.","x-mcp-tool":{"name":"purchasing_get_settings","title":"Purchasing: Get settings","toolset":"purchasing","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["settings:read"],"x-example-source":{"origin":"contract"}},"put":{"tags":["settings"],"operationId":"settings.set","parameters":[],"security":[{"bearer":[]}],"responses":{"200":{"description":"PurchasingSettings","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PurchasingSettingsEncoded"},"examples":{"contract":{"summary":"settings.set","value":{"poNumberPrefix":"PO-","nextPoNumber":3,"autoInvoiceOnReceipt":false,"autoClose":true,"shortClose":"cancel-remainder","supplierAlerts":{"damageRatePercent":5,"lateRatePercent":20,"minimumSample":5,"windowDays":90}}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Replace the tenant's purchasing policy. Every field is optional and falls back to its default, so a partial body is a whole configuration: `poNumberPrefix` and `nextPoNumber` are what the next order is numbered with (`PO-00042`); the serial only moves forward — a value at or below a number already issued is clamped to the next free one, never applied. `autoInvoiceOnReceipt` records the invoice at PO-line prices the moment an order is received in full; `autoClose` closes an order the moment it is invoiced; `shortClose` is what `close` does with undelivered quantity when the command does not say (`cancel-remainder` or `keep-shortfall`); `supplierAlerts` raises a member alert (`purchasing.supplier-alert-raised`) when a supplier's `damageRatePercent` or `lateRatePercent` reaches its threshold over the last `windowDays`, once `minimumSample` deliveries were measured. Appends `purchasing.settings-configured`. Idempotent by content: a retry that says what the policy already says appends nothing.\n\nRequires `settings:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PurchasingSettingsEncoded"},"example":{"poNumberPrefix":"PO-","nextPoNumber":3,"autoInvoiceOnReceipt":false,"autoClose":true,"shortClose":"cancel-remainder","supplierAlerts":{"damageRatePercent":5,"lateRatePercent":20,"minimumSample":5,"windowDays":90}}}},"required":true},"x-mcp-tool":{"name":"purchasing_set_settings","title":"Purchasing: Set settings","toolset":"purchasing","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["settings:write"],"x-example-source":{"origin":"contract"}}},"/events":{"get":{"tags":["events"],"operationId":"events.list","parameters":[{"name":"since","in":"query","schema":{"type":"string"},"required":false,"example":"2"},{"name":"limit","in":"query","schema":{"type":"string"},"required":false,"example":"500"},{"name":"upTo","in":"query","schema":{"type":"string"},"required":false}],"security":[{"bearer":[]}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"array","items":{"anyOf":[{"$ref":"#/components/schemas/purchasing.po-createdEncoded"},{"$ref":"#/components/schemas/purchasing.po-updatedEncoded"},{"$ref":"#/components/schemas/purchasing.po-expected-changedEncoded"},{"$ref":"#/components/schemas/purchasing.po-cancelledEncoded"},{"$ref":"#/components/schemas/purchasing.po-authorisedEncoded"},{"$ref":"#/components/schemas/purchasing.receipt-requestedEncoded"},{"$ref":"#/components/schemas/purchasing.receipt-recordedEncoded"},{"$ref":"#/components/schemas/purchasing.receipt-refusedEncoded"},{"$ref":"#/components/schemas/purchasing.invoice-authorisedEncoded"},{"$ref":"#/components/schemas/purchasing.landed-cost-allocatedEncoded"},{"$ref":"#/components/schemas/purchasing.cost-recordedEncoded"},{"$ref":"#/components/schemas/purchasing.cost-reversedEncoded"},{"$ref":"#/components/schemas/purchasing.po-closedEncoded"},{"$ref":"#/components/schemas/purchasing.settings-configuredEncoded"},{"$ref":"#/components/schemas/purchasing.supplier-price-setEncoded"},{"$ref":"#/components/schemas/purchasing.supplier-price-removedEncoded"},{"$ref":"#/components/schemas/purchasing.supplier-payment-recordedEncoded"},{"$ref":"#/components/schemas/purchasing.receipt-issue-recordedEncoded"},{"$ref":"#/components/schemas/purchasing.inbound-shipment-recordedEncoded"},{"$ref":"#/components/schemas/purchasing.inbound-tracking-recordedEncoded"},{"$ref":"#/components/schemas/purchasing.supplier-alert-raisedEncoded"}]}},"examples":{"contract":{"summary":"events.list","value":[{"_tag":"purchasing.po-authorised","eventId":"evt_01a12465-9700-7e2b-b08b-c83673208051","txId":"tx_01a12465-9700-7e2b-b08b-c83673208052","tenantId":"org_01a1586e-f9f6-7a8b-9c7d-6e5f4a3b2c1d","sequence":2,"occurredAt":"2026-09-22T01:20:00.000Z","source":"purchasing-manager","version":1,"actor":{"_tag":"user","id":"usr_01a12e7b-6080-7a3c-a1fc-94dbc33aeadb"},"correlationId":"req_01a12465-96f0-7a10-8e1d-4c2b9a7f3e60","payload":{"poId":"po_01a15876-6c9e-7b3a-8c4d-9e0f1a2b3c4d","document":{"number":"PO-00001","reference":"PO-WIDGET-BLUE","currency":"AUD","supplier":{"companyId":"cmp_01a15884-6399-7e5f-8a6b-1c2d3e4f5a6b","name":"Northwind Components"},"lines":[{"sku":"WIDGET-BLUE","name":"Blue widget, 40mm","quantity":40,"unitCostCents":1250}],"totalCents":50000}}}]}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Replay committed purchasing events at-or-after `since` (a journal sequence number), oldest first. Consumers (registry materializers, accounting) catch up here before subscribing to NATS `purchasing.>`. One response is a page: `limit` defaults to 500 and is capped at 5000 (an over-cap request is clamped). Pages are `sequence`-ordered and the boundary is stable — repeat with `since=<last event's sequence + 1>` until a page comes back smaller than `limit` to replay the journal exactly once. `upTo` (inclusive) ends the replay at a sequence instead of the journal's head — with `GET /events/head` it replays the journal as it stood at a moment. Appends nothing: a read of facts already journalled.\n\nRequires `purchasing:read` or `receiving:read`.","x-mcp-withheld":"The journal replay a consumer pages through to build its projection; agents read the projections the list and get tools serve, and the audit trail (`audit_trail`) for history.","x-required-scopes":["purchasing:read","receiving:read"],"x-example-source":{"origin":"contract"}}},"/events/head":{"get":{"tags":["events"],"operationId":"events.head","parameters":[{"name":"at","in":"query","schema":{"type":"string"},"required":true,"example":"2026-10-31T03:00:00.000Z"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"Where a tenant's journal stood at a moment.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JournalHead"},"examples":{"contract":{"summary":"events.head","value":{"at":"2026-10-31T03:00:00.000Z","sequence":9}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"The journal's position at a moment: the last `sequence` the database had recorded for this tenant at `at` (absent when it held nothing yet), by the database's own clock rather than the service's. Replaying with `upTo=<sequence>` then gives the journal exactly as it stood then; a set of heads taken at one `at` is a consistent cut across journals. Appends nothing: a read of facts already journalled.\n\nRequires `purchasing:read` or `receiving:read`.","x-mcp-withheld":"Where a journal stood at a moment, for a consumer cutting journals to replay them as of then; agents read history through the audit trail (`audit_trail`).","x-required-scopes":["purchasing:read","receiving:read"],"x-example-source":{"origin":"contract"}}}},"components":{"schemas":{"CmpId":{"type":"string","pattern":"^cmp_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A cmp-prefixed uuid, e.g. cmp_9f8c1c2e-0000-4000-8000-000000000000"},"Sku":{"type":"string","minLength":1,"pattern":"^\\s*[A-Z0-9](?:[A-Z0-9 ._/-]*[A-Z0-9._/-])?\\s*$","description":"A-Z 0-9 space - _ . / (trimmed, uppercased)"},"PoCurrency":{"type":"string"},"SupplierPriceEncoded":{"type":"object","properties":{"supplierId":{"$ref":"#/components/schemas/CmpId"},"sku":{"$ref":"#/components/schemas/Sku"},"unitCostCents":{"type":"number","minimum":0},"currency":{"$ref":"#/components/schemas/PoCurrency"},"supplierSku":{"type":"string","minLength":1,"maxLength":120},"updatedAt":{"type":"string"}},"required":["supplierId","sku","unitCostCents","currency","updatedAt"],"additionalProperties":false},"SupplierPricePageEncoded":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/SupplierPriceEncoded"}},"total":{"type":"integer","minimum":0},"limit":{"type":"integer","exclusiveMinimum":0},"offset":{"type":"integer","minimum":0}},"required":["items","total","offset"],"additionalProperties":false},"UnauthorizedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["Unauthorized"]},"reason":{"type":"string"}},"required":["_tag","reason"],"additionalProperties":false},"TokenAlreadyUsedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["TokenAlreadyUsed"]},"tokenId":{"type":"string"}},"required":["_tag","tokenId"],"additionalProperties":false},"RequestLogUnavailableEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["RequestLogUnavailable"]},"tokenId":{"type":"string"},"reason":{"type":"string"}},"required":["_tag","tokenId","reason"],"additionalProperties":false},"TenantRequiredEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["TenantRequired"]},"userId":{"type":"string"}},"required":["_tag","userId"],"additionalProperties":false},"ScopeRequiredEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["ScopeRequired"]},"required":{"type":"array","items":{"type":"string"}}},"required":["_tag","required"],"additionalProperties":false},"PlatformAdminRequiredEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["PlatformAdminRequired"]},"userId":{"type":"string"}},"required":["_tag","userId"],"additionalProperties":false},"SubscriptionRequiredEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["SubscriptionRequired"]},"status":{"type":"string"}},"required":["_tag","status"],"additionalProperties":false},"MirroredFromSourceEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["MirroredFromSource"]},"source":{"type":"string"}},"required":["_tag","source"],"additionalProperties":false},"SetSupplierPriceEncoded":{"type":"object","properties":{"unitCostCents":{"type":"number","minimum":0},"currency":{"$ref":"#/components/schemas/PoCurrency"},"supplierSku":{"type":"string","minLength":1,"maxLength":120}},"required":["unitCostCents","currency"],"additionalProperties":false},"BooleanString":{"type":"string","enum":["true","false"],"description":"A boolean as a query string spells it: `true` or `false`."},"PoSortKey":{"type":"string","enum":["number","reference","supplier","status","createdAt","updatedAt"],"description":"The column the purchase-order grid is ordered by"},"SortOrder":{"type":"string","enum":["asc","desc"],"description":"The direction a list is ordered in: `asc` (ascending) or `desc` (descending)"},"PoId":{"type":"string","pattern":"^po_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A po-prefixed uuid, e.g. po_9f8c1c2e-0000-4000-8000-000000000000"},"PoStatus":{"type":"string","enum":["draft","authorised","partially-received","received","invoiced","closed","cancelled"],"description":"Where a purchase order stands: `draft` → `authorised` → `partially-received` → `received` → `invoiced` → `closed`, or `cancelled` before any goods arrived"},"IsoDay":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$","description":"A calendar day, e.g. 2026-03-31"},"ExpectedBasis":{"type":"string","enum":["buyer","learned"],"description":"Where an order's expected day came from: `buyer` — a person said it (what on-time is measured against); `learned` — filled in at authorisation from the supplier's learned lead time (planning, never a promise)"},"Sku_1":{"type":"string","minLength":1,"pattern":"^\\s*[A-Z0-9](?:[A-Z0-9 ._/-]*[A-Z0-9._/-])?\\s*$","description":"A-Z 0-9 space - _ . / (trimmed, uppercased)"},"PoLineEncoded":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku"},"pack":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku_1"},"units":{"type":"integer","exclusiveMinimum":0}},"required":["sku","units"],"additionalProperties":false},"ordered":{"type":"integer","exclusiveMinimum":0},"received":{"type":"integer","minimum":0},"cancelled":{"type":"integer","minimum":0},"unitCostCents":{"type":"number","minimum":0},"confirmedUnitCostCents":{"type":"number","minimum":0}},"required":["sku","ordered","unitCostCents"],"additionalProperties":false},"RcptId":{"type":"string","pattern":"^rcpt_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A rcpt-prefixed uuid, e.g. rcpt_9f8c1c2e-0000-4000-8000-000000000000"},"IbsId":{"type":"string","pattern":"^ibs_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A ibs-prefixed uuid, e.g. ibs_9f8c1c2e-0000-4000-8000-000000000000"},"PoReceiptEncoded":{"type":"object","properties":{"receiptId":{"$ref":"#/components/schemas/RcptId"},"receivedOn":{"$ref":"#/components/schemas/IsoDay"},"shipmentId":{"$ref":"#/components/schemas/IbsId"},"lines":{"type":"array","items":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku"},"quantity":{"type":"integer","exclusiveMinimum":0}},"required":["sku","quantity"],"additionalProperties":false}}},"required":["receiptId","receivedOn","lines"],"additionalProperties":false},"RciId":{"type":"string","pattern":"^rci_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A rci-prefixed uuid, e.g. rci_9f8c1c2e-0000-4000-8000-000000000000"},"ReceiptCondition":{"type":"string","enum":["damaged","short","over","wrong-item"],"description":"What was wrong with part of a delivery; the units it names were not taken into stock. `damaged` — arrived broken or unusable; `short` — fewer arrived than the supplier's paperwork said; `over` — more arrived than the order wanted, not accepted; `wrong-item` — something other than the line's SKU came instead"},"ReceiptIssueLine":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku"},"condition":{"$ref":"#/components/schemas/ReceiptCondition"},"quantity":{"type":"integer","exclusiveMinimum":0},"reason":{"type":"string","maxLength":500}},"required":["sku","condition","quantity"],"additionalProperties":false},"ReceiptIssueEncoded":{"type":"object","properties":{"issueId":{"$ref":"#/components/schemas/RciId"},"receiptId":{"$ref":"#/components/schemas/RcptId"},"shipmentId":{"$ref":"#/components/schemas/IbsId"},"reportedOn":{"$ref":"#/components/schemas/IsoDay"},"lines":{"type":"array","items":{"$ref":"#/components/schemas/ReceiptIssueLine"}}},"required":["issueId","reportedOn","lines"],"additionalProperties":false},"CarrierNameEncoded":{"type":"string"},"TrackingNumberEncoded":{"type":"string"},"InboundShipmentSource":{"type":"string","enum":["buyer","supplier","app"],"description":"Who told purchasing about an inbound shipment: `buyer` — a person entered it (often by pasting tracking); `supplier` — the supplier's advance shipping notice (ASN); `app` — a shipping app the tenant installed"},"InboundShipmentLine":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku"},"quantity":{"type":"integer","exclusiveMinimum":0}},"required":["sku","quantity"],"additionalProperties":false},"InboundShipmentStatus":{"type":"string","enum":["announced","in-transit","out-for-delivery","delivered","exception"],"description":"Where an inbound shipment stands: `announced` — booked or notified, not yet moving; `in-transit`; `out-for-delivery`; `delivered` — the carrier says so, or a receipt named it; `exception` — the carrier reports a problem (held, damaged, returned)"},"TrackingEventEncoded":{"type":"object","properties":{"at":{"type":"string"},"status":{"$ref":"#/components/schemas/InboundShipmentStatus"},"description":{"type":"string"},"location":{"type":"string"}},"required":["at","status"],"additionalProperties":false},"InboundShipmentEncoded":{"type":"object","properties":{"shipmentId":{"$ref":"#/components/schemas/IbsId"},"carrier":{"$ref":"#/components/schemas/CarrierNameEncoded"},"service":{"type":"string","minLength":1},"trackingNumbers":{"type":"array","items":{"$ref":"#/components/schemas/TrackingNumberEncoded"}},"dispatchedOn":{"$ref":"#/components/schemas/IsoDay"},"eta":{"$ref":"#/components/schemas/IsoDay"},"firstEta":{"$ref":"#/components/schemas/IsoDay"},"source":{"$ref":"#/components/schemas/InboundShipmentSource"},"lines":{"type":"array","items":{"$ref":"#/components/schemas/InboundShipmentLine"}},"status":{"$ref":"#/components/schemas/InboundShipmentStatus"},"events":{"type":"array","items":{"$ref":"#/components/schemas/TrackingEventEncoded"}},"receiptIds":{"type":"array","items":{"$ref":"#/components/schemas/RcptId"}},"deliveredOn":{"$ref":"#/components/schemas/IsoDay"}},"required":["shipmentId","carrier","source","status"],"additionalProperties":false},"CurrencyCode":{"type":"string"},"LandedCostLine":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku"},"quantity":{"type":"integer","exclusiveMinimum":0},"amountCents":{"type":"integer","minimum":0}},"required":["sku","quantity","amountCents"],"additionalProperties":false},"LandedCostEncoded":{"type":"object","properties":{"amountCents":{"type":"integer","exclusiveMinimum":0},"currency":{"$ref":"#/components/schemas/CurrencyCode"},"description":{"type":"string","minLength":1},"reference":{"type":"string","minLength":1},"lines":{"type":"array","items":{"$ref":"#/components/schemas/LandedCostLine"}}},"required":["amountCents","currency","description","reference","lines"],"additionalProperties":false},"CostId":{"type":"string","pattern":"^cost_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A cost-prefixed uuid, e.g. cost_9f8c1c2e-0000-4000-8000-000000000000"},"Currency":{"type":"string"},"FxCaptureSource":{"type":"string","enum":["rba","rbnz","ecb","boe","fed","boc","norges-bank","nationalbanken","actual","same"],"description":"Where a captured rate came from: a central bank (`rba`, `rbnz`, `ecb`, `boe`, `fed`, `boc`, `norges-bank`, `nationalbanken`), `actual` (the counterparty's own figure for what the money became) or `same` (the document is in the home currency, rate 1)"},"FxCapture":{"type":"object","properties":{"currency":{"$ref":"#/components/schemas/Currency"},"home":{"$ref":"#/components/schemas/Currency"},"rate":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"rateDate":{"$ref":"#/components/schemas/IsoDay"},"source":{"$ref":"#/components/schemas/FxCaptureSource"},"via":{"$ref":"#/components/schemas/Currency"}},"required":["currency","home","rate","rateDate","source"],"additionalProperties":false,"description":"The rate a money fact was booked at, captured when it committed: `rate` units of `home` per one unit of the document's `currency`, from `source` for `rateDate` (`via` a cross); `same` is a document in the home currency, rate 1"},"AccountCodeEncoded":{"anyOf":[{"type":"string"},{"type":"integer"}]},"UsrId":{"type":"string","pattern":"^usr_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A usr-prefixed uuid, e.g. usr_9f8c1c2e-0000-4000-8000-000000000000"},"AppId":{"type":"string","pattern":"^app_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A app-prefixed uuid, e.g. app_9f8c1c2e-0000-4000-8000-000000000000"},"InsId":{"type":"string","pattern":"^ins_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A ins-prefixed uuid, e.g. ins_9f8c1c2e-0000-4000-8000-000000000000"},"CplId":{"type":"string","pattern":"^cpl_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A cpl-prefixed uuid, e.g. cpl_9f8c1c2e-0000-4000-8000-000000000000"},"Actor":{"anyOf":[{"type":"object","properties":{"_tag":{"type":"string","enum":["user"]},"id":{"$ref":"#/components/schemas/UsrId"},"impersonatedBy":{"type":"string","minLength":1},"viaPartner":{"type":"string","minLength":1}},"required":["_tag","id"],"additionalProperties":false},{"type":"object","properties":{"_tag":{"type":"string","enum":["system"]},"id":{"type":"string","minLength":1}},"required":["_tag","id"],"additionalProperties":false},{"type":"object","properties":{"_tag":{"type":"string","enum":["app"]},"id":{"$ref":"#/components/schemas/AppId"},"installationId":{"$ref":"#/components/schemas/InsId"}},"required":["_tag","id","installationId"],"additionalProperties":false},{"type":"object","properties":{"_tag":{"type":"string","enum":["customer"]},"id":{"$ref":"#/components/schemas/CplId"}},"required":["_tag","id"],"additionalProperties":false}]},"Actor_1":{"anyOf":[{"type":"object","properties":{"_tag":{"type":"string","enum":["user"]},"id":{"$ref":"#/components/schemas/UsrId"},"impersonatedBy":{"type":"string","minLength":1},"viaPartner":{"type":"string","minLength":1}},"required":["_tag","id"],"additionalProperties":false},{"type":"object","properties":{"_tag":{"type":"string","enum":["system"]},"id":{"type":"string","minLength":1}},"required":["_tag","id"],"additionalProperties":false},{"type":"object","properties":{"_tag":{"type":"string","enum":["app"]},"id":{"$ref":"#/components/schemas/AppId"},"installationId":{"$ref":"#/components/schemas/InsId"}},"required":["_tag","id","installationId"],"additionalProperties":false},{"type":"object","properties":{"_tag":{"type":"string","enum":["customer"]},"id":{"$ref":"#/components/schemas/CplId"}},"required":["_tag","id"],"additionalProperties":false}]},"CostReversal":{"type":"object","properties":{"by":{"$ref":"#/components/schemas/Actor_1"},"at":{"type":"string"},"reason":{"type":"string","minLength":1,"maxLength":500}},"required":["by","at"],"additionalProperties":false},"PoCostEncoded":{"type":"object","properties":{"costId":{"$ref":"#/components/schemas/CostId"},"amountCents":{"type":"integer","exclusiveMinimum":0},"currency":{"$ref":"#/components/schemas/CurrencyCode"},"fx":{"$ref":"#/components/schemas/FxCapture"},"reason":{"type":"string","minLength":1,"maxLength":500},"accountCode":{"$ref":"#/components/schemas/AccountCodeEncoded"},"date":{"$ref":"#/components/schemas/IsoDay"},"recordedBy":{"$ref":"#/components/schemas/Actor"},"recordedAt":{"type":"string"},"reversal":{"$ref":"#/components/schemas/CostReversal"},"sku":{"$ref":"#/components/schemas/Sku_1"},"capitalised":{"type":"boolean"},"lines":{"type":"array","items":{"$ref":"#/components/schemas/LandedCostLine"}}},"required":["costId","amountCents","currency","fx","reason","accountCode","date","recordedBy","recordedAt","capitalised","lines"],"additionalProperties":false},"PoPayableEncoded":{"type":"object","properties":{"currency":{"$ref":"#/components/schemas/PoCurrency"},"billedCents":{"type":"integer","minimum":0},"paidCents":{"type":"integer","minimum":0}},"required":["currency","billedCents","paidCents"],"additionalProperties":false},"SpayId":{"type":"string","pattern":"^spay_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A spay-prefixed uuid, e.g. spay_9f8c1c2e-0000-4000-8000-000000000000"},"PoPaymentEncoded":{"type":"object","properties":{"paymentId":{"$ref":"#/components/schemas/SpayId"},"currency":{"$ref":"#/components/schemas/PoCurrency"},"amountCents":{"type":"integer","exclusiveMinimum":0},"paidOn":{"$ref":"#/components/schemas/IsoDay"}},"required":["paymentId","currency","amountCents","paidOn"],"additionalProperties":false},"PurchaseOrderEncoded":{"type":"object","properties":{"id":{"$ref":"#/components/schemas/PoId"},"number":{"type":"string","minLength":1},"serial":{"type":"integer","exclusiveMinimum":0},"reference":{"type":"string","minLength":1},"supplier":{"type":"string","minLength":1},"supplierId":{"$ref":"#/components/schemas/CmpId"},"currency":{"$ref":"#/components/schemas/PoCurrency"},"status":{"$ref":"#/components/schemas/PoStatus"},"expectedOn":{"$ref":"#/components/schemas/IsoDay"},"expectedBasis":{"$ref":"#/components/schemas/ExpectedBasis"},"promisedOn":{"$ref":"#/components/schemas/IsoDay"},"placedOn":{"$ref":"#/components/schemas/IsoDay"},"authorisedOn":{"$ref":"#/components/schemas/IsoDay"},"lines":{"type":"array","items":{"$ref":"#/components/schemas/PoLineEncoded"}},"receipts":{"type":"array","items":{"$ref":"#/components/schemas/PoReceiptEncoded"}},"issues":{"type":"array","items":{"$ref":"#/components/schemas/ReceiptIssueEncoded"}},"shipments":{"type":"array","items":{"$ref":"#/components/schemas/InboundShipmentEncoded"}},"landedCosts":{"type":"array","items":{"$ref":"#/components/schemas/LandedCostEncoded"}},"costs":{"type":"array","items":{"$ref":"#/components/schemas/PoCostEncoded"}},"payables":{"type":"array","items":{"$ref":"#/components/schemas/PoPayableEncoded"}},"payments":{"type":"array","items":{"$ref":"#/components/schemas/PoPaymentEncoded"}},"invoicedAt":{"type":"string"},"closedAt":{"type":"string"},"revision":{"type":"integer","minimum":0},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","number","serial","reference","supplier","currency","status","lines","createdAt","updatedAt"],"additionalProperties":false},"PurchaseOrderPageEncoded":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/PurchaseOrderEncoded"}},"total":{"type":"integer","minimum":0},"limit":{"type":"integer","exclusiveMinimum":0},"offset":{"type":"integer","minimum":0}},"required":["items","total","offset"],"additionalProperties":false},"IncomingStockEncoded":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku"},"poId":{"$ref":"#/components/schemas/PoId"},"poNumber":{"type":"string","minLength":1},"quantity":{"type":"integer","exclusiveMinimum":0},"expectedOn":{"$ref":"#/components/schemas/IsoDay"}},"required":["sku","poId","poNumber","quantity"],"additionalProperties":false},"IncomingStockListEncoded":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/IncomingStockEncoded"}}},"required":["items"],"additionalProperties":false},"PoNotFoundEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["PoNotFound"]},"poId":{"type":"string"}},"required":["_tag","poId"],"additionalProperties":false},"CreatePurchaseOrderEncoded":{"type":"object","properties":{"reference":{"type":"string","minLength":1},"supplier":{"type":"string","minLength":1},"supplierId":{"$ref":"#/components/schemas/CmpId"},"currency":{"$ref":"#/components/schemas/PoCurrency"},"expectedOn":{"$ref":"#/components/schemas/IsoDay"},"placedOn":{"$ref":"#/components/schemas/IsoDay"},"lines":{"type":"array","items":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku"},"quantity":{"type":"integer","exclusiveMinimum":0},"unitCostCents":{"type":"number","minimum":0}},"required":["sku","quantity"],"additionalProperties":false},"minItems":1}},"required":["reference","supplier","lines"],"additionalProperties":false},"LineUncostedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["LineUncosted"]},"skus":{"type":"array","items":{"type":"string"}}},"required":["_tag","skus"],"additionalProperties":false},"KitNotBuyableEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["KitNotBuyable"]},"sku":{"type":"string"},"reason":{"type":"string"}},"required":["_tag","sku","reason"],"additionalProperties":false},"StockSkuOnTwoLinesEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["StockSkuOnTwoLines"]},"sku":{"type":"string"},"lines":{"type":"array","items":{"type":"string"}}},"required":["_tag","sku","lines"],"additionalProperties":false},"InventoryUnavailableEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["InventoryUnavailable"]},"reason":{"type":"string"}},"required":["_tag","reason"],"additionalProperties":false},"DayInFutureEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["DayInFuture"]},"day":{"type":"string"},"today":{"type":"string"}},"required":["_tag","day","today"],"additionalProperties":false},"UpdatePurchaseOrderEncoded":{"type":"object","properties":{"supplier":{"type":"string","minLength":1},"supplierId":{"anyOf":[{"$ref":"#/components/schemas/CmpId"},{"type":"null"}]},"lines":{"type":"array","items":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku_1"},"quantity":{"type":"integer","exclusiveMinimum":0},"unitCostCents":{"type":"number","minimum":0}},"required":["sku","quantity"],"additionalProperties":false},"minItems":1}},"additionalProperties":false},"ItemNotFoundEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["ItemNotFound"]},"sku":{"type":"string"}},"required":["_tag","sku"],"additionalProperties":false},"PoNotEditableEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["PoNotEditable"]},"poId":{"type":"string"},"status":{"$ref":"#/components/schemas/PoStatus"}},"required":["_tag","poId","status"],"additionalProperties":false},"PoLineReceivedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["PoLineReceived"]},"poId":{"type":"string"},"sku":{"type":"string"},"received":{"type":"integer"},"requested":{"type":"integer"}},"required":["_tag","poId","sku","received","requested"],"additionalProperties":false},"SetPoExpectedEncoded":{"type":"object","properties":{"expectedOn":{"anyOf":[{"$ref":"#/components/schemas/IsoDay"},{"type":"null"}]}},"required":["expectedOn"],"additionalProperties":false},"PoHasReceiptsEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["PoHasReceipts"]},"poId":{"type":"string"},"status":{"$ref":"#/components/schemas/PoStatus"}},"required":["_tag","poId","status"],"additionalProperties":false},"PoNotDraftEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["PoNotDraft"]},"poId":{"type":"string"},"status":{"$ref":"#/components/schemas/PoStatus"}},"required":["_tag","poId","status"],"additionalProperties":false},"LocId":{"type":"string","pattern":"^loc_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A loc-prefixed uuid, e.g. loc_9f8c1c2e-0000-4000-8000-000000000000"},"SerialNumber":{"type":"string","minLength":1,"maxLength":64},"BatchNumber":{"type":"string","minLength":1,"maxLength":64},"ReceiptLine":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku"},"quantity":{"type":"integer","exclusiveMinimum":0},"serials":{"type":"array","items":{"$ref":"#/components/schemas/SerialNumber"},"minItems":1},"batchNumber":{"$ref":"#/components/schemas/BatchNumber"},"expiresAt":{"type":"string"}},"required":["sku","quantity"],"additionalProperties":false},"RecordReceiptEncoded":{"type":"object","properties":{"receiptId":{"$ref":"#/components/schemas/RcptId"},"locationId":{"$ref":"#/components/schemas/LocId"},"receivedOn":{"$ref":"#/components/schemas/IsoDay"},"shipmentId":{"$ref":"#/components/schemas/IbsId"},"lines":{"type":"array","prefixItems":[{"$ref":"#/components/schemas/ReceiptLine"}],"minItems":1,"items":{"$ref":"#/components/schemas/ReceiptLine"}}},"required":["receiptId","lines"],"additionalProperties":false},"UnknownInboundShipmentEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["UnknownInboundShipment"]},"poId":{"type":"string"},"shipmentId":{"type":"string"}},"required":["_tag","poId","shipmentId"],"additionalProperties":false},"PoNotAuthorisedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["PoNotAuthorised"]},"poId":{"type":"string"},"status":{"$ref":"#/components/schemas/PoStatus"}},"required":["_tag","poId","status"],"additionalProperties":false},"UnknownPoLineEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["UnknownPoLine"]},"poId":{"type":"string"},"sku":{"type":"string"}},"required":["_tag","poId","sku"],"additionalProperties":false},"OverReceiptEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["OverReceipt"]},"poId":{"type":"string"},"sku":{"type":"string"},"ordered":{"type":"integer"},"previouslyReceived":{"type":"integer"},"requested":{"type":"integer"}},"required":["_tag","poId","sku","ordered","previouslyReceived","requested"],"additionalProperties":false},"SerialAlreadyRegisteredEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["SerialAlreadyRegistered"]},"sku":{"type":"string"},"serials":{"type":"array","items":{"$ref":"#/components/schemas/SerialNumber"}}},"required":["_tag","sku","serials"],"additionalProperties":false},"Tracking":{"type":"string","enum":["none","serial","batch"],"description":"How a SKU's units are identified: `none` — bare quantities; `serial` — one serial number per unit; `batch` — one batch (lot) number per lot"},"TrackingMismatchEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["TrackingMismatch"]},"sku":{"type":"string"},"tracking":{"$ref":"#/components/schemas/Tracking"},"reason":{"type":"string"}},"required":["_tag","sku","tracking","reason"],"additionalProperties":false},"ReceiptPendingEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["ReceiptPending"]},"poId":{"$ref":"#/components/schemas/PoId"},"receiptId":{"$ref":"#/components/schemas/RcptId"},"reason":{"type":"string"}},"required":["_tag","poId","receiptId","reason"],"additionalProperties":false},"AuthoriseInvoiceEncoded":{"type":"object","properties":{"lines":{"type":"array","items":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku"},"unitCostCents":{"type":"number","minimum":0}},"required":["sku","unitCostCents"],"additionalProperties":false},"minItems":1}},"required":["lines"],"additionalProperties":false},"PoAlreadyInvoicedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["PoAlreadyInvoiced"]},"poId":{"type":"string"}},"required":["_tag","poId"],"additionalProperties":false},"AllocateLandedCostEncoded":{"type":"object","properties":{"amountCents":{"type":"integer","exclusiveMinimum":0},"currency":{"$ref":"#/components/schemas/PoCurrency"},"description":{"type":"string","minLength":1},"reference":{"type":"string","minLength":1},"lines":{"type":"array","prefixItems":[{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku_1"},"quantity":{"type":"integer","exclusiveMinimum":0}},"required":["sku"],"additionalProperties":false}],"minItems":1,"items":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku_1"},"quantity":{"type":"integer","exclusiveMinimum":0}},"required":["sku"],"additionalProperties":false}}},"required":["amountCents","description","reference"],"additionalProperties":false},"LandedCostExceedsLineEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["LandedCostExceedsLine"]},"poId":{"$ref":"#/components/schemas/PoId"},"sku":{"$ref":"#/components/schemas/Sku"},"quantity":{"type":"integer","exclusiveMinimum":0},"available":{"type":"integer","minimum":0}},"required":["_tag","poId","sku","quantity","available"],"additionalProperties":false},"RecordPoCostEncoded":{"type":"object","properties":{"costId":{"$ref":"#/components/schemas/CostId"},"amountCents":{"type":"integer","exclusiveMinimum":0},"currency":{"$ref":"#/components/schemas/CurrencyCode"},"reason":{"type":"string","minLength":1,"maxLength":500},"accountCode":{"$ref":"#/components/schemas/AccountCodeEncoded"},"date":{"$ref":"#/components/schemas/IsoDay"},"sku":{"$ref":"#/components/schemas/Sku_1"},"capitalise":{"type":"boolean"}},"required":["costId","amountCents","reason","accountCode"],"additionalProperties":false},"AccountNotPostableEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["AccountNotPostable"]},"accountCode":{"type":"string"},"reason":{"type":"string"}},"required":["_tag","accountCode","reason"],"additionalProperties":false},"CostCurrencyRefusedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["CostCurrencyRefused"]},"currency":{"type":"string"},"allowed":{"type":"array","items":{"type":"string"}}},"required":["_tag","currency","allowed"],"additionalProperties":false},"NothingReceivedToCapitaliseEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["NothingReceivedToCapitalise"]},"poId":{"type":"string"},"sku":{"type":"string"}},"required":["_tag","poId"],"additionalProperties":false},"ReverseCostEncoded":{"type":"object","properties":{"reason":{"type":"string","minLength":1,"maxLength":500}},"additionalProperties":false},"CostNotFoundEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["CostNotFound"]},"costId":{"type":"string"}},"required":["_tag","costId"],"additionalProperties":false},"SupplierPaymentMethod":{"type":"string","enum":["bank-transfer","card","cheque","cash","direct-debit","other"],"description":"How money was paid to a supplier: `bank-transfer` (an EFT, a wire), `card`, `cheque`, `cash`, `direct-debit` (the supplier drew it), or `other`"},"SupplierPaymentAllocation":{"type":"object","properties":{"poId":{"$ref":"#/components/schemas/PoId"},"amountCents":{"type":"integer","exclusiveMinimum":0}},"required":["poId","amountCents"],"additionalProperties":false},"SupplierPaymentEncoded":{"type":"object","properties":{"paymentId":{"$ref":"#/components/schemas/SpayId"},"supplier":{"type":"string","minLength":1},"supplierId":{"$ref":"#/components/schemas/CmpId"},"currency":{"$ref":"#/components/schemas/PoCurrency"},"amountCents":{"type":"integer","exclusiveMinimum":0},"paidOn":{"$ref":"#/components/schemas/IsoDay"},"method":{"$ref":"#/components/schemas/SupplierPaymentMethod"},"remittance":{"type":"string","minLength":1},"fx":{"$ref":"#/components/schemas/FxCapture"},"allocations":{"type":"array","prefixItems":[{"$ref":"#/components/schemas/SupplierPaymentAllocation"}],"minItems":1,"items":{"$ref":"#/components/schemas/SupplierPaymentAllocation"}},"recordedAt":{"type":"string"}},"required":["paymentId","supplier","currency","amountCents","paidOn","method","fx","allocations","recordedAt"],"additionalProperties":false},"SupplierPaymentPageEncoded":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/SupplierPaymentEncoded"}},"total":{"type":"integer","minimum":0},"limit":{"type":"integer","exclusiveMinimum":0},"offset":{"type":"integer","minimum":0}},"required":["items","total","offset"],"additionalProperties":false},"RecordSupplierPaymentEncoded":{"type":"object","properties":{"paymentId":{"$ref":"#/components/schemas/SpayId"},"currency":{"$ref":"#/components/schemas/PoCurrency"},"allocations":{"type":"array","prefixItems":[{"$ref":"#/components/schemas/SupplierPaymentAllocation"}],"minItems":1,"items":{"$ref":"#/components/schemas/SupplierPaymentAllocation"}},"method":{"$ref":"#/components/schemas/SupplierPaymentMethod"},"homeAmountCents":{"type":"integer","exclusiveMinimum":0},"paidOn":{"$ref":"#/components/schemas/IsoDay"},"remittance":{"type":"string","minLength":1,"maxLength":120}},"required":["paymentId","currency","allocations","method"],"additionalProperties":false},"SupplierOverpaymentEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["SupplierOverpayment"]},"poId":{"$ref":"#/components/schemas/PoId"},"currency":{"type":"string"},"outstandingCents":{"type":"integer","minimum":0},"requestedCents":{"type":"integer","exclusiveMinimum":0}},"required":["_tag","poId","currency","outstandingCents","requestedCents"],"additionalProperties":false},"SupplierPaymentMixesSuppliersEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["SupplierPaymentMixesSuppliers"]},"poIds":{"type":"array","items":{"$ref":"#/components/schemas/PoId"}}},"required":["_tag","poIds"],"additionalProperties":false},"SupplierPaymentHomeMismatchEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["SupplierPaymentHomeMismatch"]},"amountCents":{"type":"integer","exclusiveMinimum":0},"homeAmountCents":{"type":"integer","exclusiveMinimum":0}},"required":["_tag","amountCents","homeAmountCents"],"additionalProperties":false},"RemainderDecision":{"type":"string","enum":["cancel","keep"],"description":"What a close asks of undelivered quantity: `cancel` — inventory stops expecting it; `keep` — the shortfall stays on the lines for supplier follow-up"},"ClosePurchaseOrderEncoded":{"type":"object","properties":{"remainder":{"$ref":"#/components/schemas/RemainderDecision"},"reason":{"type":"string","minLength":1}},"additionalProperties":false},"PoNotClosableEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["PoNotClosable"]},"poId":{"type":"string"},"status":{"$ref":"#/components/schemas/PoStatus"}},"required":["_tag","poId","status"],"additionalProperties":false},"RecordReceiptIssueEncoded":{"type":"object","properties":{"issueId":{"$ref":"#/components/schemas/RciId"},"receiptId":{"$ref":"#/components/schemas/RcptId"},"shipmentId":{"$ref":"#/components/schemas/IbsId"},"reportedOn":{"$ref":"#/components/schemas/IsoDay"},"lines":{"type":"array","prefixItems":[{"$ref":"#/components/schemas/ReceiptIssueLine"}],"minItems":1,"items":{"$ref":"#/components/schemas/ReceiptIssueLine"}}},"required":["issueId","lines"],"additionalProperties":false},"RecordInboundShipmentEncoded":{"type":"object","properties":{"carrier":{"$ref":"#/components/schemas/CarrierNameEncoded"},"service":{"type":"string","minLength":1},"trackingNumbers":{"type":"array","items":{"$ref":"#/components/schemas/TrackingNumberEncoded"}},"dispatchedOn":{"$ref":"#/components/schemas/IsoDay"},"eta":{"$ref":"#/components/schemas/IsoDay"},"source":{"$ref":"#/components/schemas/InboundShipmentSource"},"lines":{"type":"array","items":{"$ref":"#/components/schemas/InboundShipmentLine"}}},"required":["carrier"],"additionalProperties":false},"RecordInboundTrackingEncoded":{"type":"object","properties":{"events":{"type":"array","items":{"$ref":"#/components/schemas/TrackingEventEncoded"}},"eta":{"$ref":"#/components/schemas/IsoDay"}},"required":["events"],"additionalProperties":false},"DayStatsEncoded":{"type":"object","properties":{"sample":{"type":"integer","minimum":0},"medianDays":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"p80Days":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"p90Days":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"minDays":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"maxDays":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"driftDays":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]}},"required":["sample"],"additionalProperties":false},"RateEncoded":{"type":"object","properties":{"measured":{"type":"integer","minimum":0},"met":{"type":"integer","minimum":0},"ratePercent":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]}},"required":["measured","met"],"additionalProperties":false},"SupplierPerformanceEncoded":{"type":"object","properties":{"supplierKey":{"type":"string"},"supplierId":{"$ref":"#/components/schemas/CmpId"},"supplier":{"type":"string"},"orders":{"type":"integer","minimum":0},"receipts":{"type":"integer","minimum":0},"unitsReceived":{"type":"integer","minimum":0},"leadTime":{"$ref":"#/components/schemas/DayStatsEncoded"},"lateness":{"$ref":"#/components/schemas/DayStatsEncoded"},"onTime":{"$ref":"#/components/schemas/RateEncoded"},"otif":{"$ref":"#/components/schemas/RateEncoded"},"fillRatePercent":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"damageRatePercent":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"shortRatePercent":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"overRatePercent":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"wrongItemRatePercent":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"priceVariancePercent":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"invoiceAccuracy":{"$ref":"#/components/schemas/RateEncoded"},"score":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"lastReceivedOn":{"$ref":"#/components/schemas/IsoDay"}},"required":["supplierKey","supplier","orders","receipts","unitsReceived","leadTime","lateness","onTime","otif","invoiceAccuracy"],"additionalProperties":false},"CarrierPerformanceEncoded":{"type":"object","properties":{"carrier":{"type":"string"},"supplierKey":{"type":"string"},"supplier":{"type":"string"},"shipments":{"type":"integer","minimum":0},"delivered":{"type":"integer","minimum":0},"transit":{"$ref":"#/components/schemas/DayStatsEncoded"},"lateness":{"$ref":"#/components/schemas/DayStatsEncoded"},"onTime":{"$ref":"#/components/schemas/RateEncoded"},"damageRatePercent":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"unitsDelivered":{"type":"integer","minimum":0}},"required":["carrier","shipments","delivered","transit","lateness","onTime","unitsDelivered"],"additionalProperties":false},"SupplierScorecardEncoded":{"type":"object","properties":{"asOf":{"$ref":"#/components/schemas/IsoDay"},"windowDays":{"type":"integer","minimum":0},"suppliers":{"type":"array","items":{"$ref":"#/components/schemas/SupplierPerformanceEncoded"}},"carriers":{"type":"array","items":{"$ref":"#/components/schemas/CarrierPerformanceEncoded"}},"lanes":{"type":"array","items":{"$ref":"#/components/schemas/CarrierPerformanceEncoded"}}},"required":["asOf","windowDays","suppliers","carriers","lanes"],"additionalProperties":false},"SkuLeadTimeEncoded":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku"},"leadTime":{"$ref":"#/components/schemas/DayStatsEncoded"}},"required":["sku","leadTime"],"additionalProperties":false},"SupplierMonthEncoded":{"type":"object","properties":{"month":{"type":"string"},"receipts":{"type":"integer","minimum":0},"medianLeadDays":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"onTimeRatePercent":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"damageRatePercent":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]}},"required":["month","receipts"],"additionalProperties":false},"ArrivalBasis":{"type":"string","enum":["carrier-eta","expected","lead-time","none"],"description":"What an arrival projection stands on: `carrier-eta` — an inbound shipment's ETA, banded by that carrier's record of meeting its ETAs; `expected` — the order's expected day, moved by how late the supplier usually is; `lead-time` — the day it was placed plus the supplier's learned lead time; `none` — nothing to project from"},"ProjectionConfidence":{"type":"string","enum":["high","medium","low"],"description":"How far a projection can be trusted: `high` — ten or more past deliveries behind it; `medium` — three or more; `low` — fewer. For a recency-weighted lead-time estimate, deliveries are counted by weight and the spread must be narrow too: `high` — worth eight or more, the 90th percentile within half again of the median; `medium` — worth three or more, within twice it"},"ArrivalRisk":{"type":"string","enum":["overdue","at-risk","on-track","unknown"],"description":"Whether an open order is likely to come when wanted: `overdue` — the expected (else projected) day passed with goods owed; `at-risk` — the projection, or the late end of its band, falls after the expected day; `on-track`; `unknown` — nothing to judge by"},"ArrivalProjectionEncoded":{"type":"object","properties":{"poId":{"$ref":"#/components/schemas/PoId"},"number":{"type":"string"},"supplier":{"type":"string"},"supplierId":{"$ref":"#/components/schemas/CmpId"},"status":{"$ref":"#/components/schemas/PoStatus"},"expectedOn":{"$ref":"#/components/schemas/IsoDay"},"projectedOn":{"$ref":"#/components/schemas/IsoDay"},"earliestOn":{"$ref":"#/components/schemas/IsoDay"},"latestOn":{"$ref":"#/components/schemas/IsoDay"},"basis":{"$ref":"#/components/schemas/ArrivalBasis"},"confidence":{"$ref":"#/components/schemas/ProjectionConfidence"},"risk":{"$ref":"#/components/schemas/ArrivalRisk"},"sample":{"type":"integer","minimum":0},"shipmentId":{"$ref":"#/components/schemas/IbsId"},"carrier":{"type":"string"},"outstanding":{"type":"integer","minimum":0}},"required":["poId","number","supplier","status","basis","risk","sample","outstanding"],"additionalProperties":false},"SupplierPerformanceDetailEncoded":{"type":"object","properties":{"asOf":{"$ref":"#/components/schemas/IsoDay"},"windowDays":{"type":"integer","minimum":0},"performance":{"$ref":"#/components/schemas/SupplierPerformanceEncoded"},"skus":{"type":"array","items":{"$ref":"#/components/schemas/SkuLeadTimeEncoded"}},"months":{"type":"array","items":{"$ref":"#/components/schemas/SupplierMonthEncoded"}},"carriers":{"type":"array","items":{"$ref":"#/components/schemas/CarrierPerformanceEncoded"}},"arrivals":{"type":"array","items":{"$ref":"#/components/schemas/ArrivalProjectionEncoded"}}},"required":["asOf","windowDays","performance","skus","months","carriers","arrivals"],"additionalProperties":false},"SupplierHasNoOrdersEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["SupplierHasNoOrders"]},"supplierId":{"type":"string"}},"required":["_tag","supplierId"],"additionalProperties":false},"ArrivalsPageEncoded":{"type":"object","properties":{"asOf":{"$ref":"#/components/schemas/IsoDay"},"items":{"type":"array","items":{"$ref":"#/components/schemas/ArrivalProjectionEncoded"}}},"required":["asOf","items"],"additionalProperties":false},"RestockBasis":{"type":"string","enum":["inbound-po","reorder-lead-time","none"],"description":"What a restock ETA stands on: `inbound-po` — an open purchase order's outstanding units not already spoken for by backorders, at its projected arrival; `reorder-lead-time` — the best supplier's recency-weighted lead time from today, if ordered today; `none` — no order and no history to project from"},"CmpId_1":{"type":"string","pattern":"^cmp_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A cmp-prefixed uuid, e.g. cmp_9f8c1c2e-0000-4000-8000-000000000000"},"LeadTimeFactor":{"type":"string","enum":["sku-history","supplier-history","recency"],"description":"What a lead-time estimate stands on: `sku-history` — the SKU's own deliveries from the supplier; `supplier-history` — the supplier's deliveries of its other SKUs, the prior a thin history is shrunk toward; `recency` — each delivery weighted by its age at the tenant's half-life"},"IsoDay_1":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$","description":"A calendar day, e.g. 2026-03-31"},"RestockEtaEncoded":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku"},"asOf":{"$ref":"#/components/schemas/IsoDay"},"basis":{"$ref":"#/components/schemas/RestockBasis"},"availableOn":{"$ref":"#/components/schemas/IsoDay"},"earliestOn":{"$ref":"#/components/schemas/IsoDay"},"latestOn":{"$ref":"#/components/schemas/IsoDay"},"daysAway":{"type":"integer","minimum":0},"confidence":{"$ref":"#/components/schemas/ProjectionConfidence"},"supplier":{"type":"string"},"supplierId":{"$ref":"#/components/schemas/CmpId"},"poId":{"$ref":"#/components/schemas/PoId"},"poNumber":{"type":"string"},"inboundUnits":{"type":"integer","minimum":0},"backordered":{"type":"integer","minimum":0},"leadTime":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku_1"},"supplierKey":{"type":"string"},"supplierId":{"$ref":"#/components/schemas/CmpId_1"},"supplier":{"type":"string"},"expectedDays":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"p10Days":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"p50Days":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"p80Days":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"p90Days":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"skuReceipts":{"type":"integer","minimum":0},"supplierReceipts":{"type":"integer","minimum":0},"effectiveSample":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"skuWeightPercent":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"halfLifeDays":{"type":"integer","exclusiveMinimum":0},"confidence":{"$ref":"#/components/schemas/ProjectionConfidence"},"factors":{"type":"array","items":{"$ref":"#/components/schemas/LeadTimeFactor"}},"lastReceivedOn":{"$ref":"#/components/schemas/IsoDay_1"}},"required":["sku","supplierKey","supplier","expectedDays","p10Days","p50Days","p80Days","p90Days","skuReceipts","supplierReceipts","effectiveSample","skuWeightPercent","halfLifeDays","confidence","factors"],"additionalProperties":false}},"required":["sku","asOf","basis","inboundUnits"],"additionalProperties":false},"RestockEtaPageEncoded":{"type":"object","properties":{"asOf":{"$ref":"#/components/schemas/IsoDay"},"items":{"type":"array","items":{"$ref":"#/components/schemas/RestockEtaEncoded"}}},"required":["asOf","items"],"additionalProperties":false},"PoNumberPrefix":{"type":"string","pattern":"^[A-Za-z0-9-]{0,12}$"},"ShortCloseMode":{"type":"string","enum":["cancel-remainder","keep-shortfall"],"description":"What a short-close does with undelivered quantity: `cancel-remainder` — inventory stops expecting it; `keep-shortfall` — it stays on the lines for supplier follow-up"},"SupplierAlertSettingsEncoded":{"type":"object","properties":{"damageRatePercent":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"lateRatePercent":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"minimumSample":{"type":"integer","exclusiveMinimum":0},"windowDays":{"type":"integer","exclusiveMinimum":0}},"additionalProperties":false},"LeadTimeHalfLifeDays":{"type":"integer","minimum":14,"maximum":730,"description":"The half-life of a delivery's weight in a lead-time estimate, in days (14–730; 180 when unset)"},"PurchasingSettingsEncoded":{"type":"object","properties":{"poNumberPrefix":{"$ref":"#/components/schemas/PoNumberPrefix"},"nextPoNumber":{"type":"integer","exclusiveMinimum":0},"autoInvoiceOnReceipt":{"type":"boolean"},"autoClose":{"type":"boolean"},"shortClose":{"$ref":"#/components/schemas/ShortCloseMode"},"supplierAlerts":{"$ref":"#/components/schemas/SupplierAlertSettingsEncoded"},"leadTimeHalfLifeDays":{"$ref":"#/components/schemas/LeadTimeHalfLifeDays"}},"additionalProperties":false},"EvtId":{"type":"string","pattern":"^evt_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A evt-prefixed uuid, e.g. evt_9f8c1c2e-0000-4000-8000-000000000000"},"TxId":{"type":"string","pattern":"^tx_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A tx-prefixed uuid, e.g. tx_9f8c1c2e-0000-4000-8000-000000000000"},"TenantId":{"type":"string","pattern":"^org_(test_)?[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"An org-prefixed uuid, e.g. org_9f8c1c2e-0000-4000-8000-000000000000; a sandbox tenant is org_test_<uuid>"},"purchasing.po-createdEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["purchasing.po-created"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"poId":{"$ref":"#/components/schemas/PoId"},"number":{"type":"string","minLength":1},"serial":{"type":"integer","exclusiveMinimum":0},"reference":{"type":"string","minLength":1},"supplier":{"type":"string","minLength":1},"supplierId":{"$ref":"#/components/schemas/CmpId"},"currency":{"$ref":"#/components/schemas/PoCurrency"},"expectedOn":{"$ref":"#/components/schemas/IsoDay"},"placedOn":{"$ref":"#/components/schemas/IsoDay"},"lines":{"type":"array","items":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku"},"pack":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku_1"},"units":{"type":"integer","exclusiveMinimum":0}},"required":["sku","units"],"additionalProperties":false},"quantity":{"type":"integer","exclusiveMinimum":0},"unitCostCents":{"type":"number","minimum":0}},"required":["sku","quantity","unitCostCents"],"additionalProperties":false}},"fx":{"$ref":"#/components/schemas/FxCapture"}},"required":["poId","number","serial","reference","supplier","currency","lines","fx"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"purchasing.po-updatedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["purchasing.po-updated"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"poId":{"$ref":"#/components/schemas/PoId"},"supplier":{"type":"string","minLength":1},"supplierId":{"$ref":"#/components/schemas/CmpId"},"lines":{"type":"array","items":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku"},"pack":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku_1"},"units":{"type":"integer","exclusiveMinimum":0}},"required":["sku","units"],"additionalProperties":false},"quantity":{"type":"integer","exclusiveMinimum":0},"unitCostCents":{"type":"number","minimum":0}},"required":["sku","quantity","unitCostCents"],"additionalProperties":false}}},"required":["poId","supplier","lines"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"purchasing.po-expected-changedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["purchasing.po-expected-changed"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"poId":{"$ref":"#/components/schemas/PoId"},"expectedOn":{"$ref":"#/components/schemas/IsoDay"},"basis":{"$ref":"#/components/schemas/ExpectedBasis"}},"required":["poId"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"purchasing.po-cancelledEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["purchasing.po-cancelled"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"poId":{"$ref":"#/components/schemas/PoId"},"reason":{"type":"string","minLength":1}},"required":["poId"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"PsnId":{"type":"string","pattern":"^psn_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A psn-prefixed uuid, e.g. psn_9f8c1c2e-0000-4000-8000-000000000000"},"TaxNumber":{"type":"string","minLength":1,"maxLength":60,"pattern":"^\\S(?:.*\\S)?$","description":"A tax registration number (ABN, NZ GST number, VAT number) as the business writes it, up to 60 characters"},"AdrId":{"type":"string","pattern":"^adr_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A adr-prefixed uuid, e.g. adr_9f8c1c2e-0000-4000-8000-000000000000"},"ClocId":{"type":"string","pattern":"^cloc_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A cloc-prefixed uuid, e.g. cloc_9f8c1c2e-0000-4000-8000-000000000000"},"PadId":{"type":"string","pattern":"^pad_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A platform address: a pad-prefixed uuid"},"PostalAddress":{"type":"object","properties":{"firstName":{"type":"string","maxLength":500},"lastName":{"type":"string","maxLength":500},"company":{"type":"string","maxLength":500},"address1":{"type":"string","maxLength":500},"address2":{"type":"string","maxLength":500},"city":{"type":"string","maxLength":500},"province":{"type":"string","maxLength":500},"provinceCode":{"type":"string","maxLength":10},"country":{"type":"string","maxLength":500},"countryCode":{"type":"string","allOf":[{"minLength":2},{"maxLength":2}]},"zip":{"type":"string","maxLength":20},"phone":{"type":"string","maxLength":40},"verifiedAddressId":{"$ref":"#/components/schemas/PadId"}},"additionalProperties":false},"DocumentAddress":{"type":"object","properties":{"id":{"anyOf":[{"$ref":"#/components/schemas/AdrId"},{"$ref":"#/components/schemas/ClocId"}]},"label":{"type":"string"},"address":{"$ref":"#/components/schemas/PostalAddress"}},"required":["id"],"additionalProperties":false,"description":"An address a document was issued with: a company location's as it read at issue, a person's by its version id only."},"DocumentParty":{"type":"object","properties":{"personId":{"$ref":"#/components/schemas/PsnId"},"companyId":{"$ref":"#/components/schemas/CmpId"},"name":{"type":"string","minLength":1},"paymentTermsDays":{"type":"integer","minimum":0},"taxNumber":{"$ref":"#/components/schemas/TaxNumber"},"shipTo":{"$ref":"#/components/schemas/DocumentAddress"},"billTo":{"$ref":"#/components/schemas/DocumentAddress"}},"additionalProperties":false,"description":"The customer or supplier a document is between, as named at issue: ids, the company's name, terms and tax number, the addresses used."},"PurchaseDocumentLine":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku"},"name":{"type":"string","minLength":1,"maxLength":300},"pack":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku_1"},"units":{"type":"integer","exclusiveMinimum":0}},"required":["sku","units"],"additionalProperties":false},"quantity":{"type":"integer","exclusiveMinimum":0},"unitCostCents":{"type":"number","minimum":0}},"required":["sku","name","quantity","unitCostCents"],"additionalProperties":false,"description":"One line of a purchase order as it went to the supplier."},"PurchaseDocument":{"type":"object","properties":{"number":{"type":"string","minLength":1},"reference":{"type":"string","minLength":1},"currency":{"$ref":"#/components/schemas/PoCurrency"},"supplier":{"$ref":"#/components/schemas/DocumentParty"},"expectedOn":{"$ref":"#/components/schemas/IsoDay"},"lines":{"type":"array","items":{"$ref":"#/components/schemas/PurchaseDocumentLine"}},"totalCents":{"type":"integer","minimum":0}},"required":["number","reference","currency","supplier","lines","totalCents"],"additionalProperties":false,"description":"A purchase order as authorised for its supplier: header, supplier, lines and total."},"purchasing.po-authorisedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["purchasing.po-authorised"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"poId":{"$ref":"#/components/schemas/PoId"},"document":{"$ref":"#/components/schemas/PurchaseDocument"}},"required":["poId","document"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"purchasing.receipt-requestedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["purchasing.receipt-requested"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"poId":{"$ref":"#/components/schemas/PoId"},"receiptId":{"$ref":"#/components/schemas/RcptId"},"locationId":{"$ref":"#/components/schemas/LocId"},"receivedOn":{"$ref":"#/components/schemas/IsoDay"},"shipmentId":{"$ref":"#/components/schemas/IbsId"},"lines":{"type":"array","prefixItems":[{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku"},"pack":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku_1"},"units":{"type":"integer","exclusiveMinimum":0}},"required":["sku","units"],"additionalProperties":false},"quantity":{"type":"integer","exclusiveMinimum":0},"unitCostCents":{"type":"number","minimum":0},"tracking":{"$ref":"#/components/schemas/Tracking"},"serials":{"type":"array","items":{"$ref":"#/components/schemas/SerialNumber"}},"batchNumber":{"$ref":"#/components/schemas/BatchNumber"},"expiresAt":{"type":"string"}},"required":["sku","quantity","unitCostCents","tracking"],"additionalProperties":false}],"minItems":1,"items":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku"},"pack":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku_1"},"units":{"type":"integer","exclusiveMinimum":0}},"required":["sku","units"],"additionalProperties":false},"quantity":{"type":"integer","exclusiveMinimum":0},"unitCostCents":{"type":"number","minimum":0},"tracking":{"$ref":"#/components/schemas/Tracking"},"serials":{"type":"array","items":{"$ref":"#/components/schemas/SerialNumber"}},"batchNumber":{"$ref":"#/components/schemas/BatchNumber"},"expiresAt":{"type":"string"}},"required":["sku","quantity","unitCostCents","tracking"],"additionalProperties":false}}},"required":["poId","receiptId","lines"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"purchasing.receipt-recordedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["purchasing.receipt-recorded"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"poId":{"$ref":"#/components/schemas/PoId"},"receiptId":{"$ref":"#/components/schemas/RcptId"},"locationId":{"$ref":"#/components/schemas/LocId"},"receivedOn":{"$ref":"#/components/schemas/IsoDay"},"shipmentId":{"$ref":"#/components/schemas/IbsId"},"currency":{"$ref":"#/components/schemas/PoCurrency"},"fx":{"$ref":"#/components/schemas/FxCapture"},"lines":{"type":"array","prefixItems":[{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku"},"quantity":{"type":"integer","exclusiveMinimum":0},"unitCostCents":{"type":"number","minimum":0},"pack":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku_1"},"quantity":{"type":"integer","exclusiveMinimum":0}},"required":["sku","quantity"],"additionalProperties":false},"serials":{"type":"array","items":{"$ref":"#/components/schemas/SerialNumber"}},"batchNumber":{"$ref":"#/components/schemas/BatchNumber"},"expiresAt":{"type":"string"}},"required":["sku","quantity","unitCostCents"],"additionalProperties":false}],"minItems":1,"items":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku"},"quantity":{"type":"integer","exclusiveMinimum":0},"unitCostCents":{"type":"number","minimum":0},"pack":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku_1"},"quantity":{"type":"integer","exclusiveMinimum":0}},"required":["sku","quantity"],"additionalProperties":false},"serials":{"type":"array","items":{"$ref":"#/components/schemas/SerialNumber"}},"batchNumber":{"$ref":"#/components/schemas/BatchNumber"},"expiresAt":{"type":"string"}},"required":["sku","quantity","unitCostCents"],"additionalProperties":false}}},"required":["poId","receiptId","currency","fx","lines"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"purchasing.receipt-refusedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["purchasing.receipt-refused"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"poId":{"$ref":"#/components/schemas/PoId"},"receiptId":{"$ref":"#/components/schemas/RcptId"},"sku":{"$ref":"#/components/schemas/Sku"},"reason":{"type":"string"}},"required":["poId","receiptId","sku","reason"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"purchasing.invoice-authorisedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["purchasing.invoice-authorised"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"poId":{"$ref":"#/components/schemas/PoId"},"lines":{"type":"array","items":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku"},"unitCostCents":{"type":"number","minimum":0},"pack":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku_1"},"unitCostCents":{"type":"number","minimum":0}},"required":["sku","unitCostCents"],"additionalProperties":false}},"required":["sku","unitCostCents"],"additionalProperties":false}},"currency":{"$ref":"#/components/schemas/PoCurrency"},"fx":{"$ref":"#/components/schemas/FxCapture"}},"required":["poId","lines","currency","fx"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"purchasing.landed-cost-allocatedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["purchasing.landed-cost-allocated"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"poId":{"$ref":"#/components/schemas/PoId"},"amountCents":{"type":"integer","exclusiveMinimum":0},"currency":{"$ref":"#/components/schemas/PoCurrency"},"fx":{"$ref":"#/components/schemas/FxCapture"},"description":{"type":"string","minLength":1},"reference":{"type":"string","minLength":1},"lines":{"type":"array","prefixItems":[{"$ref":"#/components/schemas/LandedCostLine"}],"minItems":1,"items":{"$ref":"#/components/schemas/LandedCostLine"}}},"required":["poId","amountCents","currency","fx","description","reference","lines"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"purchasing.cost-recordedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["purchasing.cost-recorded"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"poId":{"$ref":"#/components/schemas/PoId"},"costId":{"$ref":"#/components/schemas/CostId"},"amountCents":{"type":"integer","exclusiveMinimum":0},"currency":{"$ref":"#/components/schemas/CurrencyCode"},"fx":{"$ref":"#/components/schemas/FxCapture"},"reason":{"type":"string","minLength":1,"maxLength":500},"accountCode":{"$ref":"#/components/schemas/AccountCodeEncoded"},"date":{"$ref":"#/components/schemas/IsoDay"},"sku":{"$ref":"#/components/schemas/Sku_1"},"capitalised":{"type":"boolean"},"lines":{"type":"array","items":{"$ref":"#/components/schemas/LandedCostLine"}}},"required":["poId","costId","amountCents","currency","fx","reason","accountCode","date","capitalised","lines"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"purchasing.cost-reversedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["purchasing.cost-reversed"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"poId":{"$ref":"#/components/schemas/PoId"},"costId":{"$ref":"#/components/schemas/CostId"},"reason":{"type":"string","minLength":1,"maxLength":500},"amountCents":{"type":"integer","exclusiveMinimum":0},"currency":{"$ref":"#/components/schemas/CurrencyCode"},"fx":{"$ref":"#/components/schemas/FxCapture"},"accountCode":{"$ref":"#/components/schemas/AccountCodeEncoded"},"capitalised":{"type":"boolean"},"lines":{"type":"array","items":{"$ref":"#/components/schemas/LandedCostLine"}}},"required":["poId","costId","amountCents","currency","fx","accountCode","capitalised","lines"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"RemainderOutcome":{"type":"string","enum":["cancelled","kept"],"description":"What became of undelivered quantity when an order closed: `cancelled` — inventory told to stop expecting it; `kept` — the shortfall stays on the lines"},"purchasing.po-closedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["purchasing.po-closed"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"poId":{"$ref":"#/components/schemas/PoId"},"remainder":{"$ref":"#/components/schemas/RemainderOutcome"},"reason":{"type":"string","minLength":1},"lines":{"type":"array","items":{"type":"object","properties":{"sku":{"$ref":"#/components/schemas/Sku"},"outstanding":{"type":"integer","minimum":0}},"required":["sku","outstanding"],"additionalProperties":false}}},"required":["poId","remainder","lines"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"purchasing.settings-configuredEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["purchasing.settings-configured"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"poNumberPrefix":{"$ref":"#/components/schemas/PoNumberPrefix"},"nextPoNumber":{"type":"integer","exclusiveMinimum":0},"autoInvoiceOnReceipt":{"type":"boolean"},"autoClose":{"type":"boolean"},"shortClose":{"$ref":"#/components/schemas/ShortCloseMode"},"supplierAlerts":{"$ref":"#/components/schemas/SupplierAlertSettingsEncoded"},"leadTimeHalfLifeDays":{"$ref":"#/components/schemas/LeadTimeHalfLifeDays"}},"required":["poNumberPrefix","nextPoNumber","autoInvoiceOnReceipt","autoClose","shortClose"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"purchasing.supplier-price-setEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["purchasing.supplier-price-set"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"supplierId":{"$ref":"#/components/schemas/CmpId"},"sku":{"$ref":"#/components/schemas/Sku"},"unitCostCents":{"type":"number","minimum":0},"currency":{"$ref":"#/components/schemas/PoCurrency"},"supplierSku":{"type":"string"}},"required":["supplierId","sku","unitCostCents","currency"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"purchasing.supplier-price-removedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["purchasing.supplier-price-removed"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"supplierId":{"$ref":"#/components/schemas/CmpId"},"sku":{"$ref":"#/components/schemas/Sku"}},"required":["supplierId","sku"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"purchasing.supplier-payment-recordedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["purchasing.supplier-payment-recorded"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"paymentId":{"$ref":"#/components/schemas/SpayId"},"supplier":{"type":"string","minLength":1},"supplierId":{"$ref":"#/components/schemas/CmpId"},"currency":{"$ref":"#/components/schemas/PoCurrency"},"amountCents":{"type":"integer","exclusiveMinimum":0},"paidOn":{"$ref":"#/components/schemas/IsoDay"},"method":{"$ref":"#/components/schemas/SupplierPaymentMethod"},"remittance":{"type":"string","minLength":1},"fx":{"$ref":"#/components/schemas/FxCapture"},"allocations":{"type":"array","prefixItems":[{"$ref":"#/components/schemas/SupplierPaymentAllocation"}],"minItems":1,"items":{"$ref":"#/components/schemas/SupplierPaymentAllocation"}}},"required":["paymentId","supplier","currency","amountCents","paidOn","method","fx","allocations"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"purchasing.receipt-issue-recordedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["purchasing.receipt-issue-recorded"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"poId":{"$ref":"#/components/schemas/PoId"},"issueId":{"$ref":"#/components/schemas/RciId"},"receiptId":{"$ref":"#/components/schemas/RcptId"},"shipmentId":{"$ref":"#/components/schemas/IbsId"},"reportedOn":{"$ref":"#/components/schemas/IsoDay"},"lines":{"type":"array","prefixItems":[{"$ref":"#/components/schemas/ReceiptIssueLine"}],"minItems":1,"items":{"$ref":"#/components/schemas/ReceiptIssueLine"}}},"required":["poId","issueId","reportedOn","lines"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"purchasing.inbound-shipment-recordedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["purchasing.inbound-shipment-recorded"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"poId":{"$ref":"#/components/schemas/PoId"},"shipmentId":{"$ref":"#/components/schemas/IbsId"},"carrier":{"$ref":"#/components/schemas/CarrierNameEncoded"},"service":{"type":"string","minLength":1},"trackingNumbers":{"type":"array","items":{"$ref":"#/components/schemas/TrackingNumberEncoded"}},"dispatchedOn":{"$ref":"#/components/schemas/IsoDay"},"eta":{"$ref":"#/components/schemas/IsoDay"},"source":{"$ref":"#/components/schemas/InboundShipmentSource"},"lines":{"type":"array","items":{"$ref":"#/components/schemas/InboundShipmentLine"}}},"required":["poId","shipmentId","carrier","trackingNumbers","source","lines"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"purchasing.inbound-tracking-recordedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["purchasing.inbound-tracking-recorded"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"poId":{"$ref":"#/components/schemas/PoId"},"shipmentId":{"$ref":"#/components/schemas/IbsId"},"events":{"type":"array","items":{"$ref":"#/components/schemas/TrackingEventEncoded"}},"eta":{"$ref":"#/components/schemas/IsoDay"},"status":{"$ref":"#/components/schemas/InboundShipmentStatus"}},"required":["poId","shipmentId","events","status"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"SupplierAlertMetric":{"type":"string","enum":["damage-rate","late-rate"],"description":"Which supplier rate an alert watches: `damage-rate` — damaged units of all delivered; `late-rate` — deliveries after the day promised"},"PercentEncoded":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"purchasing.supplier-alert-raisedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["purchasing.supplier-alert-raised"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"reference":{"type":"string","minLength":1},"supplierId":{"$ref":"#/components/schemas/CmpId"},"supplier":{"type":"string","minLength":1},"metric":{"$ref":"#/components/schemas/SupplierAlertMetric"},"ratePercent":{"$ref":"#/components/schemas/PercentEncoded"},"thresholdPercent":{"$ref":"#/components/schemas/PercentEncoded"},"sample":{"type":"integer","exclusiveMinimum":0},"windowDays":{"type":"integer","exclusiveMinimum":0}},"required":["reference","supplierId","supplier","metric","ratePercent","thresholdPercent","sample","windowDays"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"JournalHead":{"type":"object","properties":{"at":{"type":"string"},"sequence":{"type":"integer","minimum":0}},"required":["at"],"additionalProperties":false,"description":"Where a tenant's journal stood at a moment."}},"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"A tenant JWT: sign in through the auth service, choose the organization, then `GET /api/auth/token`. Tokens last 15 minutes."}}},"security":[],"tags":[{"name":"pos","description":"Purchase-order lifecycle: draft → authorised → partially-received → received → invoiced → closed, or cancelled."},{"name":"settings","description":"Tenant-level purchasing policy."},{"name":"events","description":"The purchasing append-only event log."}],"servers":[{"url":"https://purchasing.getmanifold.io","description":"Production"}]}