For the complete documentation index, see llms.txt. This page is also available as Markdown.

Ledger API

Query the deterministic structured records the Brain protocol produces from Raw evidence. The Ledger is the single source of financial truth. Every row carries provenance, evidence references, and a confidence score.

Operation
Endpoint

List accounts

GET /v1/ledger/accounts

Account detail (+ latest balance)

GET /v1/ledger/accounts/{account_id}

List balances (point-in-time)

GET /v1/ledger/balances

List counterparties

GET /v1/ledger/counterparties

List invoices

GET /v1/ledger/invoices

List obligations

GET /v1/ledger/obligations

List transactions

GET /v1/ledger/transactions

Transaction detail

GET /v1/ledger/transactions/{transaction_id}

Promote Raw → Ledger

POST /v1/ledger/normalize

Trigger reconciliation

POST /v1/ledger/reconcile

List reconciliation matches

GET /v1/ledger/reconciliation-matches

List Transactions

GET /v1/ledger/transactions?account_id=acct_ops&since=2026-01-01&until=2026-03-31&direction=outflow
Authorization: Bearer <token>
{
  "transactions": [
    {
      "id": "tx_001",
      "account_id": "acct_ops",
      "external_transaction_id": "plaid_tx_abc",
      "amount": "-1234.56",
      "currency": "USD",
      "direction": "outflow",
      "transaction_date": "2026-01-15",
      "posted_date": "2026-01-16",
      "counterparty_id": "cp_aws",
      "category_id": "cat_cloud",
      "status": "posted",
      "description_normalized": "AWS - cloud services",
      "reconciliation_status": "matched",
      "source_ids": ["raw_8231"],
      "evidence_ids": ["rp_001"],
      "confidence": 0.98
    }
  ],
  "next_cursor": "..."
}

Filters: account_id, counterparty_id, direction (inflow | outflow | transfer | adjustment), status (pending | posted | cleared | failed | reversed | disputed), since, until, limit (default 100, max 1000), cursor. amount is a signed decimal string.

Get a Single Transaction

Returns the same Transaction shape. 404 if unknown.

List Accounts

account_type enum: bank_checking | bank_savings | card | loan | line_of_credit | onchain | payment_processor. Filters: status (active | closed | frozen | pending), account_type, limit (default 50, max 500), cursor.

For one account plus its latest balance:

List Balances (Point-in-Time)

Returns the balance row(s) effective at as_of (or the latest if omitted).

List Counterparties

type enum: merchant | vendor | customer | employer | employee | bank | wallet | exchange | tax_authority | agent | other. verified_status: unverified | self_attested | document_verified | sanctions_cleared. Each counterparty carries risk_level (low | medium | high | sanctioned), aliases[], and linked_accounts[].

List Invoices and Obligations

Invoice.status: draft | sent | partial | paid | overdue | cancelled | disputed. Obligation.type: bill | invoice | subscription | loan | rent | payroll | tax | card_statement | other.

Promote Raw → Ledger

Normalize a Raw-parsed row into typed Ledger entities. Idempotent. Re-running with the same input returns the same Ledger row ids.

Normalization derives every entity implied by the parsed row. The route accepts an optional target_entities field for forward compatibility, but the current handler ignores it: it reads only raw_parsed_id and produces the full entity set the parsed row supports.

Reconciliation

Trigger an async reconciliation pass:

202 Accepted{ "job_id": "rec_4711" }.

List matches:

match_type enum: transaction_receipt | invoice_payment | statement_balance | wallet_transfer | payroll_bank_debit | subscription_charge | card_charge | onchain_settlement | obligation_duplicate. status: unmatched | matched | partially_matched | duplicate_possible | disputed | cleared | failed | reversed.

Provenance on Every Row

Every Ledger row carries:

| Field | Description | | --------------------------- | ------------------------------------------ | -------- | --------- | --------------- | ------------------ | | source_ids | Raw artifact ids that produced it | | evidence_ids | Raw-parsed row ids the extractor consulted | | provenance | extracted | inferred | ambiguous | human_confirmed | agent_contributed | | confidence | Calibrated 0 to 1 score | | created_at / updated_at | Bitemporal timestamps |

Records are immutable. Corrections are written as superseding records that reference what they correct (supersedes field). The history is preserved end-to-end. Query GET /v1/audit/entity/{entityType}/{entityId} for the full causal trail.

What's Next

🧠 Wiki API

Reason over the Ledger in natural language.

📥 Raw and Ledger

The conceptual model.

Last updated