Bill Runs
A bill run turns rated transactions into invoices. Billerang exposes a single universal API for creating and running bill runs — there is no distinction between "cycle" and "ad-hoc" bill runs in the public contract.
The universal model
The universal bill run carries its own scope and aggregation rules. There is no inheritance from a billing cycle by default — when you attach a cycle, its fields become defaults for the BR, not constraints.
POST /api/v1/billingRuns (sync) and POST /api/v1/billingRuns/async (async + jobRunId).
Run types are auto-derived
| Condition | runType |
|---|---|
billingCycleCode is set | CYCLE |
billingCycleCode is null | EXCEPTIONAL |
You do not pick the run type — it follows from the scope you provide.
Scope sources
A bill run picks RatedTransactions through the intersection of four optional sources:
| Source | Effect |
|---|---|
billingCycleCode | Bill all BAs assigned to the cycle. Inherits the BC's invoiceTypeEl, splitPerPaymentMethod, aggregation defaults, and validation script. |
billingAccountCodes[] | Explicit BA list. Combinable with the cycle (intersection). |
filters (generic-API map) | JPA-path filters on RatedTransaction. Operator prefixes supported: inList, fromRange, toRange, like, ne, gt, lt. |
applicationEl (run gate, not a BA filter) | Jakarta EL evaluated at job execution time. When false → the entire BR is skipped by the job. |
To filter BAs or charges, use filters — not applicationEl.
Date semantics
The bill run consumes RatedTransactions that already exist. Charge-level nextChargeDate / nextInvoiceDate (on ChargeInstance) drive WO → RT generation by the rating engine — they are not bill-run inputs.
| Date | Role |
|---|---|
invoiceDate | Date stamped on invoices the run produces. |
lastTransactionDate | RT cutoff. Only RTs with usageDate < lastTransactionDate enter the run. |
startDate / endDate (advanced) | Filter billingAccount.nextInvoiceDate ∈ [startDate, endDate]. |
Process modes
processType controls the engine behaviour — how far the engine advances the BR's status.
| UI label | Backend value | Result |
|---|---|---|
| Automated, ready for validation | AUTOMATIC | Stops at DRAFT_INVOICES; operator validates. |
| Manual progress | MANUAL | Stays at NEW; operator advances each step. |
| Automated validation | FULL_AUTOMATIC | Runs end-to-end including validation, reaches VALIDATED. |
runOptions.autoValidate is a separate HTTP-level flag for sync POSTs: block the response until VALIDATED. Only valid with processType=FULL_AUTOMATIC (other combos return 400).
Minimal example — bill one BA right now
TOKEN=$(./get-token.sh)
curl -X POST "https://api.billerang.com/api/v1/billingRuns" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"billingAccountCodes": ["BA_001"],
"invoiceDate": "2026-05-13T00:00:00Z",
"lastTransactionDate": "2026-05-13T23:59:59Z",
"processType": "FULL_AUTOMATIC",
"runOptions": { "autoValidate": true }
}'
Returns the full BR with status: "VALIDATED".
Cycle-based example — monthly run for all B2C accounts
curl -X POST "https://api.billerang.com/api/v1/billingRuns" \
-H "Authorization: Bearer $TOKEN" \
-d '{
"code": "BR_MONTHLY_B2C_2026_05",
"description": "Monthly B2C billing",
"billingCycleCode": "Monthly_B2C",
"invoiceDate": "2026-05-01T00:00:00Z",
"lastTransactionDate": "2026-04-30T23:59:59Z",
"processType": "AUTOMATIC"
}'
code is the idempotency key — submitting the same code twice returns 409.
Filtered example — only USAGE charges for B2M customers
curl -X POST "https://api.billerang.com/api/v1/billingRuns" \
-H "Authorization: Bearer $TOKEN" \
-d '{
"invoiceDate": "2026-05-13T00:00:00Z",
"lastTransactionDate": "2026-05-13T23:59:59Z",
"filters": {
"chargeInstance.chargeTemplate.chargeMainType": "USAGE",
"billingAccount.customer.customerCategory.code": "B2M"
},
"processType": "FULL_AUTOMATIC",
"runOptions": { "autoValidate": true }
}'
Full payload reference
See Aggregation Rules for the full set of aggregation knobs and Split Billing for the five native split mechanisms.
| Field | Type | Required | Default |
|---|---|---|---|
code | string | no | auto-generated |
description | string | no | — |
billingCycleCode | string | no | — |
billingAccountCodes | string[] | no | — |
filters | object | no | — |
applicationEl | string | no | — |
defaultInvoiceTypeCode | string | no | — (resolved per article) |
invoiceDate | ISO-8601 | yes | — |
lastTransactionDate | ISO-8601 | yes |