Outcome
Connect a bank with a read-only API token. The token is verified against the bank first, stored encrypted in Nexus, then the bank's accounts are recorded. Refused with bank_credential_invalid if the bank rejects it.
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.connections.create --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
POST /api/bank/connections
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 |
|---|---|---|---|
provider | Required | provider | {"type":"string","enum":["mercury"]} |
apiToken | Required | Specifically authorized read-only provider token for the selected environment; supply securely and never copy fixture tokens. | {"type":"string","minLength":1,"maxLength":500} |
environment | Optional | Provider environment named by the schema; sandbox and live credentials/eligibility are separate. | {"type":"string","enum":["live","sandbox"]} |
label | Optional | label | {"anyOf":[{"type":"string","maxLength":120},{"type":"null"}]} |
Inspect nested fields and the complete input schema.
Effects
- Verifies the credential with the bank, stores it encrypted in Nexus, and records the accounts the bank reports. Books never returns the credential again.
Interpret the response
Read $.connection.id for the returned bank_connection identifier. Empty collections and nullable fields do not discover a target.
Call app_topolo_books.bank.accounts.list and confirm the bank's accounts appear.
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.connections.create --data @payload.json --json
topolo actions plan app_topolo_books.bank.connections.create --resource-type workspace --resource-id "$BOOKS_WORKSPACE_ID" --data @payload.json --json
topolo actions call app_topolo_books.bank.connections.create --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.connections.create",
"input": {
"provider": "mercury",
"apiToken": "tok",
"environment": "sandbox",
"label": "Topolo main"
},
"resourceType": "workspace",
"resourceId": "<exact granted workspace id>",
"confirm": true,
"detail": true
}
}
Successful response · HTTP 201
Input · payload.json:
{
"provider": "mercury",
"apiToken": "tok",
"environment": "sandbox",
"label": "Topolo main"
}
Captured response · HTTP 201
{
"connection": {
"id": "bcx_4556a8445af948028e268a0199fc44cf",
"organization_id": "org_route_muvnpuo912",
"workspace_id": "ws_route_muvnpuo912",
"provider": "mercury",
"environment": "sandbox",
"label": "Topolo main",
"nexus_connection_id": "nx_bcx_4556a8445af948028e268a0199fc44cf",
"connected_by_user_id": "usr_test",
"status": "active",
"last_synced_at": null,
"last_sync_error": null,
"sync_error_count": 0,
"created_at": "2026-10-05T19:42:48.973Z",
"updated_at": "2026-10-05T19:42:48.973Z"
},
"accounts": [
{
"id": "bac_4ed374718d8148ff8d468733a72267b0",
"organization_id": "org_route_muvnpuo912",
"workspace_id": "ws_route_muvnpuo912",
"connection_id": "bcx_4556a8445af948028e268a0199fc44cf",
"provider": "mercury",
"provider_account_id": "m-check",
"name": "Checking",
"nickname": null,
"kind": null,
"account_number_last4": "2222",
"currency": "USD",
"provider_status": "active",
"current_balance_minor": 500000,
"available_balance_minor": 490000,
"balance_as_of": "2026-10-05T19:42:48.973Z",
"ledger_account_id": null,
"status": "active",
"last_synced_at": null,
"sync_cursor": null,
"created_at": "2026-10-05T19:42:48.973Z",
"updated_at": "2026-10-05T19:42:48.973Z"
}
]
}
HTTP 201. Call app_topolo_books.bank.accounts.list and confirm the bank's accounts appear.
Successful response · HTTP 201
Input · payload.json:
{
"provider": "mercury",
"apiToken": "x",
"environment": "sandbox"
}
Captured response · HTTP 201
{
"connection": {
"id": "bcx_af649180c5e54338a27501ce5fbf5a19",
"organization_id": "org_route_muvnpuo912",
"workspace_id": "ws_route_muvnpuo912",
"provider": "mercury",
"environment": "sandbox",
"label": "Mercury · Topolo Technology Inc (sandbox)",
"nexus_connection_id": "nx_bcx_af649180c5e54338a27501ce5fbf5a19",
"connected_by_user_id": "usr_test",
"status": "active",
"last_synced_at": null,
"last_sync_error": null,
"sync_error_count": 0,
"created_at": "2026-10-05T19:42:48.988Z",
"updated_at": "2026-10-05T19:42:48.988Z"
},
"accounts": [
{
"id": "bac_4ed374718d8148ff8d468733a72267b0",
"organization_id": "org_route_muvnpuo912",
"workspace_id": "ws_route_muvnpuo912",
"connection_id": "bcx_af649180c5e54338a27501ce5fbf5a19",
"provider": "mercury",
"provider_account_id": "m-check",
"name": "Checking",
"nickname": "Main",
"kind": null,
"account_number_last4": "2222",
"currency": "USD",
"provider_status": "active",
"current_balance_minor": 500000,
"available_balance_minor": 490000,
"balance_as_of": "2026-10-05T19:42:48.988Z",
"ledger_account_id": null,
"status": "active",
"last_synced_at": "2026-10-05T19:42:48.979Z",
"sync_cursor": "2026-10-05",
"created_at": "2026-10-05T19:42:48.973Z",
"updated_at": "2026-10-05T19:42:48.988Z"
}
]
}
HTTP 201. Call app_topolo_books.bank.accounts.list and confirm the bank's accounts appear.
Refused response · dependency_unavailable
Input · payload.json:
{
"provider": "mercury",
"apiToken": "x",
"environment": "sandbox"
}
Captured response · HTTP 503
{
"error": "dependency_unavailable",
"message": "Mercury is temporarily unavailable (500). Try again shortly.",
"details": {
"provider": "mercury",
"retryable": true,
"operation": "/accounts",
"upstreamStatus": 500
}
}
HTTP 503. SDK error code dependency_unavailable. Inspect details.provider, operation, upstreamStatus and retryable. Restore provider availability; after any uncertain write read current state before a serial retry. Preserve the request id.
Refused response · bank_credential_invalid
Input · payload.json:
{
"provider": "mercury",
"apiToken": "bad"
}
Captured response · HTTP 400
{
"error": "bank_credential_invalid",
"message": "Mercury refused the token (401). Create a read-only token for the live environment and try again."
}
HTTP 400. SDK error code bank_credential_invalid. The provider refused the credential. Reconnect with a specifically authorized read-only token for the intended live or sandbox provider environment; do not retry the same invalid token.
Refused response · auth_error
Input · payload.json:
{
"provider": "mercury",
"apiToken": "secret-token:<a Mercury read-only API token>",
"environment": "live",
"label": "Operating account"
}
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.
Verify the result
- Call app_topolo_books.bank.accounts.list and confirm the bank's accounts appear.
Errors and recovery
dependency_unavailable(HTTP 503): Inspect details.provider, operation, upstreamStatus and retryable. Restore provider availability; after any uncertain write read current state before a serial retry. Preserve the request id.bank_credential_invalid(HTTP 400): The provider refused the credential. Reconnect with a specifically authorized read-only token for the intended live or sandbox provider environment; do not retry the same invalid token.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
Disconnect: the credential is revoked in Nexus and imported statement lines are kept.
Related actions
- Sync a bank connection: Pull posted transactions for every account on the connection. The first sync takes the whole history the bank still holds; later syncs are incremental. Pass
fromto re-read every account from that date. Idempotent on the bank's transaction id. - Update bank account mapping: Set the nickname and the ledger account (asset or liability) a bank account maps to. Everything else about the account is the bank's.
- 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.
- Disconnect a bank: Disconnect a bank: the credential is revoked in Nexus first; accounts are marked disconnected and imported lines are kept as statement history.
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.