use_case · invoice_vs_payment
Open invoices to customer payments
Accounts receivable shows the invoice. The bank or lockbox shows the cash. The invoice number in the memo rarely matches the string stored on the invoice, and a short-pay is not a match.
What breaks in practice
Customers pay late, pay less than the invoice, or put "Inv 2041" in a free-text memo. An exact string compare misses the punctuation difference. An amount tolerance wide enough to accept a short-pay will also hide a real underpayment. One ACH that pays two invoices becomes an unmatched lump unless the parts sum exactly and share a reference.
What Unira reconciles
- Dataset A, open invoices:
invoice_id,date,amount,reference(invoice number),currency. - Dataset B, payments:
payment_id,posting_date,amount,reference(invoice number copied from the memo),currency. use_caseisinvoice_vs_payment. Amount tolerance is0, so a short-pay stays unmatched. The date window is 7 days. Exact reference fields normalize case, whitespace, and punctuation, soINV-2041andinv 2041can match when both values sit inreference. An empty normalized reference never matches.
A payment that exactly sums 2 to 5 same-sign invoice lines, with one amount condition, one date condition, matching currency, and a reference shared with the single line, can be a confirmed split. Other combinations are suggested or left unmatched. This recipe's sample is one-to-one.
Outputs and exceptions
INV-2041matches (paid in full, one day later).INV-2042at 1575.50 against a 1500.00 payment does not match. Both rows are exceptions.missing_booksincludes the unpaid invoiceINV-2043(dataset A).missing_bankincludes paymentPAY-3(dataset B, no invoice).- Page them with
GET /api/v1/reconciliations/{id}/exceptions. Export withGET /api/v1/reconciliations/{id}/export?format=csv.
Sample payload
POST /api/v1/datasets (invoices)
{
"name": "Open invoices — October",
"id_field": "invoice_id",
"idempotency_key": "ar-invoices-v1",
"records": [
{"invoice_id": "INV-2041", "date": "2026-10-05", "amount": "3200.00", "reference": "INV-2041", "currency": "USD"},
{"invoice_id": "INV-2042", "date": "2026-10-13", "amount": "1575.50", "reference": "INV-2042", "currency": "USD"},
{"invoice_id": "INV-2043", "date": "2026-10-20", "amount": "4100.00", "reference": "INV-2043", "currency": "USD"}
]
}
POST /api/v1/datasets (payments)
{
"name": "Customer payments — October",
"id_field": "payment_id",
"idempotency_key": "ar-payments-v1",
"records": [
{"payment_id": "PAY-1", "posting_date": "2026-10-06", "amount": "3200.00", "reference": "inv 2041", "currency": "USD"},
{"payment_id": "PAY-2", "posting_date": "2026-10-14", "amount": "1500.00", "reference": "INV-2042", "currency": "USD"},
{"payment_id": "PAY-3", "posting_date": "2026-10-18", "amount": "75.00", "reference": "UNKNOWN", "currency": "USD"}
]
}
POST /api/v1/rulesets
{
"name": "Invoice number to payment",
"rules": [
{
"id": "invoice-exact",
"name": "Same invoice reference and currency; paid within 7 days",
"priority": 1,
"conditions": [
{"field_a": "currency", "field_b": "currency", "operator": "exact"},
{"field_a": "reference", "field_b": "reference", "operator": "exact", "trim": true, "ignore_case": true},
{"field_a": "amount", "field_b": "amount", "operator": "amount", "tolerance": "0"},
{"field_a": "date", "field_b": "posting_date", "operator": "date", "tolerance": "7"}
]
}
]
}
POST /api/v1/reconciliations
{
"name": "October invoices vs payments",
"use_case": "invoice_vs_payment",
"dataset_a_id": "ds_invoices",
"dataset_b_id": "ds_payments",
"ruleset_id": "rules_example",
"ruleset_version": 1,
"idempotency_key": "ar-october-2026"
}
curl
curl --fail-with-body -sS https://unira.dev/api/v1/datasets \
-H "Authorization: Bearer $UNIRA_API_KEY" \
-H "Content-Type: application/json" \
--data '{"name":"Open invoices — October","id_field":"invoice_id","idempotency_key":"ar-invoices-v1","records":[{"invoice_id":"INV-2041","date":"2026-10-05","amount":"3200.00","reference":"INV-2041","currency":"USD"},{"invoice_id":"INV-2042","date":"2026-10-13","amount":"1575.50","reference":"INV-2042","currency":"USD"},{"invoice_id":"INV-2043","date":"2026-10-20","amount":"4100.00","reference":"INV-2043","currency":"USD"}]}'
curl --fail-with-body -sS https://unira.dev/api/v1/datasets \
-H "Authorization: Bearer $UNIRA_API_KEY" \
-H "Content-Type: application/json" \
--data '{"name":"Customer payments — October","id_field":"payment_id","idempotency_key":"ar-payments-v1","records":[{"payment_id":"PAY-1","posting_date":"2026-10-06","amount":"3200.00","reference":"inv 2041","currency":"USD"},{"payment_id":"PAY-2","posting_date":"2026-10-14","amount":"1500.00","reference":"INV-2042","currency":"USD"},{"payment_id":"PAY-3","posting_date":"2026-10-18","amount":"75.00","reference":"UNKNOWN","currency":"USD"}]}'
curl --fail-with-body -sS https://unira.dev/api/v1/rulesets \
-H "Authorization: Bearer $UNIRA_API_KEY" \
-H "Content-Type: application/json" \
--data '{"name":"Invoice number to payment","rules":[{"id":"invoice-exact","name":"Same invoice reference and currency; paid within 7 days","priority":1,"conditions":[{"field_a":"currency","field_b":"currency","operator":"exact"},{"field_a":"reference","field_b":"reference","operator":"exact","trim":true,"ignore_case":true},{"field_a":"amount","field_b":"amount","operator":"amount","tolerance":"0"},{"field_a":"date","field_b":"posting_date","operator":"date","tolerance":"7"}]}]}'
curl --fail-with-body -sS https://unira.dev/api/v1/reconciliations \
-H "Authorization: Bearer $UNIRA_API_KEY" \
-H "Content-Type: application/json" \
--data '{"name":"October invoices vs payments","use_case":"invoice_vs_payment","dataset_a_id":"'"$A"'","dataset_b_id":"'"$B"'","ruleset_id":"'"$RULESET"'","ruleset_version":1,"idempotency_key":"ar-october-2026"}'
curl --fail-with-body -sS "https://unira.dev/api/v1/reconciliations/$JOB/exceptions" \
-H "Authorization: Bearer $UNIRA_API_KEY"
curl --fail-with-body -sS "https://unira.dev/api/v1/reconciliations/$JOB/export?format=csv" \
-H "Authorization: Bearer $UNIRA_API_KEY" --output ar-matching.csv
MCP: reconcile_files
reconcile_files with preset bank-books uses the same reference, amount, currency, and date or posting_date headers. The one-day lag is inside the preset's 4-day rule. The short-pay stays unmatched because the preset's rounding rule is only 0.05. use_case is invoice_vs_payment.
curl --fail-with-body -sS https://unira.dev/api/mcp \
-H "Authorization: Bearer $UNIRA_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
--data '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"reconcile_files","arguments":{"side_a_csv":"invoice_id,date,amount,reference,currency\nINV-2041,2026-10-05,3200.00,INV-2041,USD\nINV-2042,2026-10-13,1575.50,INV-2042,USD\nINV-2043,2026-10-20,4100.00,INV-2043,USD\n","side_b_csv":"payment_id,posting_date,amount,reference,currency\nPAY-1,2026-10-06,3200.00,inv 2041,USD\nPAY-2,2026-10-14,1500.00,INV-2042,USD\nPAY-3,2026-10-18,75.00,UNKNOWN,USD\n","side_a_name":"Open invoices","side_b_name":"Customer payments","preset":"bank-books","use_case":"invoice_vs_payment","idempotency_key":"ar-october-mcp-v1"}}}'