Topolo Docs Topolo Platform
Open workspace

Get trial balance

Every account holding a balance at the date, each on one side only: debitMinor carries a debit balance, creditMinor a credit balance, and the other is zero. Accounts that net to nothing are left out. totalDebitMinor and totalCreditMinor are the sums of those balances and must agree, which is what balanced reports. These are balances, not turnover: they do not add up everything ever posted to an account, which would count both sides of every entry and count an expense again when a year-end close reverses it.

Outcome

Every account holding a balance at the date, each on one side only: debitMinor carries a debit balance, creditMinor a credit balance, and the other is zero. Accounts that net to nothing are left out. totalDebitMinor and totalCreditMinor are the sums of those balances and must agree, which is what balanced reports. These are balances, not turnover: they do not add up everything ever posted to an account, which would count both sides of every entry and count an expense again when a year-end close reverses it.

Before you start

  • Verify the intended environment, authenticated identity and specifically approved organization context.
  • The published application permission is ledger:read. Discover the exact granted canonical Books workspace and bind it separately from action input.

Discover the target

topolo whoami --json
topolo actions get app_topolo_books.ledger.trial_balance.get --detail --json
topolo resources topolo-books --json
topolo workspaces list topolo-books --json
  • Set BOOKS_WORKSPACE_ID to the exact granted workspace returned by discovery.

Request

GET /api/ledger/trial-balance

Inspect and test this action. Save the reviewed input as payload.json; supply credential/resource context separately.

Input fields

FieldRequiredMeaningSchema and constraints
asOfOptionalas Of{"type":"string","pattern":"^\d{4}-\d{2}-\d{2}$"}

Inspect nested fields and the complete input schema.

Effects

  • Reads the trial balance from the balance projection without changing anything.

Interpret the response

Read $.rows[].accountId for the returned ledger_account identifier. Empty collections and nullable fields do not discover a target.

No verification needed for a read. A balanced flag of false means the projection needs app_topolo_books.ledger.balances.rebuild.

Inspect the success schema. CLI/MCP add their own transport envelope; CLI --detail requests the full result.

Worked examples

Actual Books route handlers and the exported Worker were exercised against five local SQLite D1 concern databases with all committed migrations, the real posting Durable Object and local R2. Route captures use synthetic verified Auth; Worker captures use synthetic Auth transports. Nexus, Brand, Notify, Pay, Mercury and Xero responses are explicitly simulated at the provider transport boundary. Captures prove local request/response behavior and canonical SDK projection, not live bank access, payment movement, email delivery, provider eligibility, tax compliance, encrypted custody, scheduled execution, deployment or production completion. Fixture identities, credentials, addresses and records authorize no live operation.

Run a reviewed request

Save the input from the selected worked example as payload.json. Validate and inspect the plan before calling the action; refused examples demonstrate errors and are not instructions to execute.

CLI:

topolo actions validate app_topolo_books.ledger.trial_balance.get --data @payload.json --json
topolo actions plan app_topolo_books.ledger.trial_balance.get --resource-type workspace --resource-id "$BOOKS_WORKSPACE_ID" --data @payload.json --json
topolo actions call app_topolo_books.ledger.trial_balance.get --resource-type workspace --resource-id "$BOOKS_WORKSPACE_ID" --data @payload.json --detail --json

MCP tool and arguments for the first successful example:

{
  "tool": "topolo_read_action",
  "arguments": {
    "actionId": "app_topolo_books.ledger.trial_balance.get",
    "input": {
      "asOf": "2026-09-30"
    },
    "resourceType": "workspace",
    "resourceId": "<exact granted workspace id>",
    "detail": true
  }
}

Refused response · auth_error

Input · payload.json:

{
  "asOf": "2026-01-31"
}

Captured response · HTTP 401

{
  "error": "API key validation failed"
}

HTTP 401. SDK error code auth_error. Authenticate in the intended organization again. Verify whoami and the exact Books application/workspace binding before retrying; do not switch identity to work around a refusal.

Successful response · HTTP 200

Input · payload.json:

{
  "asOf": "2026-09-30"
}

Captured response · HTTP 200

{
  "asOf": "2026-09-30",
  "currency": "GBP",
  "rows": [
    {
      "accountId": "acc_7fd589d17dfd4102b46ae5c11af56219",
      "code": "4000",
      "name": "Sales",
      "type": "income",
      "debitMinor": 0,
      "creditMinor": 90000,
      "balanceMinor": -90000
    },
    {
      "accountId": "acc_c206051b6715441f93e04faf3dc052cd",
      "code": "6000",
      "name": "Advertising and marketing",
      "type": "expense",
      "debitMinor": 90000,
      "creditMinor": 0,
      "balanceMinor": 90000
    }
  ],
  "totalDebitMinor": 90000,
  "totalCreditMinor": 90000,
  "balanced": true
}

HTTP 200. No verification needed for a read. A balanced flag of false means the projection needs app_topolo_books.ledger.balances.rebuild.

Successful response · HTTP 200

Input · payload.json:

{
  "asOf": "2026-09-30"
}

Captured response · HTTP 200

{
  "asOf": "2026-09-30",
  "currency": "GBP",
  "rows": [
    {
      "accountId": "acc_873bdb78fad44749b99b4acacb376541",
      "code": "1000",
      "name": "Bank account",
      "type": "asset",
      "debitMinor": 500000,
      "creditMinor": 0,
      "balanceMinor": 500000
    },
    {
      "accountId": "acc_ed1238b8fa864827ac904306ca7c8f85",
      "code": "3000",
      "name": "Share capital",
      "type": "equity",
      "debitMinor": 0,
      "creditMinor": 500000,
      "balanceMinor": -500000
    }
  ],
  "totalDebitMinor": 500000,
  "totalCreditMinor": 500000,
  "balanced": true
}

HTTP 200. No verification needed for a read. A balanced flag of false means the projection needs app_topolo_books.ledger.balances.rebuild.

Successful response · HTTP 200

Input · payload.json:

{
  "asOf": "2026-09-30"
}

Captured response · HTTP 200

{
  "asOf": "2026-09-30",
  "currency": "GBP",
  "rows": [],
  "totalDebitMinor": 0,
  "totalCreditMinor": 0,
  "balanced": true
}

HTTP 200. No verification needed for a read. A balanced flag of false means the projection needs app_topolo_books.ledger.balances.rebuild.

Verify the result

  • No verification needed for a read. A balanced flag of false means the projection needs app_topolo_books.ledger.balances.rebuild.

Errors and recovery

  • auth_error (HTTP 401): Authenticate in the intended organization again. Verify whoami and the exact Books application/workspace binding before retrying; do not switch identity to work around a refusal.

These are observed local refusals. Shared authentication, schema validation and resource authorization can also refuse before the route. Preserve the actual error, details and request id.

Recovery boundary

Repeat a read in the same authorized context; no state is changed.

  • Get account ledger lines: General ledger detail for one account: lines in posting order, paged with limit and offset. openingBalanceMinor is the balance immediately before the returned page, including both activity before the requested range and earlier lines in that range.
  • Rebuild balance projection: Recompute the account balance projection from the ledger lines and report whether it already matched.

Evidence

Actual Books route handlers and the exported Worker were exercised against five local SQLite D1 concern databases with all committed migrations, the real posting Durable Object and local R2. Route captures use synthetic verified Auth; Worker captures use synthetic Auth transports. Nexus, Brand, Notify, Pay, Mercury and Xero responses are explicitly simulated at the provider transport boundary. Captures prove local request/response behavior and canonical SDK projection, not live bank access, payment movement, email delivery, provider eligibility, tax compliance, encrypted custody, scheduled execution, deployment or production completion. Fixture identities, credentials, addresses and records authorize no live operation.