Outcome
Preview or post multiple journals from a line-oriented CSV with journal, date, description, account_code, debit and credit columns plus optional reference and memo. Amounts are major currency units. Lines sharing a journal key form one balanced posting; re-importing the same journal is idempotent.
Before you start
- Verify the intended environment, authenticated identity and specifically approved organization context.
- The published application permission is journals: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.journals.import --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/journals/import
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 |
|---|---|---|---|
csv | Required | Actual CSV text with supported headers. Preview row outcomes and errors before a separately approved import. | {"type":"string","minLength":1,"maxLength":2000000} |
dryRun | Optional | Preview the operation when true; inspect the actual result before approving a state-changing run. | {"type":"boolean"} |
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
- With dryRun true (the default), validates and groups every CSV line without writing. Each journal is post, skip_existing or error.
- With dryRun false, appends every valid new journal to the immutable hash chain and updates balances. Rows marked posted return the new event id; skip_existing rows identify the event already held.
Interpret the response
Preview rows can contain eventId:null. Inspect every row outcome; after an approved posting discover the actual journals and retain only returned nonempty event ids.
Call app_topolo_books.ledger.verify and confirm ok is true, then read returned event ids with app_topolo_books.journals.get.
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.journals.import --data @payload.json --json
topolo actions plan app_topolo_books.journals.import --resource-type workspace --resource-id "$BOOKS_WORKSPACE_ID" --data @payload.json --json
topolo actions call app_topolo_books.journals.import --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.journals.import",
"input": {
"csv": "journal,date,description,reference,account_code,debit,credit,memo\nJ-1,2026-09-01,Opening capital,OPEN-1,1000,\"1,000.00\",,Cash\nJ-1,,,,3000,,\"1,000.00\",Capital\nJ-2,2026-09-02,Rent,,6500,250.50,,September\nJ-2,,,,1000,,250.50,\nBAD,2026-09-02,Unknown account,,9999,10.00,,\nBAD,,,,1000,,10.00,"
},
"resourceType": "workspace",
"resourceId": "<exact granted workspace id>",
"confirm": true,
"detail": true
}
}
Refused response · auth_error
Input · payload.json:
{
"csv": "journal,date,description,reference,account_code,debit,credit,memo\nACCR-01,2026-01-31,Hosting accrual,ACCR-01,6100,120.00,,January hosting\nACCR-01,2026-01-31,Hosting accrual,ACCR-01,2100,,120.00,",
"dryRun": true
}
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:
{
"csv": "journal,date,description,reference,account_code,debit,credit,memo\nJ-1,2026-09-01,Opening capital,OPEN-1,1000,\"1,000.00\",,Cash\nJ-1,,,,3000,,\"1,000.00\",Capital\nJ-2,2026-09-02,Rent,,6500,250.50,,September\nJ-2,,,,1000,,250.50,\nBAD,2026-09-02,Unknown account,,9999,10.00,,\nBAD,,,,1000,,10.00,"
}
Captured response · HTTP 200
{
"dryRun": true,
"rows": [
{
"row": 2,
"key": "J-1",
"postedOn": "2026-09-01",
"description": "Opening capital",
"reference": "OPEN-1",
"lineCount": 2,
"debitMinor": 100000,
"action": "post",
"reason": null,
"eventId": null
},
{
"row": 4,
"key": "J-2",
"postedOn": "2026-09-02",
"description": "Rent",
"reference": null,
"lineCount": 2,
"debitMinor": 25050,
"action": "post",
"reason": null,
"eventId": null
},
{
"row": 6,
"key": "BAD",
"postedOn": "2026-09-02",
"description": "Unknown account",
"reference": null,
"lineCount": 2,
"debitMinor": 1000,
"action": "error",
"reason": "Row 6: account 9999 was not found",
"eventId": null
}
],
"ready": 2,
"posted": 0,
"skipped": 0,
"errors": 1
}
HTTP 200. Call app_topolo_books.ledger.verify and confirm ok is true, then read returned event ids with app_topolo_books.journals.get.
Successful response · HTTP 200
Input · payload.json:
{
"csv": "journal,date,description,reference,account_code,debit,credit,memo\nJ-1,2026-09-01,Opening capital,OPEN-1,1000,\"1,000.00\",,Cash\nJ-1,,,,3000,,\"1,000.00\",Capital\nJ-2,2026-09-02,Rent,,6500,250.50,,September\nJ-2,,,,1000,,250.50,\nBAD,2026-09-02,Unknown account,,9999,10.00,,\nBAD,,,,1000,,10.00,",
"dryRun": false
}
Captured response · HTTP 200
{
"dryRun": false,
"rows": [
{
"row": 2,
"key": "J-1",
"postedOn": "2026-09-01",
"description": "Opening capital",
"reference": "OPEN-1",
"lineCount": 2,
"debitMinor": 100000,
"action": "posted",
"reason": null,
"eventId": "je_117ba7e1f9ef4b33bc76d355e96cfa14"
},
{
"row": 4,
"key": "J-2",
"postedOn": "2026-09-02",
"description": "Rent",
"reference": null,
"lineCount": 2,
"debitMinor": 25050,
"action": "posted",
"reason": null,
"eventId": "je_50d0da080a6e47c4aadc50616f851966"
},
{
"row": 6,
"key": "BAD",
"postedOn": "2026-09-02",
"description": "Unknown account",
"reference": null,
"lineCount": 2,
"debitMinor": 1000,
"action": "error",
"reason": "Row 6: account 9999 was not found",
"eventId": null
}
],
"ready": 0,
"posted": 2,
"skipped": 0,
"errors": 1
}
HTTP 200. Call app_topolo_books.ledger.verify and confirm ok is true, then read returned event ids with app_topolo_books.journals.get.
Successful response · HTTP 200
Input · payload.json:
{
"csv": "journal,date,description,reference,account_code,debit,credit,memo\nJ-1,2026-09-01,Opening capital,OPEN-1,1000,\"1,000.00\",,Cash\nJ-1,,,,3000,,\"1,000.00\",Capital\nJ-2,2026-09-02,Rent,,6500,250.50,,September\nJ-2,,,,1000,,250.50,\nBAD,2026-09-02,Unknown account,,9999,10.00,,\nBAD,,,,1000,,10.00,"
}
Captured response · HTTP 200
{
"dryRun": true,
"rows": [
{
"row": 2,
"key": "J-1",
"postedOn": "2026-09-01",
"description": "Opening capital",
"reference": "OPEN-1",
"lineCount": 2,
"debitMinor": 100000,
"action": "skip_existing",
"reason": "Already imported",
"eventId": "je_117ba7e1f9ef4b33bc76d355e96cfa14"
},
{
"row": 4,
"key": "J-2",
"postedOn": "2026-09-02",
"description": "Rent",
"reference": null,
"lineCount": 2,
"debitMinor": 25050,
"action": "skip_existing",
"reason": "Already imported",
"eventId": "je_50d0da080a6e47c4aadc50616f851966"
},
{
"row": 6,
"key": "BAD",
"postedOn": "2026-09-02",
"description": "Unknown account",
"reference": null,
"lineCount": 2,
"debitMinor": 1000,
"action": "error",
"reason": "Row 6: account 9999 was not found",
"eventId": null
}
],
"ready": 0,
"posted": 0,
"skipped": 2,
"errors": 1
}
HTTP 200. Call app_topolo_books.ledger.verify and confirm ok is true, then read returned event ids with app_topolo_books.journals.get.
Successful response · HTTP 200
Input · payload.json:
{
"csv": "journal,date,description,reference,account_code,debit,credit,memo\nDATES,2026-09-01,Conflict,,1000,1.00,,\nDATES,2026-09-02,,,3000,,1.00,\nBOTH,2026-09-01,Both,,1000,1.00,1.00,\nBOTH,,,,3000,,1.00,\nAMOUNT,2026-09-01,Amount,,1000,wrong,,\nAMOUNT,,,,3000,,1.00,\nZERO,2026-09-01,Zero,,1000,0.00,,\nZERO,,,,3000,,0.00,\nUNBALANCED,2026-09-01,Unbalanced,,1000,2.00,,\nUNBALANCED,,,,3000,,1.00,\nMISSING,,,,1000,1.00,,\nMISSING,,,,3000,,1.00,\nNOACCOUNT,2026-09-01,Missing account,,,1.00,,\nNOACCOUNT,,,,3000,,1.00,\nDESCRIPTION,2026-09-01,XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX,,1000,1.00,,\nDESCRIPTION,,,,3000,,1.00,\nREFERENCE,2026-09-01,Reference,RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR,1000,1.00,,\nREFERENCE,,,,3000,,1.00,\nMEMO,2026-09-01,Memo,,1000,1.00,,MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\nMEMO,,,,3000,,1.00,"
}
Captured response · HTTP 200
{
"dryRun": true,
"rows": [
{
"row": 2,
"key": "DATES",
"postedOn": null,
"description": "Conflict",
"reference": null,
"lineCount": 2,
"debitMinor": 100,
"action": "error",
"reason": "Conflicting dates",
"eventId": null
},
{
"row": 4,
"key": "BOTH",
"postedOn": "2026-09-01",
"description": "Both",
"reference": null,
"lineCount": 2,
"debitMinor": 0,
"action": "error",
"reason": "Row 4: enter either debit or credit",
"eventId": null
},
{
"row": 6,
"key": "AMOUNT",
"postedOn": "2026-09-01",
"description": "Amount",
"reference": null,
"lineCount": 2,
"debitMinor": 0,
"action": "error",
"reason": "Row 6: \"wrong\" is not a decimal amount",
"eventId": null
},
{
"row": 8,
"key": "ZERO",
"postedOn": "2026-09-01",
"description": "Zero",
"reference": null,
"lineCount": 2,
"debitMinor": 0,
"action": "error",
"reason": "Row 8: amount must be above zero",
"eventId": null
},
{
"row": 10,
"key": "UNBALANCED",
"postedOn": "2026-09-01",
"description": "Unbalanced",
"reference": null,
"lineCount": 2,
"debitMinor": 200,
"action": "error",
"reason": "Debits 200 do not equal credits 100 (difference 100 minor units)",
"eventId": null
},
{
"row": 12,
"key": "MISSING",
"postedOn": null,
"description": "",
"reference": null,
"lineCount": 2,
"debitMinor": 100,
"action": "error",
"reason": "Missing date",
"eventId": null
},
{
"row": 14,
"key": "NOACCOUNT",
"postedOn": "2026-09-01",
"description": "Missing account",
"reference": null,
"lineCount": 2,
"debitMinor": 100,
"action": "error",
"reason": "Row 14: missing account code",
"eventId": null
},
{
"row": 16,
"key": "DESCRIPTION",
"postedOn": "2026-09-01",
"description": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"reference": null,
"lineCount": 2,
"debitMinor": 100,
"action": "error",
"reason": "Description must be at most 500 characters",
"eventId": null
},
{
"row": 18,
"key": "REFERENCE",
"postedOn": "2026-09-01",
"description": "Reference",
"reference": "RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR",
"lineCount": 2,
"debitMinor": 100,
"action": "error",
"reason": "Reference must be at most 100 characters",
"eventId": null
},
{
"row": 20,
"key": "MEMO",
"postedOn": "2026-09-01",
"description": "Memo",
"reference": null,
"lineCount": 2,
"debitMinor": 100,
"action": "error",
"reason": "Row 20: memo must be at most 500 characters",
"eventId": null
}
],
"ready": 0,
"posted": 0,
"skipped": 0,
"errors": 10
}
HTTP 200. Call app_topolo_books.ledger.verify and confirm ok is true, then read returned event ids with app_topolo_books.journals.get.
Verify the result
- Call app_topolo_books.ledger.verify and confirm ok is true, then read returned event ids with app_topolo_books.journals.get.
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
Reverse each eventId from a row marked posted. Do not reverse skip_existing rows. Imported ledger events are never edited or deleted.
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.
- Verify ledger integrity: Prove the ledger has not been altered. depth full (the default) walks the whole chain, re-hashes every event, checks every posting balances and the cursor matches the chain tip, and names the sequence where any break happened; it reads the entire ledger, so it grows with the books. depth tip re-hashes only the newest event and checks the cursor still points at it, which is constant work and is what a screen refreshing on every load should ask for. Only full detects a change made to older history.
- List journals: List posted journal events, filtered by date range or period, searched across description, reference and journal type, and sorted by sequence, posted date, description or amount. Newest first unless you say otherwise.
- Reverse a journal: Post the reversal of a journal: the same lines negated, dated as requested (default the original date). A journal can be reversed once; corrections are reversals, never edits.
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.