Treasury and bank reconciliation
Bank accounts with their own 572 sub-account, statement imports (Norma 43, CSV, XLSX), scored automatic matching (also against payments already recorded), the pending tray and its actions, rules, bank vs. ledger summary and the opening entry from a trial balance.
The treasury module keeps the ledger balance of every bank account (572xxxx) and cash account (570xxxx) equal to the bank's without manual work: you import the statement, Billora matches each transaction with issued invoices, expenses, payslips, taxes, transfers and fees, and whatever cannot be matched safely lands in a pending tray with scored suggestions you resolve with one request. The bank vs. ledger difference is always visible.
The whole flow has four steps:
- Bank account: create it and it receives its own ledger sub-account.
- Import a statement:
POST /treasury/imports/preview/to see how the file is read andPOST /treasury/imports/to import it. Rows are deduplicated, rules are applied and safe transactions are matched. - Reconcile the pending ones:
GET /treasury/transactions/?status=pendingand, for each one, an action (match,book,transfer,tax-payment,payroll,ignore) oraccept-suggestionsin bulk. - Check the summary:
GET /treasury/summary/with the bank balance, the ledger balance and the difference of every account.
Scopes: treasury:read (reads) / treasury:write (accounts, imports, reconciliation actions, rules and settings); the opening entry uses accounting:write. Like accounting, it is a plan feature (403 feature_not_available when not included) and writes require the OWNER or ADMIN role (403 role_forbidden). Every amount is a string with two decimals; a transaction's amount is signed (+ credit, − debit).
Bank accounts
/api/v1/treasury/bank-accounts/treasury:write{
"name": "BBVA main account",
"kind": "bank",
"iban": "ES91 2100 0418 4502 0005 1332",
"bic": "BBVAESMM",
"bank_name": "BBVA",
"currency": "EUR",
"is_default": true
}{
"id": 2,
"name": "BBVA main account",
"kind": "bank",
"iban": "ES9121000418450200051332",
"iban_formatted": "ES91 2100 0418 4502 0005 1332",
"bic": "BBVAESMM",
"bank_name": "BBVA",
"currency": "EUR",
"accounting_account": 512,
"accounting_account_code": "57200002",
"accounting_account_name": "BBVA main account",
"is_default": true,
"is_active": true,
"notes": "",
"last_statement_balance": null,
"last_statement_date": null,
"last_import_at": null,
"bank_balance": null,
"ledger_balance": "0.00",
"difference": null,
"pending_count": 0,
"created_at": "2026-10-01T09:12:44Z",
"updated_at": "2026-10-01T09:12:44Z"
}kindisbank(bank account) orcash(petty cash; no IBAN).- The
ibanis validated (format and check digits) and stored normalised, without spaces;iban_formattedreturns it in groups of four. An IBAN already used in the organization returns400 validation_error. - Automatic sub-account: creating the account assigns it its own ledger sub-account,
5720+ id for banks and5700+ id for cash (e.g.57200002), named after the account. Every payment and entry reconciled from that account debits or credits that sub-account, soledger_balancecan be compared withbank_balance(last known bank balance);differenceis bank − ledger and staysnulluntil you import a statement. Renaming the account renames the sub-account. - Invoice payments (
/payments/) and expense payments (/expense-payments/) created through the API acceptbank_account: their entry then uses that account's sub-account instead of the payment method's treasury account.
| Operation | Endpoint |
|---|---|
List (filters kind, is_active, is_default, search by name, IBAN or bank; ordering) | GET /treasury/bank-accounts/ |
| Detail, edit, deactivate | GET · PATCH /treasury/bank-accounts/{id}/ (is_active: false) |
Delete (only without imported transactions; otherwise 409 conflict: deactivate it) | DELETE /treasury/bank-accounts/{id}/ |
Bank vs. ledger summary of the account (?at=YYYY-MM-DD for balances at a date) | GET /treasury/bank-accounts/{id}/summary/ |
Importing statements
A statement is always imported into one bank account. Supported formats:
| Format | Detection | What is extracted |
|---|---|---|
Norma 43 (AEB) (.q43, .n43, .aeb, .c43 or .txt with 11/22/23/33/88 records) | By extension or content | Booking and value dates, signed amount, concept (including the complementary records), references, AEB common concept code (concept_code: 03 direct debits, 04 transfers, 11 payroll, 12 cards, 13 cash, 15 taxes, 17 fees…), opening and closing balances and the balance after each entry. File totals are validated; latin-1 and UTF-8 are accepted. |
| CSV | Separator ;, , or tab and encoding (UTF-8 with or without BOM, latin-1) detected | Columns recognised by their header in Spanish, English and Catalan: date, value date, concept, amount (or debit/credit), balance, reference, counterparty and IBAN. Spanish («1.234,56», «-1.234,56 €», «(123,45)») and English number formats; dates dd/mm/yyyy, dd-mm-yy, yyyy-mm-dd and Excel serials. |
| XLSX | First sheet whose header is recognised | Same as CSV. The header need not be on the first row: the first 40 rows are scanned and the rows above it (title, holder, IBAN…) are skipped. |
For CSV and XLSX there are bank presets detected from their header signature: BBVA, Banco Santander, CaixaBank, Banco Sabadell, Bankinter, ING, Openbank, Unicaja, Abanca, Kutxabank, Revolut Business, Revolut, Qonto, N26 and Wise. The Revolut Business statement gets its own treatment (separate fees and deduplication against the API): see Importing the Revolut Business CSV. When none fits, the generic column detector is used, and when that cannot identify the date, amount or concept, you name the columns yourself with mapping.
Preview
/api/v1/treasury/imports/preview/treasury:writeMultipart with file and, optionally, bank_account and mapping. Creates nothing: it returns the format, the preset, the detected columns, up to 20 sample rows already parsed, the confidence and the warnings.
curl https://api.billora.app/api/v1/treasury/imports/preview/ \
-H "Authorization: Bearer $BILLORA_API_KEY" \
-F "file=@statement-october.xlsx"import os, requests
with open("statement-october.xlsx", "rb") as fh:
res = requests.post(
"https://api.billora.app/api/v1/treasury/imports/preview/",
headers={"Authorization": f"Bearer {os.environ['BILLORA_API_KEY']}"},
files={"file": ("statement-october.xlsx", fh)},
timeout=60,
)
preview = res.json()
print(preview["confidence"], preview["bank_preset_label"], preview["issues"]){
"format": "xlsx",
"bank_preset": "bbva",
"bank_preset_label": "BBVA",
"sheet": "Movimientos",
"mapping": {
"date": "Fecha",
"value_date": "F.Valor",
"concept": "Concepto",
"amount": "Importe",
"balance": "Disponible",
"reference": "Observaciones",
"date_format": "%d/%m/%Y",
"decimal_separator": ",",
"skip_rows": 4,
"bank_preset": "bbva"
},
"confidence": "high",
"columns": ["Fecha", "F.Valor", "Concepto", "Movimiento", "Importe", "Divisa", "Disponible", "Observaciones"],
"sample_rows": [
{
"row_number": 6,
"date": "2026-10-02",
"value_date": "2026-10-02",
"amount": "-12.50",
"concept": "COMISION MANTENIMIENTO CUENTA",
"reference": "",
"counterparty_name": "",
"counterparty_iban": "",
"balance_after": "16788.35",
"concept_code": "",
"currency": "EUR"
}
],
"rows_total": 48,
"issues": [],
"opening_balance": null,
"closing_balance": null
}confidenceishigh(preset recognised and every sample row parsed),medium(no preset, or some sample row with an error) orlow(the date, amount or concept is missing: the import would fail with400).issueslists the warnings: unidentified column, rows that could not be parsed, header not recognised…- For Norma 43,
mappingis{"format": "n43"}and the response addsperiod_start,period_end,opening_balance,closing_balanceandaccount(IBAN or account number of the file). - A sample row that cannot be parsed comes with
errorandraw(the original cells) instead of the normalised fields.
Manual mapping
When the confidence is not high, send mapping (a JSON object; in multipart, as a JSON string) to both the preview and the import. Each column key accepts the header name or the column index (starting at 0):
| Key | Description |
|---|---|
date, value_date | Booking date column (required) and value date. |
concept | Concept column (required). |
amount or debit + credit | Signed amount, or debit/credit pair (both positive). |
balance, reference, counterparty, counterparty_iban | Balance after the entry, reference, counterparty name and IBAN. |
date_format | strptime format of the dates (%d/%m/%Y, %Y-%m-%d…); guessed from the sample when omitted. |
decimal_separator | , or .; guessed when omitted. |
skip_rows | Index of the header row (rows above it are ignored). |
invert_sign | true when the bank exports debits as positive numbers. |
bank_preset | Forces a preset (bbva, santander, caixabank, sabadell, bankinter, ing, openbank, unicaja, abanca, kutxabank, revolut_business, revolut, qonto, n26, wise). |
curl https://api.billora.app/api/v1/treasury/imports/ \
-H "Authorization: Bearer $BILLORA_API_KEY" \
-F "file=@transactions.csv" \
-F "bank_account=2" \
-F 'mapping={"date": "Fecha contable", "concept": "Detalle", "debit": "Cargo", "credit": "Abono", "balance": "Saldo", "date_format": "%d-%m-%Y", "decimal_separator": ",", "skip_rows": 2}'Import
/api/v1/treasury/imports/treasury:writeMultipart with file, bank_account and, optionally, mapping. Parses the file, creates the new transactions, updates the account's last known balance, applies the rules with auto_apply and runs the automatic matching, all in one database transaction per file. Returns 201 with the import:
{
"id": 57,
"bank_account": 2,
"bank_account_name": "BBVA main account",
"original_filename": "statement-october.xlsx",
"format": "xlsx",
"status": "done",
"mapping": { "date": "Fecha", "concept": "Concepto", "amount": "Importe", "balance": "Disponible", "date_format": "%d/%m/%Y", "decimal_separator": ",", "skip_rows": 4, "bank_preset": "bbva" },
"rows_total": 48,
"rows_new": 45,
"rows_duplicate": 3,
"rows_error": 0,
"auto_matched": 31,
"period_start": "2026-10-01",
"period_end": "2026-10-31",
"opening_balance": "16800.85",
"closing_balance": "18240.35",
"issues": [],
"error": "",
"created_by": 7,
"created_by_name": "Laura Gómez",
"created_at": "2026-11-02T08:31:10Z"
}- Deduplication: every entry has a fingerprint (account + date + amount + normalised concept + balance). Re-importing the same file, or one overlapping the previous one, duplicates nothing: repeated rows are counted in
rows_duplicate. When the bank gives no balance, rows are deduplicated by date + amount + concept while keeping legitimate identical entries within the same file. - Balance continuity: when the file carries an opening balance and the account already has earlier transactions, it is checked against the last known balance; if it does not link up,
issueswarns that an intermediate statement may be missing (and the warning shows up in the summary'salerts). For Norma 43 the totals of the closing record are also validated. - Rows that cannot be parsed do not block the rest: they are counted in
rows_errorwith the detail inerror. A file that cannot be parsed at all returns400 validation_error(fieldfile) and leaves the import withstatus: error. auto_matchedis the number of transactions resolved on their own (by rule or by automatic matching). The rest staypending.
| Operation | Endpoint |
|---|---|
Imports (filters bank_account, status, format) | GET /treasury/imports/ · GET /treasury/imports/{id}/ |
| Transactions created by an import | GET /treasury/imports/{id}/transactions/ |
Automatic matching
For every pending transaction the engine computes candidates with a score from 0 to 100 and readable reasons, and stores the five best in suggestions. The clues add up (capped at 100):
| Clue | Points |
|---|---|
| Amount equal to the document's outstanding balance or total (± tolerance) | 50 |
| Invoice number (issued or supplier's) in the concept | 40 |
| Party's VAT number in the concept | 30 |
| Party's name in the concept (full / partial) | 35 / 25 |
| Counterparty IBAN already associated with that customer or supplier | 25 |
| Hints learned from earlier transactions (per hint, up to 40) | 20 |
| Same supplier and amount in the last 45 days (recurring payment) | 20 |
| Payroll: "NÓMINA" concept or code 11 / employee name | 25 each |
| Partial payment (document identified, smaller amount) | +15, not "exact" |
| Payment already recorded without a bank account, with the same amount in euros | 50 (+10 when its date is within 3 days of the bank date) |
Suggestion types (kind): invoice (payment of an invoice, grouped payment of 2–4 invoices of the same customer adding up to the amount, or partial), expense (payment of an expense, grouped or partial; refund of a supplier credit note on credits), existing_payment (a payment you had already recorded by hand: it is linked instead of duplicated; see below), customer_advance (customer identified without a matching invoice), card_settlement (POS or gateway settlement: Stripe, Redsys, Adyen, SumUp… whose card payments of the period add up to the amount), payroll (a payslip or the month's payslips), tax_payment (AEAT, with the form and period deduced from the date; Social Security → book to 476/642), book (fees → 626, interest → 669/769, accounts used before), transfer (mirror transaction in another own account ±2 days, another account's IBAN in the concept, "TRASPASO", cash ↔ cash account), ignore (like similar transactions) and rule (matches a rule without auto_apply).
Payslips of another month. Two payslips of the same employee often have the same net amount. When the bank concept names a period different from the candidate payslip's ("NOMINA SEPTIEMBRE" against October's), the suggestion is kept with the notice "El concepto cita otro periodo" (−40 points; +10 when it names the payslip's own month), but it is never matched on its own.
Foreign-currency accounts. Transactions of an account that is not in euros (foreign_currency: true, with the reason in notice) get no suggestions and are never matched on their own, and any accounting action on them returns 409 foreign_currency_account; they can only be ignored. This is a current limitation: post their euro equivalent by hand and ignore the transaction.
What is matched automatically: a transaction is resolved on its own only when there is exactly one suggestion with an exact amount, identity evidence (number, VAT number, name, known IBAN, hint, mirror transaction…) and a score ≥ auto_match_threshold (85 by default), and it is also the best one; or when it matches a rule with auto_apply. Everything else stays pending with its suggestions. A credit with an exact amount from a known IBAN but no name or number (50 + 25 = 75), for instance, stays pending.
/api/v1/treasury/settings/treasury:write{ "auto_match_threshold": 85, "date_window_days": 180, "amount_tolerance": "0.02", "existing_payment_days_before": 120, "existing_payment_days_after": 120, "learn_rules": true }auto_match_threshold accepts 50 to 100; date_window_days is the window after the invoice or expense date (minus 5 days) in which candidates are searched; amount_tolerance is the difference accepted as an "exact amount" and, on reconciliation, booked to 769/669 as rounding; existing_payment_days_before and existing_payment_days_after (0–730, default 120 each) are the days before and after the bank date in which payments already recorded without a bank account are searched.
Rules
/api/v1/treasury/rules/treasury:write{
"name": "BBVA maintenance fee",
"concept_contains": ["COMISION MANTENIMIENTO", "CUOTA MANTENIMIENTO"],
"direction": "out",
"amount_max": "30.00",
"action": "expense",
"document_type": "bank_fee",
"supplier": 88,
"description": "Maintenance fee",
"auto_apply": true,
"priority": 10
}Conditions (at least one is required): concept_contains (list of texts; one of them appearing in the concept, counterparty or reference is enough, ignoring case and accents), counterparty_contains, amount_min / amount_max (absolute amount) and direction (in, out, any). Actions: expense (VAT-free expense with its payment; supplier, expense_category, document_type, optional accounting_account), book (entry to accounting_account, required), transfer (to target_bank_account, required) and ignore. Rules are evaluated by priority (lower first); with auto_apply they are applied on import and in the nightly recalculation, otherwise they show up as a rule suggestion (score 90). times_applied and learned_from are read-only.
| Operation | Endpoint |
|---|---|
List (filters is_active, action, direction, auto_apply, search) | GET /treasury/rules/ |
Apply the rule to every pending transaction that matches it ({rule, applied: [ids], errors: [{transaction, error}]}) | POST /treasury/rules/{id}/apply/ |
Learning
With learn_rules on, every transaction you resolve by hand leaves hints: the longest tokens of the concept, the IBAN and the counterparty name get associated with the chosen customer, supplier, ledger account or action, and add points to similar transactions later (one hint alone is not enough to match; two are). "As other times" suggestions (book to an account or ignore) are only proposed with a specific key: the learned IBAN or counterparty name, or a distinctive text (at least two learned words covering most of the concept). A single loose word is never enough, and a payroll concept is only suggested by IBAN or counterparty. If you also send remember: true in match, book, transfer or ignore, a rule with auto_apply is created from the transaction (counterparty or most specific token, plus direction), with learned_from pointing to it.
Suggestions of pending transactions are recalculated every night (new invoices and expenses appear) and with POST /treasury/transactions/{id}/rematch/.
Pending tray
/api/v1/treasury/transactions/?status=pending&bank_account=2treasury:readFilters: bank_account, statement_import, status (pending, matched, booked, transfer, ignored), date_from / date_to, direction (in / out), amount_min / amount_max (absolute amount), has_suggestions, auto_matched, concept_code, source (statement, revolut, manual), external_id, external_state, document (transactions reconciled with a document: invoice:<id>, expense:<id>, payment:<id> or expense_payment:<id>), search (concept, reference, counterparty or IBAN) and ordering (date, amount, created_at, status). Every row also carries foreign_currency and notice (a message for the user: foreign-currency account, transaction reverted at the bank). Every row carries its best suggestion (top_suggestion), the five best (suggestions) and allocations_summary; the detail GET /treasury/transactions/{id}/ adds the full allocations with their entries.
{
"id": 1842,
"bank_account": 2,
"bank_account_name": "BBVA main account",
"statement_import": 57,
"date": "2026-10-14",
"value_date": "2026-10-14",
"amount": "1452.00",
"currency": "EUR",
"direction": "in",
"concept": "TRANSFERENCIA RECIBIDA REF 0049123456",
"reference": "0049123456",
"counterparty_name": "",
"counterparty_iban": "ES7620770024003102575766",
"concept_code": "04",
"balance_after": "18240.35",
"status": "pending",
"status_display": "Pendiente de conciliar",
"matched_amount": "0.00",
"auto_matched": false,
"suggestions": [
{
"kind": "invoice",
"id": 980,
"label": "Cobro agrupado – facturas 2026-A-0147, 2026-A-0151 – Talleres Martín, S.L.",
"amount": "1452.00",
"score": 75,
"reasons": [
"Suma exacta de varias facturas pendientes del cliente",
"IBAN de la contraparte ya asociado a este tercero"
],
"params": { "invoices": [{ "id": 980, "amount": "968.00" }, { "id": 984, "amount": "484.00" }], "grouped": true },
"exact": true,
"identity": true
}
],
"top_suggestion": { "kind": "invoice", "id": 980, "score": 75, "…": "…" },
"allocations_summary": [],
"allocations": [],
"resolved_at": null,
"resolved_by": null,
"resolved_by_name": null,
"notes": "",
"created_at": "2026-11-02T08:31:11Z",
"updated_at": "2026-11-02T08:31:11Z"
}A suggestion's params is exactly what the matching action needs, so accepting it means passing params to match, book, transfer… (or using accept-suggestions). A suggestion without params (e.g. a card settlement whose payments do not add up) is only informative. Labels and reasons are in Spanish.
To pick by hand, GET /treasury/transactions/{id}/candidates/?q=martin&kind=invoice searches outstanding invoices or expenses, customers, suppliers, payslips or payments already recorded without a bank account (kind: invoice, expense, customer, supplier, payroll, payment or expense_payment; it defaults according to the sign of the transaction; q accepts a number, name, VAT number or amount) and returns [{kind, id, label, amount, date, party}].
The following actions are atomic, post their entries against the bank account's sub-account and return the full transaction (detail). They only apply to pending transactions.
Match with a split (match)
/api/v1/treasury/transactions/{id}/match/treasury:write{
"allocations": [
{ "kind": "invoice", "id": 980, "amount": "968.00" },
{ "kind": "invoice", "id": 984, "amount": "484.00" }
],
"payment_method": "Transferencia bancaria",
"difference_as_fee": false,
"remember": false
}Each allocation is {kind, …, amount} with kind:
kind | Fields | What it creates |
|---|---|---|
invoice | id, amount | A payment (Payment) of the invoice dated on the bank date; on a debit, a refund (is_refund). |
expense | id, amount | A payment (ExpensePayment) of the confirmed expense; on a credit, the refund of a supplier credit note. |
customer_advance | customer_id, amount | A customer advance (credits only). |
account | account_id or account_code, amount, description | A bank_movement entry bank ↔ account. |
payment | payment_id, optional amount | Creates nothing: links an invoice payment already recorded without a bank account (entered by hand, or taken by card and settled by the POS). Without amount, everything still unlinked is linked. |
expense_payment | expense_payment_id, optional amount | Creates nothing: links an expense payment already recorded without a bank account. Without amount, everything still unlinked is linked. |
payroll | payroll_record_id | Pays a confirmed payslip for its net amount (amount is ignored). Debits only. It can be mixed with other allocations: a batch with two payslips and a grant recorded as an expense. |
The allocations must add up to the absolute value of the transaction: a difference ≤ amount_tolerance is booked as rounding to 769/669; with difference_as_fee: true the difference (only when the bank credits less or debits more than what is applied) goes to 626 as a withheld fee, with no limit; any other difference returns 400 validation_error on allocations. payment_method is the id or name of the payment method; when omitted it is deduced from the Norma 43 code (card, direct debit, transfer). A draft or cancelled invoice, an unconfirmed expense or an amount above the document's outstanding balance return 400.
Response (abridged):
{
"id": 1842,
"status": "matched",
"status_display": "Conciliado (cobro/pago)",
"matched_amount": "1452.00",
"auto_matched": false,
"allocations_summary": [
{ "id": 301, "kind": "invoice_payment", "amount": "968.00", "target_id": 980, "object_type": "payment", "object_id": 5120 },
{ "id": 302, "kind": "invoice_payment", "amount": "484.00", "target_id": 984, "object_type": "payment", "object_id": 5121 }
],
"allocations": [
{
"id": 301,
"kind": "invoice_payment",
"kind_display": "Cobro de factura",
"object_type": "payment",
"object_id": 5120,
"target_type_name": "invoice",
"target_id": 980,
"target_display": "2026-A-0147 – Talleres Martín, S.L.",
"amount": "968.00",
"metadata": {},
"entries": [
{ "id": 9031, "entry_number": 412, "date": "2026-10-14", "description": "Cobro factura 2026-A-0147", "kind": "payment", "status": "posted" }
],
"created_at": "2026-11-02T10:05:32Z"
},
{ "id": 302, "kind": "invoice_payment", "target_display": "2026-A-0151 – Talleres Martín, S.L.", "amount": "484.00", "…": "…" }
],
"resolved_at": "2026-11-02T10:05:32Z",
"resolved_by": 7,
"resolved_by_name": "Laura Gómez",
"…": "…"
}The payments created carry bank_account, the bank date, the statement reference and a "Conciliación bancaria" note, and show up in the payments guide.
Matching against payments already recorded
Often the payment is already in Billora when the statement arrives: you marked the invoice as paid, recorded the expense payment by hand, or a bulk payment created it. Reconciling that transaction with invoice or expense would create a second payment. To avoid it, the engine proposes the existing_payment suggestion and match accepts the payment and expense_payment allocations, which link the existing record instead of creating another one.
Invoice payments (/payments/) and expense payments (/expense-payments/) without a bank_account are considered, as long as they are not linked to another transaction yet, have the same amount in euros (± amount_tolerance) and are dated between existing_payment_days_before days before and existing_payment_days_after days after the bank date. Those recorded more than 10 days after the transaction (for instance, payments loaded in bulk weeks later) score lower (5 to 20 points, depending on the distance) and are only matched on their own when the concept quotes the invoice number. Groups of 2 to 4 payments of the same party adding up to the amount are proposed too. Like any other suggestion, it is only applied on its own when there is identity evidence as well (invoice number, VAT number, name, IBAN…) and it reaches the threshold.
{
"kind": "existing_payment",
"id": 5120,
"label": "Cobro ya registrado – factura 2026-A-0147 – Talleres Martín, S.L. (09/10/2026)",
"amount": "968.00",
"score": 90,
"reasons": [
"Importe igual a un cobro ya registrado sin cuenta bancaria",
"Número de factura en el concepto",
"El cobro se registró con fecha 09/10/2026: se moverá a la del banco"
],
"params": { "payments": [{ "kind": "payment", "id": 5120, "amount": "968.00", "date": "2026-10-09" }] },
"exact": true,
"identity": true
}To accept it, carry params.payments over to match:
{ "allocations": [{ "kind": "payment", "payment_id": 5120 }] }For an expense payment, { "kind": "expense_payment", "expense_payment_id": 2210 }. On linking:
- No payment is created: the invoice or expense keeps the one it already had.
- Re-dated to the bank date: the payment takes the transaction's bank account and its date. Its entry moves from the generic cash account to the account's 572xxxx sub-account and to the real date; the previous date is kept in
allocation.metadata.previous_date(withlinked_existing: true). unmatchdoes not delete it: on undo, the payment goes back to its previous date and to having no bank account, and the transaction returns to pending.- Partial link: with an
amountsmaller than the payment, only that part is linked and the rest stays available for other transactions of the same bank account (a €19.55 expense paid in three charges of 9.25 + 6.25 + 4.05). The first link sets the date; later ones do not change it. The linked total can never exceed the payment amount. - A payment dated in a locked period is not proposed, and linking or undoing it returns
409 period_locked. One that is already linked for its full amount, was reconciled another way or already has another bank account returns400.
To search them by hand: GET /treasury/transactions/{id}/candidates/?kind=payment (or expense_payment). And GET /treasury/transactions/?document=payment:5120 returns the transaction a payment is reconciled with.
Book to an account or record a fee (book)
/api/v1/treasury/transactions/{id}/book/treasury:write{
"account_code": "626",
"as_expense": true,
"document_type": "bank_fee",
"supplier_name": "BBVA",
"description": "October maintenance fee",
"remember": true
}Without as_expense it creates a bank_movement entry between the bank sub-account and account (id) or account_code (626 fees, 669 interest paid, 769 interest received, 551 partners, 555 pending items, 4751/476 tax office and Social Security…). With as_expense: true (debits only) it also creates a confirmed VAT-free expense with document_type (bank_fee by default; also financial_interest, receipt, tax_or_fee, penalty, insurance_receipt, settlement, pass_through, other), expense_category, supplier supplier (id) or supplier_name (created if missing; by default the account's bank) and its payment from the account; when you give no account, the document type's default is used (bank_fee → 626, financial_interest → 669, tax_or_fee → 631…).
{
"id": 1811,
"status": "booked",
"status_display": "Contabilizado",
"matched_amount": "12.50",
"allocations": [
{
"id": 298,
"kind": "expense_payment",
"kind_display": "Pago de gasto",
"object_type": "expensepayment",
"object_id": 2210,
"target_type_name": "expense",
"target_id": 731,
"target_display": "BBVA",
"amount": "12.50",
"metadata": { "expense_created": 731 },
"entries": [
{ "id": 9012, "entry_number": 398, "date": "2026-10-02", "description": "Pago gasto BBVA", "kind": "expense_payment", "status": "posted" }
],
"created_at": "2026-11-02T10:01:07Z"
}
],
"…": "…"
}Transfer between own accounts (transfer)
/api/v1/treasury/transactions/{id}/transfer/treasury:write{ "target_bank_account": 3, "mirror_transaction": 1901, "remember": false }Creates a transfer entry 572x ↔ 572y with the target (or source, depending on the sign) account. mirror_transaction is the mirror transaction (same amount, opposite sign) already imported in the other account; when omitted, a pending one within ±2 days is searched for, and if found both become transfer sharing the same entry (if the mirror arrives later, reconciling it links it to the entry already created). For a cash withdrawal, target_bank_account is the cash account.
{
"id": 1877,
"status": "transfer",
"status_display": "Traspaso",
"allocations": [
{
"id": 310,
"kind": "transfer",
"kind_display": "Traspaso entre cuentas",
"object_type": "journalentry",
"object_id": 9044,
"target_type_name": "bankaccount",
"target_id": 3,
"target_display": "Santander savings",
"amount": "5000.00",
"metadata": { "mirror_transaction_id": 1901 },
"entries": [
{ "id": 9044, "entry_number": 420, "date": "2026-10-20", "description": "Traspaso a Santander savings – TRASPASO A CUENTA AHORRO", "kind": "transfer", "status": "posted" }
],
"created_at": "2026-11-02T10:08:50Z"
}
],
"…": "…"
}Tax payment or refund (tax-payment)
/api/v1/treasury/transactions/{id}/tax-payment/treasury:write{ "model": "303", "period": "2026-3T" }model is 303, 111, 115, 123, 130, 131, 202, 200 or 100; period looks like 2026-3T, 2026-09 (monthly regime) or 2026 (annual). A debit is a payment (debit 4750/4751/4752/473, credit bank) and a credit a refund. The entry is the same one POST /accounting/tax-payments/ creates and stays linked to the transaction (kind: tax_payment, metadata: {model, period}); the transaction becomes booked.
Payroll payment (payroll)
/api/v1/treasury/transactions/{id}/payroll/treasury:write{ "payroll_record_ids": [412, 413, 414] }Debits only. The net salaries of the payslips (confirmed or paid, from HR) must add up to the transaction amount (± tolerance); when the batch also includes other payments, use match with payroll allocations. Each payslip is marked paid on the bank date (an existing payment date is kept) and its payment entry (payroll_payment) is linked to the bank sub-account; the transaction becomes matched with one payroll_payment allocation per payslip (target_type_name: "payrollrecord"). A payslip already reconciled with another transaction returns 400.
Ignore (ignore)
/api/v1/treasury/transactions/{id}/ignore/treasury:write{ "reason": "Entry cancelled by the bank the next day", "remember": false }For wrong, duplicated or cancelled lines. No entry is posted: the transaction becomes ignored with the reason in notes, and its amount still counts in the summary's bank vs. ledger difference (ignored_count, ignored_amount). POST /treasury/transactions/bulk-ignore/ with {transaction_ids, reason} ignores several and returns a result per transaction.
Undo (unmatch)
/api/v1/treasury/transactions/{id}/unmatch/treasury:writeNo body. Reverts what the reconciliation created: deletes the payments it created (their entries are reversed; the ones that already existed and were only linked are not deleted: they return to their previous date and are left without a bank account), deletes the expense created by book with as_expense, reverses direct entries (bank_movement, transfer, tax_payment) with a contra entry, restores the payslips' previous status and payment date and, for a transfer, sets the mirror back to pending too. The transaction returns to pending with recalculated suggestions. If any entry or payment falls in a locked period nothing is touched and it returns 409 period_locked; on an already pending transaction it returns 409 invalid_transaction_state.
Accepting suggestions in bulk
/api/v1/treasury/transactions/accept-suggestions/treasury:write{ "transaction_ids": [1842, 1843, 1850], "min_score": 70, "dry_run": true }Applies the best suggestion of every pending transaction (transaction_ids, or every pending one when omitted) whose score reaches min_score (default auto_match_threshold). With dry_run: true it only lists. Returns one row per transaction:
[
{ "transaction": 1842, "result": "would_apply", "detail": "", "suggestion": { "kind": "invoice", "id": 980, "label": "Cobro agrupado – facturas 2026-A-0147, 2026-A-0151 – Talleres Martín, S.L.", "amount": "1452.00", "score": 75, "…": "…" } },
{ "transaction": 1843, "result": "skipped", "detail": "Puntuación 60 por debajo del umbral 70.", "suggestion": { "kind": "transfer", "score": 60, "…": "…" } },
{ "transaction": 1850, "result": "skipped", "detail": "Sin sugerencia aplicable.", "suggestion": null }
]result is applied (with the transaction's final status), would_apply (in dry_run), skipped or error (the reason in detail; an error on one transaction does not affect the others). Recommended pattern: dry_run → review the list → repeat without dry_run.
Bank vs. ledger summary
/api/v1/treasury/summary/treasury:read{
"accounts": [
{
"id": 2,
"name": "BBVA main account",
"kind": "bank",
"iban": "ES9121000418450200051332",
"bank_name": "BBVA",
"currency": "EUR",
"is_default": true,
"is_active": true,
"accounting_account": 512,
"accounting_account_code": "57200002",
"bank_balance": "18240.35",
"ledger_balance": "17796.35",
"difference": "444.00",
"pending_count": 3,
"pending_amount": "444.00",
"ignored_count": 0,
"ignored_amount": "0.00",
"transactions_count": 412,
"last_statement_date": "2026-10-31",
"last_statement_balance": "18240.35",
"last_import_at": "2026-11-02T08:31:10Z",
"last_import": { "id": 57, "status": "done", "created_at": "2026-11-02T08:31:10Z", "rows_new": 45, "issues": [] }
}
],
"bank_balance": "18240.35",
"ledger_balance": "17796.35",
"difference": "444.00",
"pending_count": 3,
"pending_amount": "444.00",
"ignored_count": 0,
"ignored_amount": "0.00",
"unreconciled_months": ["2026-10"],
"revolut": null,
"alerts": [
{ "account": 2, "message": "BBVA main account: diferencia banco ↔ contabilidad de 444.00 €." }
]
}bank_balance is the last known bank balance (the balance_after of the latest transaction or, when the bank gives no balances, the closing balance of the latest statement); ledger_balance is the sub-account's balance from posted entries; difference = bank − ledger (totals only include accounts with a statement). With everything reconciled the difference is 0.00; pending and ignored transactions explain whatever remains. unreconciled_months lists the months with pending transactions and alerts collects differences and continuity warnings of the latest import. ?at=YYYY-MM-DD returns the balances at that date, and GET /treasury/bank-accounts/{id}/summary/ the same block for a single account. Foreign-currency accounts carry foreign_currency: true and difference: null, and are left out of the totals (bank_balance, difference), which are always in euros; when they have pending transactions, alerts says so. revolut is null unless the organization has the Revolut Business integration configured: it then carries its state (status, last_sync_at, expires_at, days_to_expiry, last_error) and its alerts, which are also appended to alerts with a code (revolut_consent_expiring, revolut_consent_expired…) and account: null. The cash-flow report (GET /accounting/reports/cash-flow/) also includes the real bank balance when there are accounts with statements.
Opening entry from a trial balance
When you start keeping the books in Billora you can load your accountant's trial balance as the opening entry of the fiscal year. If the previous year was kept elsewhere, set the accounting start first. Scope accounting:write.
File format
- CSV or XLSX, up to 10 MB. A file with an
.xlsextension whose content is actually xlsx is opened too; the old Excel 97-2003 binary format is not supported (409 accounting_error): save it as.xlsxor CSV. - Columns code/account, name and debit balance / credit balance (or debit / credit, or a single signed balance), with Spanish or English headers.
- Accountant's layout: title rows before the header are accepted (it is searched in the first 30 rows), as are the
DEBE SALDO/HABER SALDOcolumns and the "TOTALES" row, which is ignored. When the file carries both sums and balances, the balances are always used. - Long codes padded with zeros (
1000000000,4300000017), as exported by many accounting packages.
Previewing and mapping the accounts
/api/v1/accounting/opening-balances/preview/accounting:writeMultipart with file and, optionally, account_mapping (a JSON string), regularize and bank_account_mapping. It creates nothing: it returns every row with the proposed target for its balance.
curl https://api.billora.app/api/v1/accounting/opening-balances/preview/ \
-H "Authorization: Bearer $BILLORA_API_KEY" \
-F "file=@sumas-y-saldos-2025.xlsx" \
-F 'account_mapping={"4300000017": "customer:231", "5720000001": "bank:2"}' \
-F "regularize=true"{
"rows": [
{
"code": "1000000000", "name": "CAPITAL SOCIAL", "source_code": "1000000000", "source_name": "CAPITAL SOCIAL",
"debit": "0.00", "credit": "3000.00",
"account_exists": true, "account_id": 401, "account_name": "Capital social", "will_create": false,
"link_party": null, "link_party_name": null, "bank_account": null, "bank_account_name": null,
"target": "100", "target_account_code": "100", "target_label": "Capital social",
"suggested_target": "100", "suggested_reason": "prefix", "skipped": false, "error": null
},
{
"code": "4300000017", "name": "TALLERES MARTIN SL", "source_code": "4300000017", "source_name": "TALLERES MARTIN SL",
"debit": "1452.00", "credit": "0.00",
"account_exists": true, "account_id": 618, "account_name": "Talleres Martín, S.L.", "will_create": false,
"link_party": "customer:231", "link_party_name": "Talleres Martín, S.L.", "bank_account": null, "bank_account_name": null,
"target": "customer:231", "target_account_code": "43000231", "target_label": "Talleres Martín, S.L.",
"suggested_target": "customer:231", "suggested_reason": "name", "skipped": false, "error": null
},
{
"code": "5720000001", "name": "BBVA", "source_code": "5720000001", "source_name": "BBVA",
"debit": "16800.85", "credit": "0.00",
"account_exists": true, "account_id": 512, "account_name": "BBVA cuenta principal", "will_create": false,
"link_party": null, "link_party_name": null, "bank_account": 2, "bank_account_name": "BBVA cuenta principal",
"target": "bank:2", "target_account_code": "57200002", "target_label": "BBVA cuenta principal",
"suggested_target": "bank:2", "suggested_reason": "bank_account", "skipped": false, "error": null
}
],
"total_debit": "18252.85",
"total_credit": "18252.85",
"difference": "0.00",
"balanced": true,
"accounts_to_create": 0,
"errors": [],
"warnings": [],
"can_import": true,
"bank_accounts": [{ "id": 2, "name": "BBVA cuenta principal", "kind": "bank", "accounting_account_code": "57200002", "is_default": true }],
"bank_account_mapping": { "5720000001": 2 },
"account_mapping": { "1000000000": "100", "4300000017": "customer:231", "5720000001": "bank:2" },
"suggested_mapping": { "1000000000": "100", "4300000017": "customer:231", "5720000001": "bank:2" },
"unmapped": [],
"regularize": true,
"result_to_129": "0.00",
"accounting_start_date": "2026-01-01"
}Automatic suggestions. Every row carries suggested_target and the reason in suggested_reason:
suggested_reason | Proposed target |
|---|---|
exact | The Billora account with the same code. |
prefix | The account whose code is the significant prefix of a long zero-padded code (1000000000 → 100, 4751000007 → 4751). |
vat_id / name | The sub-account of the Billora customer, supplier or employee matching by VAT number or by name (sub-accounts 430/431/436/438, 400/401/410/411/407/523 and 465). |
bank_account | The sub-account of the bank or cash account (57x balances). |
new_account | There is no target in Billora: an account will be created with the file's code and name. |
regularize | Expense or income account (6/7) that, with regularize, goes to 129. |
unmapped lists the codes without a clear target (they would be created with their own code): assign them a customer, supplier or account before importing. warnings flags, for instance, a 57x balance that would stay in the generic account instead of a bank account's.
account_mapping changes the target row by row. It is an object keyed by the file's code with the target as value (in multipart, as a JSON string); whatever you leave out uses the suggestion:
| Target | What it does |
|---|---|
An account code ("4751") | Sends the balance to that account, which must exist in your chart or be a standard PGC account. |
customer:<id> · supplier:<id> · employee:<id> | Sends it to that customer's, supplier's or employee's sub-account (created when missing), so the outstanding balance shows on their record and in the aging report. |
bank:<id> | Sends it to the 572xxxx / 570xxxx sub-account of that bank or cash account, so the ledger balance matches the statement. |
skip | Does not import the row. Only allowed when the balance still adds up without it. |
Several rows can share a target: they are aggregated and netted into a single entry line. bank_account_mapping (code → bank account id) is the earlier way of mapping 57x balances and still works; it is equivalent to bank:<id>.
regularize. An opening balance only carries balance-sheet accounts (groups 1–5). If your accountant's was produced before the year-end regularisation and carries expense and income accounts (6/7) with a balance, send regularize: true: instead of rejecting them, their net balance, which is the result of the year, goes to account 129. result_to_129 gives the amount (positive = profit). Without regularize, each 6/7 row carries an error and blocks the import.
Balancing and validation rules:
- Debit and credit must match within a 0.01 € tolerance; otherwise
balanced: falseand the reason inerrors. - Only accounts of three or more digits in groups 1–5 (and 6/7 with
regularize). - If a code in the file is already the sub-account of another party in Billora (same code, different name), the row carries an
erroruntil you give it another target. can_importistrueonly when it balances and no row has an error.
Importing
/api/v1/accounting/opening-balances/import/accounting:writeMultipart with file, fiscal_year (id of the fiscal year, which must be open), replace (default true) and the same account_mapping, regularize and bank_account_mapping as the preview. It validates again, creates the missing accounts and posts the opening entry dated on the first day of the fiscal year or, when later, on the accounting start date (it is posted even if that date is under lock_date, like the opening generated by the year-end close). If the fiscal year already had an opening entry, with replace: true it is reversed with a contra entry and the new one is created; with replace: false the request fails. The entry records its origin in metadata (source: trial_balance, file, rows, accounts created, replaced entries and the mapping applied).
{
"entry": { "id": 9100, "entry_number": 1, "date": "2026-01-01", "kind": "opening", "status": "posted", "description": "Asiento de apertura 2026 (balance de sumas y saldos)", "…": "…" },
"accounts_created": [],
"replaced_entries": [],
"rows": 3,
"total_debit": "18252.85",
"total_credit": "18252.85",
"bank_account_mapping": { "5720000001": 2 },
"account_mapping": { "1000000000": "100", "4300000017": "customer:231", "5720000001": "bank:2" },
"regularize": true,
"result_to_129": "0.00",
"warnings": []
}A file without a recognisable header, one that does not balance, one with 6/7 accounts without regularize, one with a code clashing with another party's sub-account, or a closed fiscal year (or one before the accounting start) return 409 accounting_error with the detail. After the opening, GET /accounting/reports/trial-balance/?fiscal_year=<id> must return the same opening balances.
From the MCP
If you connect Billora to Claude through the MCP server, the treasury module is available as tools that go through this same API with the user's permissions: list_bank_accounts, create_bank_account and get_bank_account_summary; preview_bank_statement and import_bank_statement (the statement is uploaded through the file hub with the bank_statement target, or as base64 when small); list_bank_transactions, get_bank_transaction, reconcile_bank_transaction (one action among match, book, transfer, tax_payment, payroll, ignore, apply_suggestion or rematch with the same parameters as here, including the payment and expense_payment allocations for payments already recorded), accept_bank_suggestions (with dry_run by default), unmatch_bank_transaction, treasury_summary, list_reconciliation_rules, create_reconciliation_rule, preview_opening_balances and import_opening_balances (with account_mapping and regularize), set_accounting_start and the 11 revolut_* tools of the Revolut Business integration. Claude summarises what it is about to do and asks for confirmation before reconciling, accepting suggestions in bulk or importing the opening entry, and never invents a match: when a suggestion is doubtful, it asks. There are conversation examples in the connector guide.
Errors
| HTTP | code | When it happens |
|---|---|---|
| 400 | validation_error | File that cannot be parsed (file), required columns not identified, allocations split that does not add up or applies to a document that does not allow it, invalid ledger account, payslips whose net salaries do not add up, wrong or duplicated IBAN, threshold outside 50–100… The field involved is in errors. |
| 403 | feature_not_available / role_forbidden / insufficient_scope | Plan without accounting, user without the OWNER/ADMIN role on a write, or key without the treasury:* scope. |
| 404 | not_found | Transaction, account, import or rule that does not exist or belongs to another organization. |
| 409 | period_locked | The transaction date falls in a locked period (lock_date) or a closed fiscal year: it cannot be reconciled, nor can a reconciliation whose entries or payments are in that period be undone. See accounting. |
| 409 | invalid_transaction_state | The action requires a pending transaction (it is already matched, booked or ignored: undo first) or unmatch on an already pending one. |
| 409 | conflict | Deleting a bank account with imported transactions. |
| 409 | foreign_currency_account | Reconciling or booking a transaction of an account that is not in euros (only ignore is allowed). |
| 409 | accounting_error | Opening that does not balance, carries 6/7 accounts without regularize, comes as an old .xls file or targets a closed fiscal year; transaction without an open fiscal year for its date. |
| 409 · 424 | revolut_* | Errors of the Revolut Business integration: see its guide. |
