Outcome
Read the exact Stripe balance transactions included in a payout, automatically clear posted Books payments by their balance-transaction reference, require an explicit ledger account for every remaining non-zero item, then post one balanced bank journal. Nothing posts while any amount is missing, guessed or does not exactly match the bank line.
Before you start
- Verify the intended environment, authenticated identity and specifically approved organization context.
- The published application permission is banking:write. Discover the exact granted canonical Books workspace and bind it separately from action input.
- Approve the actual mutation, accounting inputs and any provider/recipient effects before CLI --confirm or MCP confirm:true. Fixture identifiers and simulated provider responses authorize no live operation.
Discover the target
topolo whoami --json
topolo actions get app_topolo_books.bank.lines.provider_payout.reconcile --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.
- lineId: Exact bank line.id from bank.lines.list; inspect its current matching state before mutation.
- payoutId: Resolve this exact identifier through the related published reads for the same organization and workspace; never infer it from a name.
Request
POST /api/bank/lines/{lineId}/provider-payout
Inspect and test this action. Save the reviewed input as payload.json; supply credential/resource context separately.
Input fields
| Field | Required | Meaning | Schema and constraints |
|---|---|---|---|
lineId | Required | Exact bank line.id from bank.lines.list; inspect its current matching state before mutation. | {"type":"string","minLength":1} |
payoutId | Required | payout Id | {"type":"string","minLength":1} |
allocations | Optional | allocations | {"maxItems":499,"type":"array","items":{"type":"object","properties":{"balanceTransactionId":{"type":"string","minLength":1},"accountId":{"type":"string","minLength":1}},"required":["balanceTransactionId","accountId"],"additionalProperties":false}} |
overrideSoftLock | Optional | Explicit override of a soft accounting lock; inspect the lock and obtain authority before posting. | {"type":"boolean"} |
Inspect nested fields and the complete input schema.
Effects
- Reads the payout and every included Stripe balance transaction from Topolo Pay before writing.
- Posts one hash-chained journal only after the payout total exactly matches the bank line and every non-zero transaction resolves to a posted Books payment or a caller-selected ledger account.
- Marks the bank line matched to that journal.
Interpret the response
Read $.line.id for the returned bank_line identifier. Empty collections and nullable fields do not discover a target.
Call app_topolo_books.journals.get for the returned journal and confirm each Stripe balance transaction appears in its classification and journal memo. Call app_topolo_books.bank.lines.list with matchStatus matched and confirm the bank line points to the returned journal.
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.bank.lines.provider_payout.reconcile --data @payload.json --json
topolo actions plan app_topolo_books.bank.lines.provider_payout.reconcile --resource-type workspace --resource-id "$BOOKS_WORKSPACE_ID" --data @payload.json --json
topolo actions call app_topolo_books.bank.lines.provider_payout.reconcile --resource-type workspace --resource-id "$BOOKS_WORKSPACE_ID" --data @payload.json --confirm --detail --json
MCP tool and arguments for the first successful example:
{
"tool": "topolo_call_action",
"arguments": {
"actionId": "app_topolo_books.bank.lines.provider_payout.reconcile",
"input": {
"lineId": "bl_payout",
"payoutId": "po_test",
"allocations": [
{
"balanceTransactionId": "txn_hold",
"accountId": "acc_0222da28d68647f6888523777a95c82b"
},
{
"balanceTransactionId": "txn_old_fee",
"accountId": "acc_d13f1b5700d7462b899052fdb921e1d0"
},
{
"balanceTransactionId": "txn_billing",
"accountId": "acc_d13f1b5700d7462b899052fdb921e1d0"
}
]
},
"resourceType": "workspace",
"resourceId": "<exact granted workspace id>",
"confirm": true,
"detail": true
}
}
Refused response · auth_error
Input · payload.json:
{
"lineId": "bl_stripe_1",
"payoutId": "po_123",
"allocations": [
{
"balanceTransactionId": "txn_minimum_hold",
"accountId": "acc_stripe_balance"
}
]
}
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 201
Input · payload.json:
{
"lineId": "bl_payout",
"payoutId": "po_test",
"allocations": [
{
"balanceTransactionId": "txn_hold",
"accountId": "acc_0222da28d68647f6888523777a95c82b"
},
{
"balanceTransactionId": "txn_old_fee",
"accountId": "acc_d13f1b5700d7462b899052fdb921e1d0"
},
{
"balanceTransactionId": "txn_billing",
"accountId": "acc_d13f1b5700d7462b899052fdb921e1d0"
}
]
}
Captured response · HTTP 201
{
"line": {
"id": "bl_payout",
"organization_id": "org_payout_muvnpbb31",
"workspace_id": "ws_payout_muvnpbb31",
"bank_account_id": "bk_payout",
"source": "statement",
"provider_transaction_id": "mercury-payout",
"posted_on": "2026-09-29",
"period_key": "2026-09",
"amount_minor": 123894,
"currency": "USD",
"description": "STRIPE PAYOUT",
"counterparty": null,
"memo": null,
"kind": null,
"provider_status": null,
"fingerprint": "fp-payout",
"match_status": "matched",
"matched_event_id": "je_6dbcf7ae75664c2fb0c20fffaa8637be",
"raw": null,
"imported_at": "2026-09-29T00:00:00Z",
"updated_at": "2026-10-05T19:42:23.917Z",
"duplicate_of": null,
"coded_account_id": null,
"matched_document_id": null,
"matched_payment_id": null,
"reconciled_at": "2026-10-05T19:42:23.917Z",
"reconciled_by": "usr_test",
"coded_by_rule_id": null,
"xero_coding": null
},
"journal": {
"id": "je_6dbcf7ae75664c2fb0c20fffaa8637be",
"organization_id": "org_payout_muvnpbb31",
"workspace_id": "ws_payout_muvnpbb31",
"sequence": 3,
"period_key": "2026-09",
"posted_on": "2026-09-29",
"event_type": "journal_posted",
"journal_type": "provider_payout",
"description": "Stripe payout po_test",
"reference": "po_test",
"source_app": "topolo-books",
"source_document_type": "bank_line",
"source_document_id": "bl_payout",
"actor_type": "human",
"actor_id": "usr_test",
"autonomy_level": null,
"correlation_id": "req_test",
"idempotency_key": "provider_payout:po_test",
"reverses_event_id": null,
"reversed_by_event_id": null,
"total_debit_minor": 125268,
"total_credit_minor": 125268,
"line_count": 5,
"previous_hash": "a3b12cd0143286480b783d3b101e1246e42b0f141f656ded4430b702b8c3e3b2",
"hash": "29ffad3824092788c88ad00406e90bd7d9e8e7cc78073f1f71941a420bc5709a",
"created_at": "2026-10-05T19:42:23.914Z",
"notes": "Exact Stripe payout composition: txn_charge charge 125268; txn_hold payout_minimum_balance_hold -1000; txn_old_fee adjustment -360; txn_billing stripe_fee -14"
},
"payoutId": "po_test",
"classifications": [
{
"transaction": {
"id": "txn_charge",
"amount": 132451,
"fee": 7183,
"net": 125268,
"currency": "usd",
"type": "charge",
"reportingCategory": "charge",
"description": "Invoice INV-1",
"sourceId": "ch_1",
"sourceType": "charge",
"chargeId": "ch_1",
"paymentIntentId": "pi_1"
},
"accountId": "acc_569cc4fd72dd4cc29d6694080f9f8f83",
"source": "document_payment"
},
{
"transaction": {
"id": "txn_hold",
"amount": -1000,
"fee": 0,
"net": -1000,
"currency": "usd",
"type": "payout_minimum_balance_hold",
"reportingCategory": "payout_minimum_balance_hold",
"description": "Minimum balance held",
"sourceId": null,
"sourceType": null,
"chargeId": null,
"paymentIntentId": null
},
"accountId": "acc_0222da28d68647f6888523777a95c82b",
"source": "allocation"
},
{
"transaction": {
"id": "txn_old_fee",
"amount": -360,
"fee": 0,
"net": -360,
"currency": "usd",
"type": "adjustment",
"reportingCategory": "refund",
"description": "Retained fee",
"sourceId": "re_old",
"sourceType": "refund",
"chargeId": "ch_old",
"paymentIntentId": null
},
"accountId": "acc_d13f1b5700d7462b899052fdb921e1d0",
"source": "allocation"
},
{
"transaction": {
"id": "txn_billing",
"amount": -14,
"fee": 0,
"net": -14,
"currency": "usd",
"type": "stripe_fee",
"reportingCategory": "fee",
"description": "Stripe Billing fee",
"sourceId": null,
"sourceType": null,
"chargeId": null,
"paymentIntentId": null
},
"accountId": "acc_d13f1b5700d7462b899052fdb921e1d0",
"source": "allocation"
}
]
}
HTTP 201. Call app_topolo_books.journals.get for the returned journal and confirm each Stripe balance transaction appears in its classification and journal memo. Call app_topolo_books.bank.lines.list with matchStatus matched and confirm the bank line points to the returned journal.
Verify the result
- Call app_topolo_books.journals.get for the returned journal and confirm each Stripe balance transaction appears in its classification and journal memo.
- Call app_topolo_books.bank.lines.list with matchStatus matched and confirm the bank line points to the returned journal.
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
Unmatch the bank line to reverse the payout journal, then reconcile it again with corrected allocations.
Related actions
- Get journal: Read one journal event with every line, its account and its debit or credit, which is what reconciles against the ledger.
- List bank lines: List statement lines, filtered by account, match status or date, searched across description, counterparty, memo and the bank's transaction id, and sorted by posted date, amount, description or match status. Newest first unless you say otherwise; linkedOnly restricts them to accounts linked to a ledger account.
- List bank accounts: List the bank accounts reported by connected banks, with cached balances and the ledger account each maps to. linkedOnly returns just the accounts pointed at a ledger account.
- Unmatch a bank line: Put a line back to unmatched: a coding or transfer journal is reversed (both lines of a transfer return), an exclusion is lifted. A line matched to a document payment is refused, since the payment is the record.
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.