Outcome
Record money paid against a bill. The paid total is the sum of the payments, and the document becomes paid once they cover it.
Before you start
- Verify the intended environment, authenticated identity and specifically approved organization context.
- The published application permission is bills: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.bills.payments.record --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.
- documentId: Exact document.id from invoices.list/get or bills.list/get, as appropriate to this action; the displayed invoice number is distinct.
- bankLineId: Exact bank line.id from bank.lines.list in this workspace and bank account.
Request
POST /api/bills/{documentId}/payments
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 |
|---|---|---|---|
documentId | Required | Exact document.id from invoices.list/get or bills.list/get, as appropriate to this action; the displayed invoice number is distinct. | {"type":"string","minLength":1} |
paidOn | Required | paid On | {"type":"string","pattern":"^\d{4}-\d{2}-\d{2}$"} |
amountMinor | Required | Currency minor units as a safe integer, not a decimal money string. Follow this action’s sign and minimum constraints. | {"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991} |
reference | Optional | reference | {"anyOf":[{"type":"string","maxLength":200},{"type":"null"}]} |
bankLineId | Optional | Exact bank line.id from bank.lines.list in this workspace and bank account. | {"anyOf":[{"type":"string","minLength":1},{"type":"null"}]} |
Inspect nested fields and the complete input schema.
Effects
- Records money paid out. The paid total is the sum of the payments, and the bill becomes paid once they cover it.
Interpret the response
Read $.document.id for the returned bill identifier. Empty collections and nullable fields do not discover a target.
Call app_topolo_books.bills.get and check paid_minor and status.
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.bills.payments.record --data @payload.json --json
topolo actions plan app_topolo_books.bills.payments.record --resource-type workspace --resource-id "$BOOKS_WORKSPACE_ID" --data @payload.json --json
topolo actions call app_topolo_books.bills.payments.record --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.bills.payments.record",
"input": {
"documentId": "doc_ed6a61b948484d9c806b03ebfdf279ec",
"paidOn": "2026-09-02",
"amountMinor": 2500,
"reference": "Fixture bank payment"
},
"resourceType": "workspace",
"resourceId": "<exact granted workspace id>",
"confirm": true,
"detail": true
}
}
Refused response · auth_error
Input · payload.json:
{
"documentId": "doc_11bc",
"paidOn": "2026-02-20",
"amountMinor": 4999
}
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:
{
"documentId": "doc_ed6a61b948484d9c806b03ebfdf279ec",
"paidOn": "2026-09-02",
"amountMinor": 2500,
"reference": "Fixture bank payment"
}
Captured response · HTTP 201
{
"document": {
"id": "doc_ed6a61b948484d9c806b03ebfdf279ec",
"organization_id": "org_documentation-bill_muvnpncj3",
"workspace_id": "ws_documentation-bill_muvnpncj3",
"kind": "bill",
"contact_id": "con_bc225ee51ce54ade8a7ac316eccfae32",
"number": null,
"reference": "FIXTURE-PO",
"issue_date": "2026-09-01",
"due_date": null,
"period_key": "2026-09",
"currency": "GBP",
"exchange_rate": null,
"subtotal_minor": 2500,
"tax_minor": 0,
"total_minor": 2500,
"base_total_minor": 2500,
"paid_minor": 2500,
"status": "paid",
"notes": null,
"posted_event_id": "je_973c8413e0414d91b0ce72306d6aa1d1",
"source": "manual",
"source_document_id": null,
"created_at": "2026-10-05T19:42:39.488Z",
"updated_at": "2026-10-05T19:42:39.511Z",
"sequence_no": null,
"approved_at": "2026-10-05T19:42:39.498Z",
"sent_at": null,
"amounts_include_tax": 0,
"design_project_id": null,
"design_export_id": null,
"design_rendered_at": null,
"brand_kit_id": null,
"brand_version_id": null,
"written_off_minor": 0
},
"payments": [
{
"id": "pay_1a21d6cc142c4be8a30f9ad52df6516c",
"organization_id": "org_documentation-bill_muvnpncj3",
"workspace_id": "ws_documentation-bill_muvnpncj3",
"document_id": "doc_ed6a61b948484d9c806b03ebfdf279ec",
"paid_on": "2026-09-02",
"amount_minor": 2500,
"currency": "GBP",
"reference": "Fixture bank payment",
"bank_line_id": null,
"source": "manual",
"source_payment_id": null,
"created_at": "2026-10-05T19:42:39.510Z",
"updated_at": "2026-10-05T19:42:39.510Z",
"ledger_account_id": null,
"settlement_gross_minor": null,
"settlement_fee_minor": null,
"settlement_net_minor": null,
"settlement_currency": null,
"settlement_exchange_rate": null,
"settlement_reference": null,
"settlement_fee_details": null
}
]
}
HTTP 201. Call app_topolo_books.bills.get and check paid_minor and status.
Verify the result
- Call app_topolo_books.bills.get and check paid_minor and status.
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
A recorded payment cannot be removed through the API yet. Check the amount before sending.
Related actions
- List bills: List bills newest first. Filter by status, contact or issue date, search the number, reference and notes, and sort by issue date, due date, number, total or status. The response carries the outstanding total for the filtered set.
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.