What is a rating engine?
The rating engine is the core of BillingEngine. It receives a data record (DR) — raw data about your service usage — and calculates the resulting price based on active rules and price list versions.
Record processing flow
Every submitted DR goes through these steps:
- Validation — checks format, required fields, and customer existence
- Price list selection — the engine iterates active
pricing_rulesand finds the first one matching the record’s attributes - Price calculation — applies the rate from
price_list_itemsto the volume or count - Storage — the record is saved with the calculated price and a reference to the price list version used
Rules and conditions
Triggers (triggers) allow dynamic changes to engine behavior. You can define:
- Scalar conditions —
{ "service_type": "SMS" }or with an operator{ "op": "gte", "value": 100 } - Aggregate conditions — e.g. “if the customer exceeded 1,000 SMS in the month, apply a discount”
{
"conditions": {
"service_type": { "op": "eq", "value": "SMS" }
},
"aggregate_conditions": [
{ "func": "COUNT", "field": "id", "op": "gt", "value": 500 }
]
}
Price list versions
BillingEngine supports price list versioning. Each version has a validity period (valid_from, valid_to). The engine always selects the version valid at the time the record was received — so historical records remain consistent even after price changes.
Result
After processing a record, the POST /api/v1/dr/billing endpoint returns a price summary for the chosen period — the perfect basis for issuing an invoice.