{"openapi":"3.1.0","info":{"title":"Accounting Ledger API","version":"0.1.0","description":"The general ledger, and the other ledgers kept in step with it. Its ledgers (`docs/ledgers.md`) are its own journal: the external books ledger apps connect, the merchant's settings and account map, and every journal planned from the postings with how the other ledger answered. Everything else is derived: it replays the inventory, purchasing, and fulfillment event logs and folds them into cost layers (per the SKU's costing method — fifo, fefo, special-batch, special-serial) and an append-only COGS ledger. Cost is captured when a purchase invoice is authorised; COGS is recognised when a dispatch is authorised; late invoices and landed costs post corrections, never rewrites. Beside the COGS ledger it keeps the general ledger: one balanced double-entry posting per fact that moved money — stock in, cost of sales, supplier invoices, sales invoices, payments, refunds — by account code, with a trial balance over any period."},"paths":{"/ledger":{"get":{"tags":["ledger"],"operationId":"ledger.entries","parameters":[{"name":"sku","in":"query","schema":{"$ref":"#/components/schemas/Sku"},"required":false,"example":"MUG-SPECKLE"},{"name":"q","in":"query","schema":{"type":"string","maxLength":64},"required":false},{"name":"type","in":"query","schema":{"$ref":"#/components/schemas/LedgerEntryType"},"required":false,"example":"cogs"},{"name":"from","in":"query","schema":{"type":"string"},"required":false,"example":"2026-10-20T00:00:00.000Z"},{"name":"to","in":"query","schema":{"type":"string"},"required":false,"example":"2026-10-21T00:00:00.000Z"},{"name":"limit","in":"query","schema":{"type":"string"},"required":false,"example":"100"},{"name":"offset","in":"query","schema":{"type":"string"},"required":false}],"security":[{"bearer":[]}],"responses":{"200":{"description":"LedgerPage","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LedgerPageEncoded"},"examples":{"contract":{"summary":"ledger.entries","value":{"items":[{"entryId":"led_01a1588b-1a20-7b31-9c42-35465768798a","type":"cogs","occurredAt":"2026-10-20T03:15:00.000Z","effectiveAt":"2026-10-20T03:15:00.000Z","sku":"MUG-SPECKLE","quantity":4,"amountCents":3400,"orderId":"ord_01a156d4-8704-7a21-8b32-4c5d6e7f8091","lineId":"lin_01a156d4-8704-7a21-8b32-5d6e7f809102","dispatchId":"dsp_01a1588b-1a20-7b31-9c42-6e7f80910213","uncostedQuantity":0,"memo":"cogs (fifo)"}],"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":"A page of ledger entries, newest effective date first (entry id breaking ties), optionally narrowed to one SKU (`sku`), a SKU substring (`q`), an entry `type`, and a period — `from` inclusive, `to` exclusive, on the entry's effective date. `total` counts every match; `limit` is 1–500 (100 when omitted). `cogs` entries post at ship (dispatch) authorisation; `cogs-correction` entries post when a supplier invoice or landed cost lands after units were already sold; `cogs-reversal` entries post when a refund physically returns units; `write-down` entries post the loss on written-off stock (and the damaged share of a restocking refund) at layer cost — the original entry is never rewritten. Served from accounting's incrementally folded ledger: a read first applies whatever the source journals committed since the last one.\n\nRequires `financials:read`.","x-mcp-tool":{"name":"accounting_ledger_entries","title":"Accounting: Ledger entries","toolset":"accounting","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["financials:read"],"x-example-source":{"origin":"contract"}}},"/ledger/cogs":{"get":{"tags":["ledger"],"operationId":"ledger.cogs","parameters":[{"name":"from","in":"query","schema":{"type":"string"},"required":true,"example":"2026-10-01T00:00:00.000Z"},{"name":"to","in":"query","schema":{"type":"string"},"required":true,"example":"2026-11-01T00:00:00.000Z"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"amountCents":{"type":"integer"}},"required":["amountCents"],"additionalProperties":false},"examples":{"contract":{"summary":"ledger.cogs","value":{"amountCents":3400}}}}}},"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 the stock sold in a period cost: total COGS (entries plus corrections) with effective dates in [`from`, `to`). A sale without an authorised dispatch contributes nothing — if the period looks low, look for unauthorised dispatches or unauthorised supplier invoices first. This is the cost ledger, dated when the cost was incurred; on the cash basis the general ledger recognises a supplier invoice's correction and a landed cost's share when the bill is paid (`docs/accounting-basis.md`), so its cost of sales can differ by those.\n\nRequires `financials:read`.","x-mcp-tool":{"name":"accounting_cogs","title":"Accounting: COGS","toolset":"accounting","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["financials:read"],"x-example-source":{"origin":"contract"}}},"/ledger/unit-costs":{"get":{"tags":["ledger"],"operationId":"ledger.unitCosts","parameters":[{"name":"days","in":"query","schema":{"type":"string"},"required":true,"example":"30"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/SkuUnitCostEncoded"}},"examples":{"contract":{"summary":"ledger.unitCosts","value":[{"sku":"MUG-SPECKLE","unitCostCents":850,"unitsSold":4,"amountCents":3400}]}}}}},"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":"Average unit COGS per SKU over the trailing `days` days: net units dispatched (COGS entries minus reversals) and the summed amounts (corrections included), divided out. SKUs with no positive net units in the window are omitted. A display/sync figure like the valuations — nothing posts. Granted to `sell` as well as `account`: channel connectors read it to stamp unit costs onto the variants they push.\n\nRequires `financials:read` or `products:write` or `catalogs:write`.","x-mcp-tool":{"name":"accounting_unit_costs","title":"Accounting: Unit costs","toolset":"accounting","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["financials:read","products:write","catalogs:write"],"x-example-source":{"origin":"contract"}}},"/orders/{orderId}/costings":{"get":{"tags":["ledger"],"operationId":"ledger.orderCostings","parameters":[{"name":"orderId","in":"path","schema":{"$ref":"#/components/schemas/OrdId"},"required":true,"example":"ord_01a156d4-8704-7a21-8b32-4c5d6e7f8091"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"OrderCostings","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderCostingsEncoded"},"examples":{"contract":{"summary":"ledger.orderCostings","value":{"orderId":"ord_01a156d4-8704-7a21-8b32-4c5d6e7f8091","homeCurrency":"AUD","booksOpen":true,"lines":[{"lineId":"lin_01a156d4-8704-7a21-8b32-5d6e7f809102","sku":"MUG-SPECKLE","shippedUnits":4,"cogsCents":3400,"uncostedUnits":0,"revenueCents":9600,"refundedCents":0,"draws":[{"receiptId":"rcpt_01a0f6b1-3a00-7d51-9e62-910213243546","poId":"po_01a0f6b1-2680-7c41-8d52-809102132435","quantity":4,"unitCostCents":850}]}],"shippingChargedCents":1200,"shippingCostCents":940,"refundedCents":0,"postings":3}}}}}},"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 the books hold of one sales order, in the home currency, per line (`lineId`): units shipped less returned, actual COGS at the cost layers drawn (receipt, PO, lot, serials), revenue booked net of tax and what refunds took back; for the order, shipping charged against carriers' charges, refunds, and its postings' count (`GET /postings?orderId=`). Only what reached the ledger; expected cost is fulfillment's `GET /orders/:orderId/margins`. Read-only.\n\nRequires `financials:read`.","x-mcp-tool":{"name":"accounting_get_order_costings","title":"Accounting: Get order costings","toolset":"accounting","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["financials:read"],"x-example-source":{"origin":"contract"}}},"/postings":{"get":{"tags":["postings"],"operationId":"postings.list","parameters":[{"name":"account","in":"query","schema":{"$ref":"#/components/schemas/AccountCodeParam"},"required":false},{"name":"source","in":"query","schema":{"$ref":"#/components/schemas/PostingSource"},"required":false},{"name":"orderId","in":"query","schema":{"$ref":"#/components/schemas/OrdId"},"required":false,"example":"ord_01a156d4-8704-7a21-8b32-4c5d6e7f8091"},{"name":"payoutId","in":"query","schema":{"$ref":"#/components/schemas/PyoId"},"required":false},{"name":"sku","in":"query","schema":{"$ref":"#/components/schemas/Sku"},"required":false},{"name":"from","in":"query","schema":{"type":"string"},"required":false,"example":"2026-10-20T00:00:00.000Z"},{"name":"to","in":"query","schema":{"type":"string"},"required":false,"example":"2026-10-21T00:00:00.000Z"},{"name":"limit","in":"query","schema":{"type":"string"},"required":false,"example":"100"},{"name":"offset","in":"query","schema":{"type":"string"},"required":false}],"security":[{"bearer":[]}],"responses":{"200":{"description":"PostingPage","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PostingPageEncoded"},"examples":{"contract":{"summary":"postings.list","value":{"items":[{"postingId":"pst_01a1588b-1a20-7b31-9c42-132435465768","source":"sales-invoice","occurredAt":"2026-10-20T03:15:00.000Z","effectiveAt":"2026-10-20T03:15:00.000Z","lines":[{"account":"1200","debitCents":10560,"creditCents":0},{"account":"4000","debitCents":0,"creditCents":9600,"sku":"MUG-SPECKLE","lineId":"lin_01a156d4-8704-7a21-8b32-5d6e7f809102"},{"account":"2200","debitCents":0,"creditCents":960,"tax":{"class":"standard","treatment":"domestic","country":"AU","rateBps":1000,"exempt":false}}],"orderId":"ord_01a156d4-8704-7a21-8b32-4c5d6e7f8091","invoiceId":"inv_01a1588b-1a20-7b31-9c42-7f8091021324","memo":"invoice inv_01a1588b-1a20-7b31-9c42-7f8091021324 on ord_01a156d4-8704-7a21-8b32-4c5d6e7f8091"},{"postingId":"pst_01a1588b-1a20-7b31-9c42-243546576879","source":"cogs","occurredAt":"2026-10-20T03:15:00.000Z","effectiveAt":"2026-10-20T03:15:00.000Z","lines":[{"account":"5000","debitCents":3400,"creditCents":0,"sku":"MUG-SPECKLE","lineId":"lin_01a156d4-8704-7a21-8b32-5d6e7f809102"},{"account":"1400","debitCents":0,"creditCents":3400,"sku":"MUG-SPECKLE","lineId":"lin_01a156d4-8704-7a21-8b32-5d6e7f809102"}],"orderId":"ord_01a156d4-8704-7a21-8b32-4c5d6e7f8091","sku":"MUG-SPECKLE","memo":"cogs (fifo)"}],"total":2,"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":"A page of the general ledger, newest effective date first (posting id breaking ties): one balanced double-entry posting per fact that moved money, with its debit and credit lines by account code. Narrow by `account` (a code any line posts to), `source` (what kind of fact posted it — `receipt`, `opening-stock`, `opening-stocktake`, `opening-balances`, `stocktake-variance`, `cogs`, `cogs-correction`, `cogs-reversal`, `write-down`, `supplier-invoice`, `landed-cost`, `sales-invoice`, `payment`, `refund`, `payout`, `supplier-payment`, `shipping-cost`, `shipping-cost-void`, `carrier-payment`, `revaluation`, `revaluation-reversal`, `cash-recognition`, `basis-change`), `orderId`, `payoutId` (a payout's own postings: their 7100 lines are its realised exchange), `sku`, and a period — `from` inclusive, `to` exclusive, on the effective date. `total` counts every match; `limit` is 1–500 (100 when omitted). Stock in debits the SKU's inventory account against goods-received-not-invoiced; a supplier invoice moves that accrual to accounts payable and lands the price difference on stock and cost of sales; a dispatch debits cost of sales and credits inventory; a sales invoice debits receivables for its total against the lines' revenue accounts, shipping income, tax payable and discounts; a payment moves receivables into its provider's clearing account (undeposited funds when taken by hand); a refund is a deduction from sales out of that clearing; a `payout` relieves the clearing of what it settles and lands its fees, chargebacks, reserves and exchange, leaving the clearing holding the deposit. On the cash basis (`docs/accounting-basis.md`) an invoice's revenue and tax, and a bill's expense and tax, post to 2300 / 1350 instead, and `cash-recognition` moves them out as money settles them. Every line is in the home currency — a line converted from another currency also carries its `currency` and `amountCents` there, at the rate its fact captured, and a settlement's rate difference is realised exchange (7100). At each period end (a calendar month `period` ending at midnight in the books' zone, tax settings' `timeZone`) a `revaluation` restates the open foreign-currency receivables, payables and clearing at that day's reference rate against unrealised exchange (7110), on the period's last instant, and its `revaluation-reversal` undoes it on the next period's first. Codes are the chart's (`GET /accounts` on inventory): a SKU's three from its master data, the control accounts fixed per tenant. **The general ledger begins at the opening stocktake** (`docs/stocktake.md`): it posts the counted stock at its cost against opening balances, nothing effective before it is the ledger's, and before it the page is empty. Served from accounting's incrementally folded ledger, like `/ledger`.\n\nRequires `financials:read`.","x-mcp-tool":{"name":"accounting_list_postings","title":"Accounting: List postings","toolset":"accounting","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["financials:read"],"x-example-source":{"origin":"contract"}}},"/postings/trial-balance":{"get":{"tags":["postings"],"operationId":"postings.trialBalance","parameters":[{"name":"from","in":"query","schema":{"type":"string"},"required":true,"example":"2026-10-20T00:00:00.000Z"},{"name":"to","in":"query","schema":{"type":"string"},"required":true,"example":"2026-10-21T00:00:00.000Z"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"TrialBalance","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TrialBalanceEncoded"},"examples":{"contract":{"summary":"postings.trialBalance","value":{"from":"2026-10-20T00:00:00.000Z","to":"2026-10-21T00:00:00.000Z","accounts":[{"account":"1200","debitCents":10560,"creditCents":0,"netCents":10560},{"account":"1400","debitCents":0,"creditCents":3400,"netCents":-3400},{"account":"2200","debitCents":0,"creditCents":960,"netCents":-960},{"account":"4000","debitCents":0,"creditCents":9600,"netCents":-9600},{"account":"5000","debitCents":3400,"creditCents":0,"netCents":3400}],"debitCents":13960,"creditCents":13960}}}}}},"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":"Every account's movement over [`from`, `to`), in code order, with the totals: what was debited, what was credited, and the net (debits minus credits — positive for a debit balance such as an asset or an expense, negative for a credit balance such as sales or a liability). Total debits equal total credits, because every posting balances. This is the period's movement, not a closing balance: open from the opening stocktake for a balance to date. A period's movement carries its period-end revaluation (7110); the next period's carries its reversal. **The general ledger begins at the opening stocktake** (`docs/stocktake.md`): a period before it moves nothing, and a tenant without one has an empty trial balance. The figure a bookkeeper checks against the accounting package, and what an accounting sync reconciles to.\n\nRequires `financials:read`.","x-mcp-tool":{"name":"accounting_trial_balance","title":"Accounting: Trial balance","toolset":"accounting","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["financials:read"],"x-example-source":{"origin":"contract"}}},"/open-items":{"get":{"tags":["postings"],"operationId":"postings.openItems","parameters":[{"name":"account","in":"query","schema":{"$ref":"#/components/schemas/AccountCodeParam"},"required":false},{"name":"currency","in":"query","schema":{"$ref":"#/components/schemas/CurrencyCode"},"required":false,"example":"AUD"},{"name":"kind","in":"query","schema":{"$ref":"#/components/schemas/OpenItemKind"},"required":false,"example":"receivable"},{"name":"orderId","in":"query","schema":{"$ref":"#/components/schemas/OrdId"},"required":false},{"name":"limit","in":"query","schema":{"type":"string"},"required":false,"example":"100"},{"name":"offset","in":"query","schema":{"type":"string"},"required":false}],"security":[{"bearer":[]}],"responses":{"200":{"description":"OpenItemPage","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpenItemPageEncoded"},"examples":{"contract":{"summary":"postings.openItems","value":{"items":[{"kind":"receivable","account":"1200","currency":"AUD","amountCents":10560,"homeCents":10560,"orderId":"ord_01a156d4-8704-7a21-8b32-4c5d6e7f8091","openedAt":"2026-10-20T03:15:00.000Z"}],"balances":[{"account":"1200","currency":"AUD","amountCents":10560,"homeCents":10560,"items":1}],"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":"The monetary accounts' unsettled items, oldest first, with the balances per account and currency (`docs/multi-currency.md` › §4): each order's receivable (its invoices less its payments), each purchase order's payable, and each payment or refund waiting in its provider's clearing account for the payout that settles it. Every item is in its document's currency (`amountCents`, ISO minor units) and at the home amount it was booked at (`homeCents`), signed — a debit balance positive. A settlement relieves an item at that booked amount and posts the rest as realised exchange (7100), so a foreign-currency balance never leaves a residue; a settled item drops off this list. Narrow by `account`, `currency`, `kind` or `orderId`; `total` counts every match, `limit` is 1–500 (100 when omitted). A provider's clearing balance here is what its payouts have yet to settle: the reconciliation's open side. Like the general ledger, the items begin at the opening stocktake: one still open then is brought in at its booked amount against 3900 opening balances (the `opening-balances` posting), and a bill arriving after it for goods it counted is owed from it, so the balances here agree with the trial balance's. A period-end revaluation moves no item: each keeps its booked amount.\n\nRequires `financials:read`.","x-mcp-tool":{"name":"accounting_list_open_items","title":"Accounting: List open items","toolset":"accounting","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["financials:read"],"x-example-source":{"origin":"contract"}}},"/valuation":{"get":{"tags":["valuation"],"operationId":"valuation.list","parameters":[],"security":[{"bearer":[]}],"responses":{"200":{"description":"InventoryValuation","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InventoryValuationEncoded"},"examples":{"contract":{"summary":"valuation.list","value":{"totalUnits":156,"totalValueCents":146600,"skus":[{"sku":"MUG-SPECKLE","onHandUnits":116,"onHandValueCents":98600,"avcoCents":850},{"sku":"BOWL-SALT-L","onHandUnits":40,"onHandValueCents":48000,"avcoCents":1200}]}}}}}},"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 whole account's stock at cost: every SKU with units on hand, highest value first, with the totals — the figure an analytics screen opens on. Like the per-SKU view, a display figure derived from open cost layers, never a posting.\n\nRequires `financials:read`.","x-mcp-tool":{"name":"accounting_list_valuations","title":"Accounting: List valuations","toolset":"accounting","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["financials:read"],"x-example-source":{"origin":"contract"}}},"/valuation/{sku}":{"get":{"tags":["valuation"],"operationId":"valuation.get","parameters":[{"name":"sku","in":"path","schema":{"$ref":"#/components/schemas/Sku_1"},"required":true,"example":"MUG-SPECKLE"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"SkuValuation","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SkuValuationEncoded"},"examples":{"contract":{"summary":"valuation.get","value":{"sku":"MUG-SPECKLE","onHandUnits":116,"onHandValueCents":98600,"avcoCents":850,"layers":[{"receiptId":"rcpt_01a0f6b1-3a00-7d51-9e62-910213243546","poId":"po_01a0f6b1-2680-7c41-8d52-809102132435","sku":"MUG-SPECKLE","remaining":116,"received":120,"unitCostMicros":8500000,"serials":[],"receivedAt":"2026-10-02T01:40: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":"Current cost layers and inventory value for a SKU. `avcoCents` is a calculated display figure for reference only — it never posts to the ledger and never feeds financial reporting.\n\nRequires `financials:read`.","x-mcp-tool":{"name":"accounting_valuation","title":"Accounting: Valuation","toolset":"accounting","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["financials:read"],"x-example-source":{"origin":"contract"}}},"/ledgers":{"get":{"tags":["ledgers"],"operationId":"ledgers.list","parameters":[{"name":"appId","in":"query","schema":{"$ref":"#/components/schemas/AppId"},"required":false,"example":"app_85cedb60-f616-4fe5-b9ea-dcd3689b4bc6"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"LedgerList","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LedgerListEncoded"},"examples":{"contract":{"summary":"ledgers.list","value":{"items":[{"id":"lgr_01a0f6b2-1c00-7f71-8a82-465768798a9b","appId":"app_85cedb60-f616-4fe5-b9ea-dcd3689b4bc6","externalId":"01a15897-023d-7b5f-9c7d-2e4f6a8b0c1d","name":"Saltbush Homewares Pty Ltd","baseCurrency":"AUD","status":"connected","settings":{"granularity":"daily-summary","accounts":"map","syncFrom":"2026-10-01"},"mappings":[{"account":"1200","externalId":"01a15873-a19f-7e60-9a1d-3f8c2b6e4a10","externalCode":"615","externalName":"Trade debtors clearing","created":false},{"account":"1400","externalId":"01a1588b-d641-7a82-8b3f-5a1e4d8c6b32","externalCode":"630","externalName":"Inventory","created":false},{"account":"2200","externalId":"01a15892-5a94-7ca4-ad5b-7c3a6f1e8d54","externalCode":"820","externalName":"GST","created":false},{"account":"4000","externalId":"01a15858-a1fe-7ec6-8f7d-9e5c8b3a0f76","externalCode":"200","externalName":"Sales","created":false},{"account":"5000","externalId":"01a15869-63f8-7fe8-9b9f-1a7e0d5c2b98","externalCode":"310","externalName":"Cost of Goods Sold","created":false},{"account":"2100","externalId":"01a15898-dee7-70cc-a208-4e5b60552d26","externalCode":"806","externalName":"Goods received not invoiced","created":false},{"account":"3900","externalId":"01a15896-13e8-7708-b853-cd30590fd955","externalCode":"975","externalName":"Opening balances","created":false}],"connectedAt":"2026-10-01T02:14:05.000Z","createdAt":"2026-10-01T02:14:05.000Z","updatedAt":"2026-10-01T02:21:47.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":"The tenant's ledgers — every external set of books an app keeps in step with the general ledger (a Xero organisation, a MYOB company file, a QuickBooks company) — connected and let go, each with the merchant's settings and the account map. `appId` narrows to one app's.\n\nRequires `financials:read`.","x-mcp-tool":{"name":"accounting_list_ledgers","title":"Accounting: List ledgers","toolset":"accounting","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["financials:read"],"x-example-source":{"origin":"contract"}}},"/ledgers/{ledgerId}":{"get":{"tags":["ledgers"],"operationId":"ledgers.get","parameters":[{"name":"ledgerId","in":"path","schema":{"$ref":"#/components/schemas/LgrId"},"required":true,"example":"lgr_01a0f6b2-1c00-7f71-8a82-465768798a9b"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"Ledger","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LedgerEncoded"},"examples":{"contract":{"summary":"ledgers.get","value":{"id":"lgr_01a0f6b2-1c00-7f71-8a82-465768798a9b","appId":"app_85cedb60-f616-4fe5-b9ea-dcd3689b4bc6","externalId":"01a15897-023d-7b5f-9c7d-2e4f6a8b0c1d","name":"Saltbush Homewares Pty Ltd","baseCurrency":"AUD","status":"connected","settings":{"granularity":"daily-summary","accounts":"map","syncFrom":"2026-10-01"},"mappings":[{"account":"1200","externalId":"01a15873-a19f-7e60-9a1d-3f8c2b6e4a10","externalCode":"615","externalName":"Trade debtors clearing","created":false},{"account":"1400","externalId":"01a1588b-d641-7a82-8b3f-5a1e4d8c6b32","externalCode":"630","externalName":"Inventory","created":false},{"account":"2200","externalId":"01a15892-5a94-7ca4-ad5b-7c3a6f1e8d54","externalCode":"820","externalName":"GST","created":false},{"account":"4000","externalId":"01a15858-a1fe-7ec6-8f7d-9e5c8b3a0f76","externalCode":"200","externalName":"Sales","created":false},{"account":"5000","externalId":"01a15869-63f8-7fe8-9b9f-1a7e0d5c2b98","externalCode":"310","externalName":"Cost of Goods Sold","created":false},{"account":"2100","externalId":"01a15898-dee7-70cc-a208-4e5b60552d26","externalCode":"806","externalName":"Goods received not invoiced","created":false},{"account":"3900","externalId":"01a15896-13e8-7708-b853-cd30590fd955","externalCode":"975","externalName":"Opening balances","created":false}],"connectedAt":"2026-10-01T02:14:05.000Z","createdAt":"2026-10-01T02:14:05.000Z","updatedAt":"2026-10-01T02:21:47.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":"LedgerNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LedgerNotFoundEncoded"}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"One ledger, with its settings and account map. 404 `LedgerNotFound`.\n\nRequires `financials:read`.","x-mcp-withheld":"accounting_list_ledgers answers each ledger whole — its app, its books, its settings and account map — and a tenant keeps at most a few.","x-required-scopes":["financials:read"],"x-example-source":{"origin":"contract"}},"put":{"tags":["ledgers"],"operationId":"ledgers.connect","parameters":[{"name":"ledgerId","in":"path","schema":{"$ref":"#/components/schemas/LgrId"},"required":true,"example":"lgr_01a0f6b2-1c00-7f71-8a82-465768798a9b"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"Ledger","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LedgerEncoded"},"examples":{"contract":{"summary":"ledgers.connect","value":{"id":"lgr_01a0f6b2-1c00-7f71-8a82-465768798a9b","appId":"app_85cedb60-f616-4fe5-b9ea-dcd3689b4bc6","externalId":"01a15897-023d-7b5f-9c7d-2e4f6a8b0c1d","name":"Saltbush Homewares Pty Ltd","baseCurrency":"AUD","status":"connected","connectedAt":"2026-10-01T02:14:05.000Z","createdAt":"2026-10-01T02:14:05.000Z","updatedAt":"2026-10-01T02:14:05.000Z","mappings":[]}}}}}},"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":"NotALedgerApp | NotThisLedgersApp | TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/NotALedgerAppEncoded"},{"$ref":"#/components/schemas/NotThisLedgersAppEncoded"},{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"409":{"description":"LedgerCurrencyMismatch | MirroredFromSource","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/LedgerCurrencyMismatchEncoded"},{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}]}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Connect a set of books, or describe them afresh: only an app, under its own token (403 `NotALedgerApp`), and only the app that keeps the ledger (403 `NotThisLedgersApp`). The id is the app's to derive from the tenant, itself and the books' `externalId` (`ledgerIdFor`), so a reconnect is the same ledger with its settings and map. The books must be kept in the tenant's home currency: `baseCurrency`, as the provider reports it, is required — books whose currency the provider cannot say are never connected — and in any other is 409 `LedgerCurrencyMismatch`: Manifold's books are in the home currency and a journal lands in the books' base currency, its amounts in that currency's own minor unit (`docs/multi-currency.md` › §1). Appends `accounting.ledger-connected`. Idempotent by content: books connected as described append nothing.\n\nRequires `financials:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectLedgerEncoded"},"example":{"externalId":"01a15897-023d-7b5f-9c7d-2e4f6a8b0c1d","name":"Saltbush Homewares Pty Ltd","baseCurrency":"AUD"}}},"required":true},"x-mcp-withheld":"Only the ledger's own app, under its own token, connects its books, maps them, plans and answers their journals (NotALedgerApp for anyone else); an agent sends the merchant to the app's page under Apps instead.","x-required-scopes":["financials:write"],"x-example-source":{"origin":"contract"}}},"/ledgers/{ledgerId}/disconnect":{"post":{"tags":["ledgers"],"operationId":"ledgers.disconnect","parameters":[{"name":"ledgerId","in":"path","schema":{"$ref":"#/components/schemas/LgrId"},"required":true,"example":"lgr_01a0f6b2-1c00-7f71-8a82-465768798a9b"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"Ledger","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LedgerEncoded"},"examples":{"contract":{"summary":"ledgers.disconnect","value":{"id":"lgr_01a0f6b2-1c00-7f71-8a82-465768798a9b","appId":"app_85cedb60-f616-4fe5-b9ea-dcd3689b4bc6","externalId":"01a15897-023d-7b5f-9c7d-2e4f6a8b0c1d","name":"Saltbush Homewares Pty Ltd","baseCurrency":"AUD","status":"disconnected","settings":{"granularity":"daily-summary","accounts":"map","syncFrom":"2026-10-01"},"mappings":[{"account":"1200","externalId":"01a15873-a19f-7e60-9a1d-3f8c2b6e4a10","externalCode":"615","externalName":"Trade debtors clearing","created":false},{"account":"1400","externalId":"01a1588b-d641-7a82-8b3f-5a1e4d8c6b32","externalCode":"630","externalName":"Inventory","created":false},{"account":"2200","externalId":"01a15892-5a94-7ca4-ad5b-7c3a6f1e8d54","externalCode":"820","externalName":"GST","created":false},{"account":"4000","externalId":"01a15858-a1fe-7ec6-8f7d-9e5c8b3a0f76","externalCode":"200","externalName":"Sales","created":false},{"account":"5000","externalId":"01a15869-63f8-7fe8-9b9f-1a7e0d5c2b98","externalCode":"310","externalName":"Cost of Goods Sold","created":false},{"account":"2100","externalId":"01a15898-dee7-70cc-a208-4e5b60552d26","externalCode":"806","externalName":"Goods received not invoiced","created":false},{"account":"3900","externalId":"01a15896-13e8-7708-b853-cd30590fd955","externalCode":"975","externalName":"Opening balances","created":false}],"connectedAt":"2026-10-01T02:14:05.000Z","createdAt":"2026-10-01T02:14:05.000Z","updatedAt":"2026-10-22T05:02:31.000Z","disconnectedAt":"2026-10-22T05:02:31.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":"NotALedgerApp | NotThisLedgersApp | TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/NotALedgerAppEncoded"},{"$ref":"#/components/schemas/NotThisLedgersAppEncoded"},{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"LedgerNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LedgerNotFoundEncoded"}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Let a ledger go, saying why: nothing more is planned for it, journals already there stay, and settings and the map are kept for a reconnect. Only the ledger's own app (403 `NotALedgerApp`, `NotThisLedgersApp`); an uninstalled app's ledgers are let go by accounting itself. Appends `accounting.ledger-disconnected`. Idempotent by state: a ledger already let go appends nothing.\n\nRequires `financials:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DisconnectLedgerEncoded"},"example":{"reason":"The merchant disconnected Xero in Apps › Xero."}}},"required":true},"x-mcp-withheld":"Only the ledger's own app, under its own token, connects its books, maps them, plans and answers their journals (NotALedgerApp for anyone else); an agent sends the merchant to the app's page under Apps instead.","x-required-scopes":["financials:write"],"x-example-source":{"origin":"contract"}}},"/ledgers/{ledgerId}/settings":{"put":{"tags":["ledgers"],"operationId":"ledgers.saveSettings","parameters":[{"name":"ledgerId","in":"path","schema":{"$ref":"#/components/schemas/LgrId"},"required":true,"example":"lgr_01a0f6b2-1c00-7f71-8a82-465768798a9b"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"Ledger","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LedgerEncoded"},"examples":{"contract":{"summary":"ledgers.saveSettings","value":{"id":"lgr_01a0f6b2-1c00-7f71-8a82-465768798a9b","appId":"app_85cedb60-f616-4fe5-b9ea-dcd3689b4bc6","externalId":"01a15897-023d-7b5f-9c7d-2e4f6a8b0c1d","name":"Saltbush Homewares Pty Ltd","baseCurrency":"AUD","status":"connected","connectedAt":"2026-10-01T02:14:05.000Z","createdAt":"2026-10-01T02:14:05.000Z","updatedAt":"2026-10-01T02:18:12.000Z","mappings":[],"settings":{"granularity":"daily-summary","accounts":"map","syncFrom":"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":"NotThisLedgersApp | TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/NotThisLedgersAppEncoded"},{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"LedgerNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LedgerNotFoundEncoded"}}}},"409":{"description":"LedgerDisconnected | OpeningStocktakeRequired | LedgerSyncStarted | SyncFromOutOfRange | LedgerCurrencyMismatch | MirroredFromSource","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/LedgerDisconnectedEncoded"},{"$ref":"#/components/schemas/OpeningStocktakeRequiredEncoded"},{"$ref":"#/components/schemas/LedgerSyncStartedEncoded"},{"$ref":"#/components/schemas/SyncFromOutOfRangeEncoded"},{"$ref":"#/components/schemas/LedgerCurrencyMismatchEncoded"},{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}]}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Choose how the general ledger lands there — what activates the ledger: `granularity` (`daily-summary` — one journal per effective date, each account's debits and credits summed; `per-posting` — one per posting), `accounts` (`map` onto the other ledger's accounts, or `create` Manifold's there) and `syncFrom`, where day-by-day journals begin. **Every ledger's books begin at the opening stocktake** (`docs/stocktake.md`), which going live completes: before the tenant has one, saving is 409 `OpeningStocktakeRequired`. `syncFrom` is any day from the opening's to today (409 `SyncFromOutOfRange` names both): its day, or none, backfills every day since the opening however long ago it was; a later day sends every posting before it first as one `carried-forward` journal dated the day before, so the books start from the same opening balance whatever the date. `syncFrom` is fixed once a journal has been planned (409 `LedgerSyncStarted`). Books kept in another currency than the tenant's home currency are never activated (409 `LedgerCurrencyMismatch`). Nothing is planned until settings are saved; any other change applies to journals not yet planned. A person, or the ledger's own app (403 `NotThisLedgersApp` for another). Appends `accounting.ledger-settings-saved`. Idempotent by content: the settings as they stand append nothing.\n\nRequires `financials:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SaveLedgerSettingsEncoded"},"example":{"granularity":"daily-summary","accounts":"map","syncFrom":"2026-10-01"}}},"required":true},"x-mcp-withheld":"How the ledger lands in the other books — journal granularity, account matching, the first date sent — is the merchant's and their bookkeeper's call in the ledger app's page.","x-required-scopes":["financials:write"],"x-example-source":{"origin":"contract"}}},"/ledgers/{ledgerId}/accounts":{"put":{"tags":["ledgers"],"operationId":"ledgers.mapAccounts","parameters":[{"name":"ledgerId","in":"path","schema":{"$ref":"#/components/schemas/LgrId"},"required":true,"example":"lgr_01a0f6b2-1c00-7f71-8a82-465768798a9b"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"Ledger","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LedgerEncoded"},"examples":{"contract":{"summary":"ledgers.mapAccounts","value":{"id":"lgr_01a0f6b2-1c00-7f71-8a82-465768798a9b","appId":"app_85cedb60-f616-4fe5-b9ea-dcd3689b4bc6","externalId":"01a15897-023d-7b5f-9c7d-2e4f6a8b0c1d","name":"Saltbush Homewares Pty Ltd","baseCurrency":"AUD","status":"connected","settings":{"granularity":"daily-summary","accounts":"map","syncFrom":"2026-10-01"},"mappings":[{"account":"1200","externalId":"01a15873-a19f-7e60-9a1d-3f8c2b6e4a10","externalCode":"615","externalName":"Trade debtors clearing","created":false},{"account":"1400","externalId":"01a1588b-d641-7a82-8b3f-5a1e4d8c6b32","externalCode":"630","externalName":"Inventory","created":false},{"account":"2200","externalId":"01a15892-5a94-7ca4-ad5b-7c3a6f1e8d54","externalCode":"820","externalName":"GST","created":false},{"account":"4000","externalId":"01a15858-a1fe-7ec6-8f7d-9e5c8b3a0f76","externalCode":"200","externalName":"Sales","created":false},{"account":"5000","externalId":"01a15869-63f8-7fe8-9b9f-1a7e0d5c2b98","externalCode":"310","externalName":"Cost of Goods Sold","created":false},{"account":"2100","externalId":"01a15898-dee7-70cc-a208-4e5b60552d26","externalCode":"806","externalName":"Goods received not invoiced","created":false},{"account":"3900","externalId":"01a15896-13e8-7708-b853-cd30590fd955","externalCode":"975","externalName":"Opening balances","created":false}],"connectedAt":"2026-10-01T02:14:05.000Z","createdAt":"2026-10-01T02:14:05.000Z","updatedAt":"2026-10-01T02:21:47.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":"NotALedgerApp | NotThisLedgersApp | TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/NotALedgerAppEncoded"},{"$ref":"#/components/schemas/NotThisLedgersAppEncoded"},{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"LedgerNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LedgerNotFoundEncoded"}}}},"409":{"description":"LedgerDisconnected | MirroredFromSource","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/LedgerDisconnectedEncoded"},{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}]}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Set the account map whole: each Manifold account code onto an account of the other ledger — its id there, its code, its name, and whether the app created it. The ledger's own app alone, which checks each against its chart first (403 `NotALedgerApp`, `NotThisLedgersApp`). An account the app keeps needs no mapping. Appends `accounting.ledger-accounts-mapped`. Idempotent by content: the map as it stands appends nothing.\n\nRequires `financials:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MapLedgerAccountsEncoded"},"example":{"mappings":[{"account":"1200","externalId":"01a15873-a19f-7e60-9a1d-3f8c2b6e4a10","externalCode":"615","externalName":"Trade debtors clearing"},{"account":"1400","externalId":"01a1588b-d641-7a82-8b3f-5a1e4d8c6b32","externalCode":"630","externalName":"Inventory"},{"account":"2200","externalId":"01a15892-5a94-7ca4-ad5b-7c3a6f1e8d54","externalCode":"820","externalName":"GST"},{"account":"4000","externalId":"01a15858-a1fe-7ec6-8f7d-9e5c8b3a0f76","externalCode":"200","externalName":"Sales"},{"account":"5000","externalId":"01a15869-63f8-7fe8-9b9f-1a7e0d5c2b98","externalCode":"310","externalName":"Cost of Goods Sold"},{"account":"2100","externalId":"01a15898-dee7-70cc-a208-4e5b60552d26","externalCode":"806","externalName":"Goods received not invoiced"},{"account":"3900","externalId":"01a15896-13e8-7708-b853-cd30590fd955","externalCode":"975","externalName":"Opening balances"}]}}},"required":true},"x-mcp-withheld":"Only the ledger's own app, under its own token, connects its books, maps them, plans and answers their journals (NotALedgerApp for anyone else); an agent sends the merchant to the app's page under Apps instead.","x-required-scopes":["financials:write"],"x-example-source":{"origin":"contract"}}},"/ledgers/{ledgerId}/journals/plan":{"post":{"tags":["ledgers"],"operationId":"ledgers.plan","parameters":[{"name":"ledgerId","in":"path","schema":{"$ref":"#/components/schemas/LgrId"},"required":true,"example":"lgr_01a0f6b2-1c00-7f71-8a82-465768798a9b"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"LedgerPlan","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LedgerPlanEncoded"},"examples":{"contract":{"summary":"ledgers.plan","value":{"journals":[{"id":"ljn_2d65a17e-ddb1-a312-5355-d026330f09e7","ledgerId":"lgr_01a0f6b2-1c00-7f71-8a82-465768798a9b","date":"2026-10-20","granularity":"daily-summary","kind":"movements","narration":"Manifold · 2026-10-20 · 2 postings [ljn_2d65a17e-ddb1-a312-5355-d026330f09e7]","currency":"AUD","postingIds":["pst_01a1588b-1a20-7b31-9c42-132435465768","pst_01a1588b-1a20-7b31-9c42-243546576879"],"postingCount":2,"lines":[{"account":"1200","externalAccountId":"01a15873-a19f-7e60-9a1d-3f8c2b6e4a10","externalCode":"615","debitCents":10560,"creditCents":0},{"account":"1400","externalAccountId":"01a1588b-d641-7a82-8b3f-5a1e4d8c6b32","externalCode":"630","debitCents":0,"creditCents":3400},{"account":"2200","externalAccountId":"01a15892-5a94-7ca4-ad5b-7c3a6f1e8d54","externalCode":"820","debitCents":0,"creditCents":960},{"account":"4000","externalAccountId":"01a15858-a1fe-7ec6-8f7d-9e5c8b3a0f76","externalCode":"200","debitCents":0,"creditCents":9600},{"account":"5000","externalAccountId":"01a15869-63f8-7fe8-9b9f-1a7e0d5c2b98","externalCode":"310","debitCents":3400,"creditCents":0}],"attempt":0,"status":"requested","requestedAt":"2026-10-21T04:00:00.000Z"}],"requested":1,"waiting":[]}}}}}},"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":"NotALedgerApp | NotThisLedgersApp | TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/NotALedgerAppEncoded"},{"$ref":"#/components/schemas/NotThisLedgersAppEncoded"},{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"LedgerNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LedgerNotFoundEncoded"}}}},"409":{"description":"LedgerDisconnected | MirroredFromSource","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/LedgerDisconnectedEncoded"},{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}]}}}},"503":{"description":"ChartUnreadable | RequestLogUnavailable","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/ChartUnreadableEncoded"},{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}]}}}}},"description":"Plan what is unsent, the ledger's own app alone (403 `NotALedgerApp`, `NotThisLedgersApp`): every posting effective in the ledger's range that no journal of it claims is grouped by its settings, and each group whose accounts are all placed — mapped, or kept by the app — becomes a journal claiming its postings (`accounting.ledger-journal-requested`, keyed `journal:<ljn>`). A day with a posting on an unplaced account waits whole, said in `waiting`. Answers every open journal, oldest first, up to `limit` — so a delivery a crash cut short is handed out again. The range begins at the opening stocktake (`docs/stocktake.md`); when `syncFrom` is after its day, every posting before `syncFrom` is planned first as one `carried-forward` journal (keyed `journal:<ljn>`; the postings it read claimed beside it as `accounting.ledger-postings-claimed`, up to 1,000 a fact, in the same transaction) and day-by-day journals follow only once it is planned. Idempotent by state: a posting is claimed by one journal, so a second call plans nothing twice. A ledger without settings, or a tenant without an opening stocktake, plans nothing and says so. Each journal carries `currency`, the home currency its amounts are minor units of; books whose base currency is no longer the home currency plan nothing and say so.\n\nRequires `financials:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlanLedgerJournalsEncoded"},"example":{"limit":200}}},"required":true},"x-mcp-withheld":"Only the ledger's own app, under its own token, connects its books, maps them, plans and answers their journals (NotALedgerApp for anyone else); an agent sends the merchant to the app's page under Apps instead.","x-required-scopes":["financials:write"],"x-example-source":{"origin":"contract"}}},"/ledgers/{ledgerId}/journals":{"get":{"tags":["ledgers"],"operationId":"ledgers.journals","parameters":[{"name":"ledgerId","in":"path","schema":{"$ref":"#/components/schemas/LgrId"},"required":true,"example":"lgr_01a0f6b2-1c00-7f71-8a82-465768798a9b"},{"name":"status","in":"query","schema":{"$ref":"#/components/schemas/LedgerJournalStatus"},"required":false,"example":"delivered"},{"name":"limit","in":"query","schema":{"type":"string"},"required":false,"example":"50"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"LedgerJournalList","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LedgerJournalListEncoded"},"examples":{"contract":{"summary":"ledgers.journals","value":{"items":[{"id":"ljn_2d65a17e-ddb1-a312-5355-d026330f09e7","ledgerId":"lgr_01a0f6b2-1c00-7f71-8a82-465768798a9b","date":"2026-10-20","granularity":"daily-summary","kind":"movements","narration":"Manifold · 2026-10-20 · 2 postings [ljn_2d65a17e-ddb1-a312-5355-d026330f09e7]","currency":"AUD","postingIds":["pst_01a1588b-1a20-7b31-9c42-132435465768","pst_01a1588b-1a20-7b31-9c42-243546576879"],"postingCount":2,"lines":[{"account":"1200","externalAccountId":"01a15873-a19f-7e60-9a1d-3f8c2b6e4a10","externalCode":"615","debitCents":10560,"creditCents":0},{"account":"1400","externalAccountId":"01a1588b-d641-7a82-8b3f-5a1e4d8c6b32","externalCode":"630","debitCents":0,"creditCents":3400},{"account":"2200","externalAccountId":"01a15892-5a94-7ca4-ad5b-7c3a6f1e8d54","externalCode":"820","debitCents":0,"creditCents":960},{"account":"4000","externalAccountId":"01a15858-a1fe-7ec6-8f7d-9e5c8b3a0f76","externalCode":"200","debitCents":0,"creditCents":9600},{"account":"5000","externalAccountId":"01a15869-63f8-7fe8-9b9f-1a7e0d5c2b98","externalCode":"310","debitCents":3400,"creditCents":0}],"attempt":0,"status":"delivered","requestedAt":"2026-10-21T04:00:00.000Z","externalId":"01a1589c-983b-7a28-8d5e-7f1c9b3a6d20","answeredAt":"2026-10-21T04:00:02.000Z"},{"id":"ljn_2469a74c-33b1-1b1c-d054-c1fa4baf03c1","ledgerId":"lgr_01a0f6b2-1c00-7f71-8a82-465768798a9b","date":"2026-10-02","granularity":"daily-summary","kind":"movements","narration":"Manifold · 2026-10-02 · 1 posting [ljn_2469a74c-33b1-1b1c-d054-c1fa4baf03c1]","currency":"AUD","postingIds":["pst_01a0f6b1-3a00-7d51-9e62-9102132435b2"],"postingCount":1,"lines":[{"account":"1400","externalAccountId":"01a1588b-d641-7a82-8b3f-5a1e4d8c6b32","externalCode":"630","debitCents":102000,"creditCents":0},{"account":"2100","externalAccountId":"01a15898-dee7-70cc-a208-4e5b60552d26","externalCode":"806","debitCents":0,"creditCents":102000}],"attempt":0,"status":"delivered","externalId":"01a1588f-8f95-795a-af26-63bd0a5db020","requestedAt":"2026-10-02T04:00:00.000Z","answeredAt":"2026-10-02T04:00:02.000Z"},{"id":"ljn_2802c99b-35c9-49d4-5047-213a65502d25","ledgerId":"lgr_01a0f6b2-1c00-7f71-8a82-465768798a9b","date":"2026-10-01","granularity":"daily-summary","kind":"movements","narration":"Manifold · 2026-10-01 · 1 posting [ljn_2802c99b-35c9-49d4-5047-213a65502d25]","currency":"AUD","postingIds":["pst_01a0f6b0-9c40-7e61-8f72-0213243546a1"],"postingCount":1,"lines":[{"account":"1400","externalAccountId":"01a1588b-d641-7a82-8b3f-5a1e4d8c6b32","externalCode":"630","debitCents":48000,"creditCents":0},{"account":"3900","externalAccountId":"01a15896-13e8-7708-b853-cd30590fd955","externalCode":"975","debitCents":0,"creditCents":48000}],"attempt":0,"status":"delivered","externalId":"01a15880-aa45-7f2b-ade9-009fad2f5c3d","requestedAt":"2026-10-01T04:00:00.000Z","answeredAt":"2026-10-01T04:00:02.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":"LedgerNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LedgerNotFoundEncoded"}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"The ledger's journals, newest first (at most `limit`, default 100, at most 500): each with the postings it claims, its lines onto the other ledger's accounts and how it was answered. `status` narrows to one.\n\nRequires `financials:read`.","x-mcp-tool":{"name":"accounting_list_ledger_journals","title":"Accounting: Journals sent to another ledger","toolset":"accounting","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["financials:read"],"x-example-source":{"origin":"contract"}}},"/ledgers/{ledgerId}/journals/{journalId}":{"get":{"tags":["ledgers"],"operationId":"ledgers.journal","parameters":[{"name":"ledgerId","in":"path","schema":{"$ref":"#/components/schemas/LgrId"},"required":true,"example":"lgr_01a0f6b2-1c00-7f71-8a82-465768798a9b"},{"name":"journalId","in":"path","schema":{"$ref":"#/components/schemas/LjnId"},"required":true,"example":"ljn_2d65a17e-ddb1-a312-5355-d026330f09e7"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"LedgerJournal","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LedgerJournalEncoded"},"examples":{"contract":{"summary":"ledgers.journal","value":{"id":"ljn_2d65a17e-ddb1-a312-5355-d026330f09e7","ledgerId":"lgr_01a0f6b2-1c00-7f71-8a82-465768798a9b","date":"2026-10-20","granularity":"daily-summary","kind":"movements","narration":"Manifold · 2026-10-20 · 2 postings [ljn_2d65a17e-ddb1-a312-5355-d026330f09e7]","currency":"AUD","postingIds":["pst_01a1588b-1a20-7b31-9c42-132435465768","pst_01a1588b-1a20-7b31-9c42-243546576879"],"postingCount":2,"lines":[{"account":"1200","externalAccountId":"01a15873-a19f-7e60-9a1d-3f8c2b6e4a10","externalCode":"615","debitCents":10560,"creditCents":0},{"account":"1400","externalAccountId":"01a1588b-d641-7a82-8b3f-5a1e4d8c6b32","externalCode":"630","debitCents":0,"creditCents":3400},{"account":"2200","externalAccountId":"01a15892-5a94-7ca4-ad5b-7c3a6f1e8d54","externalCode":"820","debitCents":0,"creditCents":960},{"account":"4000","externalAccountId":"01a15858-a1fe-7ec6-8f7d-9e5c8b3a0f76","externalCode":"200","debitCents":0,"creditCents":9600},{"account":"5000","externalAccountId":"01a15869-63f8-7fe8-9b9f-1a7e0d5c2b98","externalCode":"310","debitCents":3400,"creditCents":0}],"attempt":0,"status":"delivered","requestedAt":"2026-10-21T04:00:00.000Z","externalId":"01a1589c-983b-7a28-8d5e-7f1c9b3a6d20","answeredAt":"2026-10-21T04:00:02.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":"LedgerNotFound | LedgerJournalNotFound","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/LedgerNotFoundEncoded"},{"$ref":"#/components/schemas/LedgerJournalNotFoundEncoded"}]}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"One journal, as its plan fixed it and as it was answered. 404 `LedgerJournalNotFound`.\n\nRequires `financials:read`.","x-mcp-withheld":"accounting_list_ledger_journals answers each journal whole: its postings, its lines and how the other ledger answered.","x-required-scopes":["financials:read"],"x-example-source":{"origin":"contract"}}},"/ledgers/{ledgerId}/journals/{journalId}/answer":{"post":{"tags":["ledgers"],"operationId":"ledgers.answer","parameters":[{"name":"ledgerId","in":"path","schema":{"$ref":"#/components/schemas/LgrId"},"required":true,"example":"lgr_01a0f6b2-1c00-7f71-8a82-465768798a9b"},{"name":"journalId","in":"path","schema":{"$ref":"#/components/schemas/LjnId"},"required":true,"example":"ljn_2d65a17e-ddb1-a312-5355-d026330f09e7"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"LedgerJournal","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LedgerJournalEncoded"},"examples":{"contract":{"summary":"ledgers.answer","value":{"id":"ljn_2d65a17e-ddb1-a312-5355-d026330f09e7","ledgerId":"lgr_01a0f6b2-1c00-7f71-8a82-465768798a9b","date":"2026-10-20","granularity":"daily-summary","kind":"movements","narration":"Manifold · 2026-10-20 · 2 postings [ljn_2d65a17e-ddb1-a312-5355-d026330f09e7]","currency":"AUD","postingIds":["pst_01a1588b-1a20-7b31-9c42-132435465768","pst_01a1588b-1a20-7b31-9c42-243546576879"],"postingCount":2,"lines":[{"account":"1200","externalAccountId":"01a15873-a19f-7e60-9a1d-3f8c2b6e4a10","externalCode":"615","debitCents":10560,"creditCents":0},{"account":"1400","externalAccountId":"01a1588b-d641-7a82-8b3f-5a1e4d8c6b32","externalCode":"630","debitCents":0,"creditCents":3400},{"account":"2200","externalAccountId":"01a15892-5a94-7ca4-ad5b-7c3a6f1e8d54","externalCode":"820","debitCents":0,"creditCents":960},{"account":"4000","externalAccountId":"01a15858-a1fe-7ec6-8f7d-9e5c8b3a0f76","externalCode":"200","debitCents":0,"creditCents":9600},{"account":"5000","externalAccountId":"01a15869-63f8-7fe8-9b9f-1a7e0d5c2b98","externalCode":"310","debitCents":3400,"creditCents":0}],"attempt":0,"status":"delivered","requestedAt":"2026-10-21T04:00:00.000Z","externalId":"01a1589c-983b-7a28-8d5e-7f1c9b3a6d20","answeredAt":"2026-10-21T04:00:02.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":"NotALedgerApp | NotThisLedgersApp | TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/NotALedgerAppEncoded"},{"$ref":"#/components/schemas/NotThisLedgersAppEncoded"},{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"LedgerNotFound | LedgerJournalNotFound","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/LedgerNotFoundEncoded"},{"$ref":"#/components/schemas/LedgerJournalNotFoundEncoded"}]}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Say how the other ledger answered a journal, the ledger's own app alone (403 `NotALedgerApp`, `NotThisLedgersApp`): `delivered`, with its id there (`accounting.ledger-journal-delivered`), or `refused`, with the reason (`accounting.ledger-journal-refused`, which releases the journal's postings so the next plan claims them under the next attempt's id). Idempotent by state: a journal is answered once (keyed `answer:<ljn>`), and a second answer returns the journal as the first left it.\n\nRequires `financials:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnswerLedgerJournal"},"example":{"outcome":"delivered","externalId":"01a1589c-983b-7a28-8d5e-7f1c9b3a6d20"}}},"required":true},"x-mcp-withheld":"Only the ledger's own app, under its own token, connects its books, maps them, plans and answers their journals (NotALedgerApp for anyone else); an agent sends the merchant to the app's page under Apps instead.","x-required-scopes":["financials:write"],"x-example-source":{"origin":"contract"}}},"/ledgers/{ledgerId}/reconciliation":{"get":{"tags":["ledgers"],"operationId":"ledgers.reconciliation","parameters":[{"name":"ledgerId","in":"path","schema":{"$ref":"#/components/schemas/LgrId"},"required":true,"example":"lgr_01a0f6b2-1c00-7f71-8a82-465768798a9b"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"LedgerReconciliation","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LedgerReconciliationEncoded"},"examples":{"contract":{"summary":"ledgers.reconciliation","value":{"opening":{"stocktakeId":"stk_01a0f6b0-9c40-7e61-8f72-021324354657","at":"2026-10-01T00:30:00.000Z"},"from":"2026-10-01T00:30:00.000Z","to":"2026-10-21T13:00:00.000Z","accounts":[{"account":"1200","ledgerDebitCents":10560,"ledgerCreditCents":0,"sentDebitCents":10560,"sentCreditCents":0},{"account":"1400","ledgerDebitCents":150000,"ledgerCreditCents":3400,"sentDebitCents":150000,"sentCreditCents":3400},{"account":"2100","ledgerDebitCents":0,"ledgerCreditCents":102000,"sentDebitCents":0,"sentCreditCents":102000},{"account":"2200","ledgerDebitCents":0,"ledgerCreditCents":960,"sentDebitCents":0,"sentCreditCents":960},{"account":"3900","ledgerDebitCents":0,"ledgerCreditCents":48000,"sentDebitCents":0,"sentCreditCents":48000},{"account":"4000","ledgerDebitCents":0,"ledgerCreditCents":9600,"sentDebitCents":0,"sentCreditCents":9600},{"account":"5000","ledgerDebitCents":3400,"ledgerCreditCents":0,"sentDebitCents":3400,"sentCreditCents":0}],"inStep":true,"pending":0,"waiting":["no place yet for the chart's default accounts: 1110, 1120, 1130, 1170, 1180, 1190, 1195, 1350, 2000, 2150, 2160, 2300, 2400, 2410, 4100, 4200, 4300, 5100, 5200, 6100, 6200, 7100, 7110"],"unplaced":[],"unmapped":["1110","1120","1130","1170","1180","1190","1195","1350","2000","2150","2160","2300","2400","2410","4100","4200","4300","5100","5200","6100","6200","7100","7110"]}}}}}},"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":"LedgerNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LedgerNotFoundEncoded"}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"ChartUnreadable | RequestLogUnavailable","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/ChartUnreadableEncoded"},{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}]}}}}},"description":"The trial balance over the ledger's range (from the opening stocktake — `opening` — to the end of today in the books' zone; empty, and `waiting` says why, before it) beside what its journals not refused carry, per account, debits and credits apart: `inStep` when every account matches; `pending` counts journals not yet answered; `waiting` says what holds the rest back — settings not saved, accounts not placed, recent refusals, more sent than the ledger holds (a person's to look at; nothing sent is ever undone). `unplaced` names, structured, the accounts with movement not yet sent that have nowhere to land (neither mapped nor kept by the app) — empty in `create` mode and before settings are saved. `unmapped` names the accounts the chart's roles need (each SKU-role or control-account default) that have no place, whether or not anything has posted to them yet — every one, in `map` mode with nothing mapped; empty in `create` mode and before settings are saved. The setup walk calls an accounting app's step done only when both are empty.\n\nRequires `financials:read`.","x-mcp-tool":{"name":"accounting_ledger_reconciliation","title":"Accounting: Ledger reconciliation","toolset":"accounting","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["financials:read"],"x-example-source":{"origin":"contract"}}},"/events":{"get":{"tags":["events"],"operationId":"events.list","parameters":[{"name":"since","in":"query","schema":{"type":"string"},"required":false,"example":"57"},{"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/accounting.ledger-connectedEncoded"},{"$ref":"#/components/schemas/accounting.ledger-disconnectedEncoded"},{"$ref":"#/components/schemas/accounting.ledger-settings-savedEncoded"},{"$ref":"#/components/schemas/accounting.ledger-accounts-mappedEncoded"},{"$ref":"#/components/schemas/accounting.ledger-journal-requestedEncoded"},{"$ref":"#/components/schemas/accounting.ledger-postings-claimedEncoded"},{"$ref":"#/components/schemas/accounting.ledger-journal-deliveredEncoded"},{"$ref":"#/components/schemas/accounting.ledger-journal-refusedEncoded"},{"$ref":"#/components/schemas/accounting.period-revaluedEncoded"}]}},"examples":{"contract":{"summary":"events.list","value":[{"_tag":"accounting.ledger-journal-requested","eventId":"evt_01a1588c-0e00-7a81-9b92-000000000057","txId":"tx_01a1588c-0e00-7a81-9b92-000000000057","tenantId":"org_01a1586e-f9f6-7a8b-9c7d-6e5f4a3b2c1d","sequence":57,"occurredAt":"2026-10-21T04:00:00.000Z","source":"accounting-manager","version":1,"actor":{"_tag":"app","id":"app_85cedb60-f616-4fe5-b9ea-dcd3689b4bc6","installationId":"ins_01a0f6b2-0b00-7e91-8ca2-68798a9bacbd"},"correlationId":"req_01a1588c-0e00-7a81-9b92-000000000057","payload":{"ledgerId":"lgr_01a0f6b2-1c00-7f71-8a82-465768798a9b","journalId":"ljn_2d65a17e-ddb1-a312-5355-d026330f09e7","attempt":0,"date":"2026-10-20","granularity":"daily-summary","kind":"movements","narration":"Manifold · 2026-10-20 · 2 postings [ljn_2d65a17e-ddb1-a312-5355-d026330f09e7]","currency":"AUD","postingIds":["pst_01a1588b-1a20-7b31-9c42-132435465768","pst_01a1588b-1a20-7b31-9c42-243546576879"],"postingCount":2,"lines":[{"account":"1200","externalAccountId":"01a15873-a19f-7e60-9a1d-3f8c2b6e4a10","externalCode":"615","debitCents":10560,"creditCents":0},{"account":"1400","externalAccountId":"01a1588b-d641-7a82-8b3f-5a1e4d8c6b32","externalCode":"630","debitCents":0,"creditCents":3400},{"account":"2200","externalAccountId":"01a15892-5a94-7ca4-ad5b-7c3a6f1e8d54","externalCode":"820","debitCents":0,"creditCents":960},{"account":"4000","externalAccountId":"01a15858-a1fe-7ec6-8f7d-9e5c8b3a0f76","externalCode":"200","debitCents":0,"creditCents":9600},{"account":"5000","externalAccountId":"01a15869-63f8-7fe8-9b9f-1a7e0d5c2b98","externalCode":"310","debitCents":3400,"creditCents":0}]}},{"_tag":"accounting.ledger-journal-delivered","eventId":"evt_01a1588c-0e00-7a81-9b92-000000000058","txId":"tx_01a1588c-0e00-7a81-9b92-000000000058","tenantId":"org_01a1586e-f9f6-7a8b-9c7d-6e5f4a3b2c1d","sequence":58,"occurredAt":"2026-10-21T04:00:02.000Z","source":"accounting-manager","version":1,"actor":{"_tag":"app","id":"app_85cedb60-f616-4fe5-b9ea-dcd3689b4bc6","installationId":"ins_01a0f6b2-0b00-7e91-8ca2-68798a9bacbd"},"correlationId":"req_01a1588c-0e00-7a81-9b92-000000000058","payload":{"ledgerId":"lgr_01a0f6b2-1c00-7f71-8a82-465768798a9b","journalId":"ljn_2d65a17e-ddb1-a312-5355-d026330f09e7","externalId":"01a1589c-983b-7a28-8d5e-7f1c9b3a6d20"}}]}}}}},"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 accounting events at-or-after `since` (a journal sequence number), oldest first: ledgers connected and let go, settings saved, accounts mapped, journals requested, delivered and refused, and each period end's reference rates fixed for revaluation (`accounting.period-revalued`). 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 `financials: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":["financials: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-21T04:05: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-21T04:05:00.000Z","sequence":58}}}}}},"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 `financials: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":["financials:read"],"x-example-source":{"origin":"contract"}}},"/replica/status":{"get":{"tags":["replica"],"operationId":"replica.status","parameters":[],"security":[{"bearer":[]}],"responses":{"200":{"description":"ReplicaStatusReport","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReplicaStatusReport"},"examples":{"contract":{"summary":"replica.status","value":{"warnBytes":268435456,"slots":[{"source":"inventory","slot":"accounting_inventory_events_sub","active":true,"lagBytes":4096,"stalled":false},{"source":"purchasing","slot":"accounting_purchasing_events_sub","active":true,"lagBytes":0,"stalled":false},{"source":"fulfillment","slot":"accounting_fulfillment_events_sub","active":true,"lagBytes":12288,"stalled":false}]}}}}}},"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":"Replication-slot health for accounting's read replica, one entry per configured source journal (inventory, purchasing, fulfillment). Each entry reports the slot name, whether a walsender is attached (`active`), and `lagBytes` — the WAL the source database is retaining for this consumer, measured on the source as `pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn)`. `stalled` is true when the slot is inactive, missing, unreachable, or lagging past `warnBytes` (`REPLICA_LAG_WARN_BYTES`, default 256 MiB). This matters because a stalled slot retains WAL on the *source* until its disk fills — check here (or the periodic `accounting.replica` log line) before that happens. Liveness is deliberately separate: `/healthz` stays 200 while this payload carries the warning. Empty `slots` means accounting is running without a replica (HTTP-source fallback). Break-glass for a permanently dead consumer: `SELECT pg_drop_replication_slot('<slot>')` on the source, then re-establish the subscription. Appends nothing: a read of facts already journalled.\n\nRequires `activity:read`.","x-mcp-withheld":"Replication lag between the journals and this service's read model: an operator's health signal, not merchant data.","x-required-scopes":["activity:read"],"x-example-source":{"origin":"contract"}}}},"components":{"schemas":{"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)"},"LedgerEntryType":{"type":"string","enum":["cogs","cogs-correction","cogs-reversal","write-down"],"description":"What a cost-of-goods ledger entry records: `cogs` (units dispatched, at the cost drawn), `cogs-correction` (a later-confirmed cost), `cogs-reversal` (units returned, negated) or `write-down` (stock that left unsold)."},"LedId":{"type":"string","pattern":"^led_[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 led-prefixed uuid, e.g. led_9f8c1c2e-0000-4000-8000-000000000000"},"OrdId":{"type":"string","pattern":"^ord_[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 ord-prefixed uuid, e.g. ord_9f8c1c2e-0000-4000-8000-000000000000"},"LinId":{"type":"string","pattern":"^lin_[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 lin-prefixed uuid, e.g. lin_9f8c1c2e-0000-4000-8000-000000000000"},"DspId":{"type":"string","pattern":"^dsp_[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 dsp-prefixed uuid, e.g. dsp_9f8c1c2e-0000-4000-8000-000000000000"},"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"},"LedgerEntryEncoded":{"type":"object","properties":{"entryId":{"$ref":"#/components/schemas/LedId"},"type":{"$ref":"#/components/schemas/LedgerEntryType"},"occurredAt":{"type":"string"},"effectiveAt":{"type":"string"},"sku":{"type":"string"},"quantity":{"type":"integer","minimum":0},"amountCents":{"type":"integer"},"orderId":{"$ref":"#/components/schemas/OrdId"},"lineId":{"$ref":"#/components/schemas/LinId"},"dispatchId":{"$ref":"#/components/schemas/DspId"},"poId":{"$ref":"#/components/schemas/PoId"},"uncostedQuantity":{"type":"integer","minimum":0},"memo":{"type":"string"}},"required":["entryId","type","occurredAt","effectiveAt","sku","quantity","amountCents","memo"],"additionalProperties":false},"LedgerPageEncoded":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/LedgerEntryEncoded"}},"total":{"type":"integer","minimum":0},"limit":{"type":"integer","exclusiveMinimum":0},"offset":{"type":"integer","minimum":0}},"required":["items","total","limit","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},"SkuUnitCostEncoded":{"type":"object","properties":{"sku":{"type":"string"},"unitCostCents":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"unitsSold":{"type":"integer","exclusiveMinimum":0},"amountCents":{"type":"integer"}},"required":["sku","unitCostCents","unitsSold","amountCents"],"additionalProperties":false},"CurrencyCode":{"type":"string"},"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"},"CostingDrawEncoded":{"type":"object","properties":{"receiptId":{"$ref":"#/components/schemas/RcptId"},"poId":{"$ref":"#/components/schemas/PoId"},"quantity":{"type":"integer","exclusiveMinimum":0},"unitCostCents":{"type":"number","minimum":0},"batchNumber":{"type":"string"},"expiresAt":{"type":"string"},"serials":{"type":"array","items":{"type":"string"}}},"required":["receiptId","quantity","unitCostCents"],"additionalProperties":false},"OrderCostingLineEncoded":{"type":"object","properties":{"lineId":{"$ref":"#/components/schemas/LinId"},"sku":{"type":"string"},"shippedUnits":{"type":"integer"},"cogsCents":{"type":"integer"},"uncostedUnits":{"type":"integer","minimum":0},"revenueCents":{"type":"integer"},"refundedCents":{"type":"integer"},"draws":{"type":"array","items":{"$ref":"#/components/schemas/CostingDrawEncoded"}}},"required":["lineId","sku","shippedUnits","cogsCents","uncostedUnits","revenueCents","refundedCents","draws"],"additionalProperties":false},"OrderCostingsEncoded":{"type":"object","properties":{"orderId":{"$ref":"#/components/schemas/OrdId"},"homeCurrency":{"$ref":"#/components/schemas/CurrencyCode"},"booksOpen":{"type":"boolean"},"lines":{"type":"array","items":{"$ref":"#/components/schemas/OrderCostingLineEncoded"}},"shippingChargedCents":{"type":"integer"},"shippingCostCents":{"type":"integer"},"refundedCents":{"type":"integer"},"postings":{"type":"integer","minimum":0}},"required":["orderId","homeCurrency","booksOpen","lines","shippingChargedCents","shippingCostCents","refundedCents","postings"],"additionalProperties":false},"AccountCodeParam":{"type":"string","minLength":1,"maxLength":20,"pattern":"^[A-Za-z0-9](?:[A-Za-z0-9 ._/-]*[A-Za-z0-9])?$","description":"a code in the tenant's chart of accounts, as text"},"PostingSource":{"type":"string","enum":["receipt","opening-stock","opening-stocktake","opening-balances","stocktake-variance","cogs","cogs-correction","cogs-reversal","write-down","supplier-invoice","landed-cost","sales-invoice","payment","refund","payout","supplier-payment","credit-given","shipping-cost","shipping-cost-void","revaluation","revaluation-reversal","carrier-payment","cash-recognition","basis-change","order-cost","order-cost-reversal"],"description":"The fact a general-ledger posting accounts for: stock-side `receipt`, `opening-stock`, `opening-stocktake` (the count that opens the general ledger), `opening-balances` (every item open when it did, against 3900), `stocktake-variance` (a later count's shortfall or gain), `cogs`, `cogs-correction`, `cogs-reversal`, `write-down`, `supplier-invoice`, `landed-cost`; sales-side `sales-invoice`, `payment`, `refund`, `credit-given`; `payout` (what a payment provider sent the merchant: its fees, exchange and reserves against the provider's clearing); `supplier-payment` (money paid to a supplier: its orders' payables settled against supplier payments clearing); `shipping-cost` (what a carrier charged for a booked parcel) and `shipping-cost-void` (its reversal when the booking is voided); `carrier-payment` (a parcel's carrier charge paid, through supplier payments clearing); `revaluation` (open foreign-currency items at a period end's rate, against 7110) and `revaluation-reversal` (the same undone on the first day of the next period); and, on the cash basis (`docs/accounting-basis.md`), `cash-recognition` (the share of a document's revenue, expense and tax that money just settled, out of its awaiting-payment account) and `basis-change` (what was still awaiting payment, recognised on the day the books moved to the accrual basis); `order-cost` (a cost journalled by hand on an order, against 2160) and its `order-cost-reversal`."},"PyoId":{"type":"string","pattern":"^pyo_[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 pyo-prefixed uuid, e.g. pyo_9f8c1c2e-0000-4000-8000-000000000000"},"PstId":{"type":"string","pattern":"^pst_[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 pst-prefixed uuid, e.g. pst_9f8c1c2e-0000-4000-8000-000000000000"},"AccountCodeEncoded":{"anyOf":[{"type":"string"},{"type":"integer"}]},"TaxClass":{"type":"string","enum":["standard","reduced","zero-rated","exempt","out-of-scope"],"description":"What a SKU is, for tax: `standard` (the standard rate), `reduced` (a reduced rate, e.g. UK 5 %), `zero-rated` (taxable at nothing — AU GST-free, UK/NZ zero-rated), `exempt` (input-taxed / exempt) or `out-of-scope` (not a supply: gift cards, deposits, duties)"},"TaxTreatment":{"type":"string","enum":["domestic","export","destination"],"description":"Where the goods go, for tax: `domestic` (the tenant's country), `export` (outside it: no tax) or `destination` (another EU member state, at that state's rate)"},"CountryCode":{"type":"string","pattern":"^[A-Z]{2}$","description":"ISO 3166-1 alpha-2, upper case"},"TaxRowKey":{"type":"object","properties":{"class":{"$ref":"#/components/schemas/TaxClass"},"treatment":{"$ref":"#/components/schemas/TaxTreatment"},"country":{"$ref":"#/components/schemas/CountryCode"},"rateBps":{"type":"integer","minimum":0,"maximum":10000,"description":"A rate in basis points (1000 = 10 %)"},"exempt":{"type":"boolean"}},"required":["class","treatment","country","rateBps","exempt"],"additionalProperties":false,"description":"What a tax breakdown row is: the class, treatment, country, rate and exemption its amounts are taxed alike by"},"PostingLineEncoded":{"type":"object","properties":{"account":{"$ref":"#/components/schemas/AccountCodeEncoded"},"debitCents":{"type":"integer","minimum":0},"creditCents":{"type":"integer","minimum":0},"currency":{"$ref":"#/components/schemas/CurrencyCode"},"amountCents":{"type":"integer","minimum":0},"sku":{"type":"string"},"lineId":{"$ref":"#/components/schemas/LinId"},"tax":{"$ref":"#/components/schemas/TaxRowKey"}},"required":["account"],"additionalProperties":false},"InvId":{"type":"string","pattern":"^inv_[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 inv-prefixed uuid, e.g. inv_9f8c1c2e-0000-4000-8000-000000000000"},"PayId":{"type":"string","pattern":"^pay_[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 pay-prefixed uuid, e.g. pay_9f8c1c2e-0000-4000-8000-000000000000"},"RfdId":{"type":"string","pattern":"^rfd_[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 rfd-prefixed uuid, e.g. rfd_9f8c1c2e-0000-4000-8000-000000000000"},"StkId":{"type":"string","pattern":"^stk_[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 stk-prefixed uuid, e.g. stk_9f8c1c2e-0000-4000-8000-000000000000"},"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"},"CrdId":{"type":"string","pattern":"^crd_[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 crd-prefixed uuid, e.g. crd_9f8c1c2e-0000-4000-8000-000000000000"},"GcdId":{"type":"string","pattern":"^gcd_[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 gcd-prefixed uuid, e.g. gcd_9f8c1c2e-0000-4000-8000-000000000000"},"AccountingPeriod":{"type":"string","pattern":"^\\d{4}-(0[1-9]|1[0-2])$","description":"A period of the books: a calendar month in the books' time zone (tax settings' `timeZone`), e.g. 2026-09"},"PostingEncoded":{"type":"object","properties":{"postingId":{"$ref":"#/components/schemas/PstId"},"source":{"$ref":"#/components/schemas/PostingSource"},"occurredAt":{"type":"string"},"effectiveAt":{"type":"string"},"lines":{"type":"array","items":{"$ref":"#/components/schemas/PostingLineEncoded"},"minItems":2},"orderId":{"$ref":"#/components/schemas/OrdId"},"invoiceId":{"$ref":"#/components/schemas/InvId"},"paymentId":{"$ref":"#/components/schemas/PayId"},"refundId":{"$ref":"#/components/schemas/RfdId"},"receiptId":{"$ref":"#/components/schemas/RcptId"},"poId":{"$ref":"#/components/schemas/PoId"},"stocktakeId":{"$ref":"#/components/schemas/StkId"},"payoutId":{"$ref":"#/components/schemas/PyoId"},"supplierPaymentId":{"$ref":"#/components/schemas/SpayId"},"creditId":{"$ref":"#/components/schemas/CrdId"},"giftCardId":{"$ref":"#/components/schemas/GcdId"},"period":{"$ref":"#/components/schemas/AccountingPeriod"},"sku":{"type":"string"},"memo":{"type":"string"}},"required":["postingId","source","occurredAt","effectiveAt","lines","memo"],"additionalProperties":false},"PostingPageEncoded":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/PostingEncoded"}},"total":{"type":"integer","minimum":0},"limit":{"type":"integer","exclusiveMinimum":0},"offset":{"type":"integer","minimum":0}},"required":["items","total","limit","offset"],"additionalProperties":false},"TrialBalanceLineEncoded":{"type":"object","properties":{"account":{"$ref":"#/components/schemas/AccountCodeEncoded"},"debitCents":{"type":"integer","minimum":0},"creditCents":{"type":"integer","minimum":0},"netCents":{"type":"integer"}},"required":["account","debitCents","creditCents","netCents"],"additionalProperties":false},"TrialBalanceEncoded":{"type":"object","properties":{"from":{"type":"string"},"to":{"type":"string"},"accounts":{"type":"array","items":{"$ref":"#/components/schemas/TrialBalanceLineEncoded"}},"debitCents":{"type":"integer","minimum":0},"creditCents":{"type":"integer","minimum":0}},"required":["from","to","accounts","debitCents","creditCents"],"additionalProperties":false},"OpenItemKind":{"type":"string","enum":["receivable","payable","clearing"],"description":"What an open item is the balance of: a `receivable` (an order's invoices less its payments), a `payable` (a purchase order's authorised supplier invoices) or `clearing` (a payment or refund in its provider's clearing account until a payout settles it)"},"PaymentProvider":{"type":"string","enum":["shopify-payments","paypal","stripe","other"],"description":"The payment provider that moved the money, each settling to a clearing account of its own: `shopify-payments`, `paypal`, `stripe`, or `other` for a gateway without one yet. Absent on a payment taken by hand."},"OpenItemEncoded":{"type":"object","properties":{"kind":{"$ref":"#/components/schemas/OpenItemKind"},"account":{"$ref":"#/components/schemas/AccountCodeEncoded"},"currency":{"$ref":"#/components/schemas/CurrencyCode"},"amountCents":{"type":"integer"},"homeCents":{"type":"integer"},"orderId":{"$ref":"#/components/schemas/OrdId"},"paymentId":{"$ref":"#/components/schemas/PayId"},"refundId":{"$ref":"#/components/schemas/RfdId"},"poId":{"$ref":"#/components/schemas/PoId"},"provider":{"$ref":"#/components/schemas/PaymentProvider"},"payoutId":{"$ref":"#/components/schemas/PyoId"},"openedAt":{"type":"string"}},"required":["kind","account","currency","amountCents","homeCents","openedAt"],"additionalProperties":false},"OpenBalanceEncoded":{"type":"object","properties":{"account":{"$ref":"#/components/schemas/AccountCodeEncoded"},"currency":{"$ref":"#/components/schemas/CurrencyCode"},"amountCents":{"type":"integer"},"homeCents":{"type":"integer"},"items":{"type":"integer","minimum":0}},"required":["account","currency","amountCents","homeCents","items"],"additionalProperties":false},"OpenItemPageEncoded":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/OpenItemEncoded"}},"balances":{"type":"array","items":{"$ref":"#/components/schemas/OpenBalanceEncoded"}},"total":{"type":"integer","minimum":0},"limit":{"type":"integer","exclusiveMinimum":0},"offset":{"type":"integer","minimum":0}},"required":["items","balances","total","limit","offset"],"additionalProperties":false},"SkuValuationLineEncoded":{"type":"object","properties":{"sku":{"type":"string"},"onHandUnits":{"type":"integer","minimum":0},"onHandValueCents":{"type":"integer","minimum":0},"avcoCents":{"type":"number","minimum":0}},"required":["sku","onHandUnits","onHandValueCents"],"additionalProperties":false},"InventoryValuationEncoded":{"type":"object","properties":{"totalUnits":{"type":"integer","minimum":0},"totalValueCents":{"type":"integer","minimum":0},"skus":{"type":"array","items":{"$ref":"#/components/schemas/SkuValuationLineEncoded"}}},"required":["totalUnits","totalValueCents","skus"],"additionalProperties":false},"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)"},"CostLayerEncoded":{"type":"object","properties":{"receiptId":{"$ref":"#/components/schemas/RcptId"},"poId":{"$ref":"#/components/schemas/PoId"},"sku":{"type":"string"},"remaining":{"type":"integer","minimum":0},"received":{"type":"integer","minimum":0},"unitCostMicros":{"type":"integer","minimum":0},"batchNumber":{"type":"string"},"serials":{"type":"array","items":{"type":"string"}},"expiresAt":{"type":"string"},"receivedAt":{"type":"string"},"closedAt":{"type":"string"},"costCurrency":{"$ref":"#/components/schemas/CurrencyCode"},"costRate":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]}},"required":["receiptId","sku","remaining","received","unitCostMicros","receivedAt"],"additionalProperties":false},"SkuValuationEncoded":{"type":"object","properties":{"sku":{"type":"string"},"onHandUnits":{"type":"integer","minimum":0},"onHandValueCents":{"type":"integer","minimum":0},"avcoCents":{"type":"number","minimum":0},"layers":{"type":"array","items":{"$ref":"#/components/schemas/CostLayerEncoded"}}},"required":["sku","onHandUnits","onHandValueCents","layers"],"additionalProperties":false},"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"},"LgrId":{"type":"string","pattern":"^lgr_[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 lgr-prefixed uuid, e.g. lgr_9f8c1c2e-0000-4000-8000-000000000000"},"LedgerStatus":{"type":"string","enum":["connected","disconnected"],"description":"`connected` — journals are planned for it once its settings are saved; `disconnected` — nothing more is planned; journals already there stay, and settings and the map are kept for a reconnect"},"JournalGranularity":{"type":"string","enum":["daily-summary","per-posting"],"description":"`daily-summary` — one journal per effective date, each account's debits and credits summed over the postings it carries; `per-posting` — one journal per posting, its lines as posted"},"AccountsMode":{"type":"string","enum":["map","create"],"description":"`map` — the merchant maps each Manifold account onto an account already in the other ledger (suggestions offered); a posting to an unmapped account waits; `create` — the app creates each Manifold account there under its own code, adopting one that already has it"},"IsoDay":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$","description":"A calendar day, e.g. 2026-03-31"},"LedgerAccountMappingEncoded":{"type":"object","properties":{"account":{"$ref":"#/components/schemas/AccountCodeEncoded"},"externalId":{"type":"string","minLength":1},"externalCode":{"type":"string"},"externalName":{"type":"string"},"created":{"type":"boolean"}},"required":["account","externalId","externalCode","externalName"],"additionalProperties":false},"LedgerEncoded":{"type":"object","properties":{"id":{"$ref":"#/components/schemas/LgrId"},"appId":{"$ref":"#/components/schemas/AppId"},"externalId":{"type":"string","minLength":1},"name":{"type":"string"},"baseCurrency":{"$ref":"#/components/schemas/CurrencyCode"},"status":{"$ref":"#/components/schemas/LedgerStatus"},"settings":{"type":"object","properties":{"granularity":{"$ref":"#/components/schemas/JournalGranularity"},"accounts":{"$ref":"#/components/schemas/AccountsMode"},"syncFrom":{"$ref":"#/components/schemas/IsoDay"}},"required":["granularity","accounts"],"additionalProperties":false},"mappings":{"type":"array","items":{"$ref":"#/components/schemas/LedgerAccountMappingEncoded"}},"connectedAt":{"type":"string"},"disconnectedAt":{"type":"string"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","appId","externalId","name","baseCurrency","status","connectedAt","createdAt","updatedAt"],"additionalProperties":false},"LedgerListEncoded":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/LedgerEncoded"}}},"required":["items"],"additionalProperties":false},"LedgerNotFoundEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["LedgerNotFound"]},"ledgerId":{"type":"string"}},"required":["_tag","ledgerId"],"additionalProperties":false},"ConnectLedgerEncoded":{"type":"object","properties":{"externalId":{"type":"string","minLength":1},"name":{"type":"string","maxLength":200},"baseCurrency":{"$ref":"#/components/schemas/CurrencyCode"}},"required":["externalId","name","baseCurrency"],"additionalProperties":false},"NotALedgerAppEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["NotALedgerApp"]}},"required":["_tag"],"additionalProperties":false},"NotThisLedgersAppEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["NotThisLedgersApp"]},"ledgerId":{"type":"string"}},"required":["_tag","ledgerId"],"additionalProperties":false},"LedgerCurrencyMismatchEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["LedgerCurrencyMismatch"]},"ledgerId":{"type":"string"},"baseCurrency":{"type":"string"},"homeCurrency":{"type":"string"}},"required":["_tag","ledgerId","baseCurrency","homeCurrency"],"additionalProperties":false},"DisconnectLedgerEncoded":{"type":"object","properties":{"reason":{"type":"string","maxLength":500}},"required":["reason"],"additionalProperties":false},"IsoDay_1":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$","description":"A calendar day, e.g. 2026-03-31"},"SaveLedgerSettingsEncoded":{"type":"object","properties":{"granularity":{"$ref":"#/components/schemas/JournalGranularity"},"accounts":{"$ref":"#/components/schemas/AccountsMode"},"syncFrom":{"$ref":"#/components/schemas/IsoDay_1"}},"required":["granularity","accounts"],"additionalProperties":false},"LedgerDisconnectedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["LedgerDisconnected"]},"ledgerId":{"type":"string"}},"required":["_tag","ledgerId"],"additionalProperties":false},"OpeningStocktakeRequiredEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["OpeningStocktakeRequired"]},"reason":{"type":"string"}},"required":["_tag","reason"],"additionalProperties":false},"LedgerSyncStartedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["LedgerSyncStarted"]},"ledgerId":{"type":"string"},"syncFrom":{"$ref":"#/components/schemas/IsoDay_1"}},"required":["_tag","ledgerId"],"additionalProperties":false},"SyncFromOutOfRangeEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["SyncFromOutOfRange"]},"syncFrom":{"$ref":"#/components/schemas/IsoDay_1"},"earliest":{"$ref":"#/components/schemas/IsoDay_1"},"latest":{"$ref":"#/components/schemas/IsoDay_1"}},"required":["_tag","syncFrom","earliest","latest"],"additionalProperties":false},"MapLedgerAccountsEncoded":{"type":"object","properties":{"mappings":{"type":"array","items":{"$ref":"#/components/schemas/LedgerAccountMappingEncoded"},"maxItems":5000}},"required":["mappings"],"additionalProperties":false},"PlanLedgerJournalsEncoded":{"type":"object","properties":{"limit":{"type":"integer","exclusiveMinimum":0,"maximum":500}},"additionalProperties":false},"LjnId":{"type":"string","pattern":"^ljn_[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 ljn-prefixed uuid, e.g. ljn_9f8c1c2e-0000-4000-8000-000000000000"},"LedgerJournalKind":{"type":"string","enum":["movements","carried-forward"],"description":"`movements` — postings grouped as the ledger's `granularity` says; `carried-forward` — every posting from the opening stocktake to the day before `syncFrom`, summed per account into one journal dated that day, sent first so a ledger that starts later starts from the same opening balance"},"LedgerJournalLineEncoded":{"type":"object","properties":{"account":{"$ref":"#/components/schemas/AccountCodeEncoded"},"externalAccountId":{"type":"string","minLength":1},"externalCode":{"type":"string"},"debitCents":{"type":"integer","minimum":0},"creditCents":{"type":"integer","minimum":0}},"required":["account","externalAccountId"],"additionalProperties":false},"LedgerJournalStatus":{"type":"string","enum":["requested","delivered","refused"],"description":"`requested` — planned, its postings claimed, not yet answered; `delivered` — the other ledger holds it; `refused` — the other ledger would not take it, and its postings were released for a later attempt"},"LedgerJournalEncoded":{"type":"object","properties":{"id":{"$ref":"#/components/schemas/LjnId"},"ledgerId":{"$ref":"#/components/schemas/LgrId"},"date":{"$ref":"#/components/schemas/IsoDay_1"},"granularity":{"$ref":"#/components/schemas/JournalGranularity"},"kind":{"$ref":"#/components/schemas/LedgerJournalKind"},"narration":{"type":"string"},"currency":{"$ref":"#/components/schemas/CurrencyCode"},"postingIds":{"type":"array","items":{"$ref":"#/components/schemas/PstId"}},"postingCount":{"type":"integer","minimum":0},"lines":{"type":"array","items":{"$ref":"#/components/schemas/LedgerJournalLineEncoded"}},"attempt":{"type":"integer","minimum":0},"status":{"$ref":"#/components/schemas/LedgerJournalStatus"},"externalId":{"type":"string"},"reason":{"type":"string"},"requestedAt":{"type":"string"},"answeredAt":{"type":"string"}},"required":["id","ledgerId","date","granularity","kind","narration","currency","postingIds","postingCount","lines","attempt","status","requestedAt"],"additionalProperties":false},"LedgerPlanEncoded":{"type":"object","properties":{"journals":{"type":"array","items":{"$ref":"#/components/schemas/LedgerJournalEncoded"}},"requested":{"type":"integer","minimum":0},"waiting":{"type":"array","items":{"type":"string"}}},"required":["journals","requested","waiting"],"additionalProperties":false},"ChartUnreadableEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["ChartUnreadable"]},"reason":{"type":"string"}},"required":["_tag","reason"],"additionalProperties":false},"LedgerJournalListEncoded":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/LedgerJournalEncoded"}}},"required":["items"],"additionalProperties":false},"LedgerJournalNotFoundEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["LedgerJournalNotFound"]},"journalId":{"type":"string"}},"required":["_tag","journalId"],"additionalProperties":false},"JournalDeliveredEncoded":{"type":"object","properties":{"outcome":{"type":"string","enum":["delivered"]},"externalId":{"type":"string","minLength":1}},"required":["outcome","externalId"],"additionalProperties":false},"JournalRefusedEncoded":{"type":"object","properties":{"outcome":{"type":"string","enum":["refused"]},"reason":{"type":"string","minLength":1,"maxLength":1000}},"required":["outcome","reason"],"additionalProperties":false},"AnswerLedgerJournal":{"anyOf":[{"$ref":"#/components/schemas/JournalDeliveredEncoded"},{"$ref":"#/components/schemas/JournalRefusedEncoded"}]},"LedgerReconciliationLineEncoded":{"type":"object","properties":{"account":{"$ref":"#/components/schemas/AccountCodeEncoded"},"ledgerDebitCents":{"type":"integer","minimum":0},"ledgerCreditCents":{"type":"integer","minimum":0},"sentDebitCents":{"type":"integer","minimum":0},"sentCreditCents":{"type":"integer","minimum":0}},"required":["account","ledgerDebitCents","ledgerCreditCents","sentDebitCents","sentCreditCents"],"additionalProperties":false},"LedgerReconciliationEncoded":{"type":"object","properties":{"opening":{"type":"object","properties":{"stocktakeId":{"$ref":"#/components/schemas/StkId"},"at":{"type":"string"}},"required":["stocktakeId","at"],"additionalProperties":false},"from":{"type":"string"},"to":{"type":"string"},"accounts":{"type":"array","items":{"$ref":"#/components/schemas/LedgerReconciliationLineEncoded"}},"inStep":{"type":"boolean"},"pending":{"type":"integer","minimum":0},"waiting":{"type":"array","items":{"type":"string"}},"unplaced":{"type":"array","items":{"$ref":"#/components/schemas/AccountCodeEncoded"}},"unmapped":{"type":"array","items":{"$ref":"#/components/schemas/AccountCodeEncoded"}}},"required":["from","to","accounts","inStep","pending","waiting","unplaced","unmapped"],"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>"},"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"},"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}]},"accounting.ledger-connectedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["accounting.ledger-connected"]},"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":{"ledgerId":{"$ref":"#/components/schemas/LgrId"},"appId":{"$ref":"#/components/schemas/AppId"},"externalId":{"type":"string","minLength":1},"name":{"type":"string"},"baseCurrency":{"$ref":"#/components/schemas/CurrencyCode"}},"required":["ledgerId","appId","externalId","name","baseCurrency"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"accounting.ledger-disconnectedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["accounting.ledger-disconnected"]},"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":{"ledgerId":{"$ref":"#/components/schemas/LgrId"},"reason":{"type":"string"}},"required":["ledgerId","reason"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"LedgerSettingsEncoded":{"type":"object","properties":{"granularity":{"$ref":"#/components/schemas/JournalGranularity"},"accounts":{"$ref":"#/components/schemas/AccountsMode"},"syncFrom":{"$ref":"#/components/schemas/IsoDay_1"}},"required":["granularity","accounts"],"additionalProperties":false},"accounting.ledger-settings-savedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["accounting.ledger-settings-saved"]},"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":{"ledgerId":{"$ref":"#/components/schemas/LgrId"},"settings":{"$ref":"#/components/schemas/LedgerSettingsEncoded"}},"required":["ledgerId","settings"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"accounting.ledger-accounts-mappedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["accounting.ledger-accounts-mapped"]},"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":{"ledgerId":{"$ref":"#/components/schemas/LgrId"},"mappings":{"type":"array","items":{"$ref":"#/components/schemas/LedgerAccountMappingEncoded"}}},"required":["ledgerId","mappings"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"accounting.ledger-journal-requestedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["accounting.ledger-journal-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":{"ledgerId":{"$ref":"#/components/schemas/LgrId"},"journalId":{"$ref":"#/components/schemas/LjnId"},"attempt":{"type":"integer","minimum":0},"date":{"$ref":"#/components/schemas/IsoDay_1"},"granularity":{"$ref":"#/components/schemas/JournalGranularity"},"kind":{"$ref":"#/components/schemas/LedgerJournalKind"},"narration":{"type":"string"},"currency":{"$ref":"#/components/schemas/CurrencyCode"},"postingIds":{"type":"array","items":{"$ref":"#/components/schemas/PstId"}},"postingCount":{"type":"integer","minimum":0},"claims":{"type":"object","properties":{"from":{"type":"string"},"to":{"type":"string"}},"required":["from","to"],"additionalProperties":false},"lines":{"type":"array","items":{"$ref":"#/components/schemas/LedgerJournalLineEncoded"}}},"required":["ledgerId","journalId","attempt","date","granularity","kind","narration","currency","postingIds","postingCount","lines"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"accounting.ledger-postings-claimedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["accounting.ledger-postings-claimed"]},"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":{"ledgerId":{"$ref":"#/components/schemas/LgrId"},"journalId":{"$ref":"#/components/schemas/LjnId"},"postingIds":{"type":"array","items":{"$ref":"#/components/schemas/PstId"},"maxItems":1000}},"required":["ledgerId","journalId","postingIds"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"accounting.ledger-journal-deliveredEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["accounting.ledger-journal-delivered"]},"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":{"ledgerId":{"$ref":"#/components/schemas/LgrId"},"journalId":{"$ref":"#/components/schemas/LjnId"},"externalId":{"type":"string","minLength":1}},"required":["ledgerId","journalId","externalId"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"accounting.ledger-journal-refusedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["accounting.ledger-journal-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":{"ledgerId":{"$ref":"#/components/schemas/LgrId"},"journalId":{"$ref":"#/components/schemas/LjnId"},"reason":{"type":"string"}},"required":["ledgerId","journalId","reason"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"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_1"},"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"},"accounting.period-revaluedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["accounting.period-revalued"]},"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":{"period":{"$ref":"#/components/schemas/AccountingPeriod"},"endsAt":{"type":"string"},"homeCurrency":{"$ref":"#/components/schemas/CurrencyCode"},"rates":{"type":"array","items":{"$ref":"#/components/schemas/FxCapture"}},"unrated":{"type":"array","items":{"$ref":"#/components/schemas/CurrencyCode"}}},"required":["period","endsAt","homeCurrency","rates","unrated"],"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."},"ReplicaSlotStatus":{"type":"object","properties":{"source":{"type":"string"},"slot":{"type":"string"},"active":{"type":"boolean"},"lagBytes":{"anyOf":[{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},{"type":"null"}]},"stalled":{"type":"boolean"},"reason":{"type":"string"}},"required":["source","slot","active","lagBytes","stalled"],"additionalProperties":false},"ReplicaStatusReport":{"type":"object","properties":{"warnBytes":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"slots":{"type":"array","items":{"$ref":"#/components/schemas/ReplicaSlotStatus"}}},"required":["warnBytes","slots"],"additionalProperties":false}},"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":"ledger","description":"The append-only COGS ledger, derived by replay."},{"name":"postings","description":"The general ledger: balanced double-entry postings derived from the journals."},{"name":"valuation","description":"Inventory valuation from open cost layers."},{"name":"ledgers","description":"The other ledgers kept in step with the general ledger, and what has reached them."},{"name":"events","description":"Accounting's append-only event log: the ledgers it keeps in step."},{"name":"replica","description":"Operational visibility into the logical-replication read replica."}],"servers":[{"url":"https://accounting.getmanifold.io","description":"Production"}]}