Guide · Rating and billing

Real-time VoIP billing: where the margin leaks

In wholesale you do not lose money in one go: you lose it in fractions of a cent, per call, over months. This page explains how a call is actually rated and walks through the six leaks that always show up — and what the switch has to do to stop them.

How a call is actually rated

"$0.012 a minute" is not a rate: it is a loose number. A real carrier rate has four fields, and all four change the result:

The rule that sums it all up: you have to charge your customer with a scheme at least as protected as the one your supplier applies to you. If you buy 60/60 and sell 1/1, every 12-second call is paid as 60 and charged as 12. That does not show up in per-minute margin: it shows up on the statement.

Why "real time" is not marketing

There are two ways to draw down a balance, and only one survives a bad-faith customer or a runaway dialer:

  1. At teardown. Simple to build. With 200 simultaneous calls open to an expensive destination, a $10 balance turns into a few hundred in debt before the first one hangs up.
  2. During the call. The switch reserves credit on answer and consumes it while the call runs. When it runs out, it cuts. The maximum possible debt is known and bounded.

The second is the only one compatible with selling prepaid to someone you do not know.

The six leaks

1. The unordered prefix table

Overlapping prefixes resolved by insertion order instead of by length. You catch it by taking a handful of real numbers per country and comparing the rate the switch applied against the one it should have.

2. Asymmetric minimum and increment

Described above. It is the number-one leak in new operations, because the sell rate gets copied from a competitor without looking at the buy rate.

3. Rounding to two decimals

A 6-second call at 0.0098 is worth 0.00098. Rounded to two decimals, it is worth zero. At dialer volume, "zero" is thousands of free calls a day. The system has to store and accumulate at the rate's precision — six decimals or more — and round only when issuing the invoice.

4. The cheap route with no margin

Cost 0.0098, sell 0.0100. LCR picks it because it is cheapest; the margin does not pay for the record. The defence is routing by minimum margin rather than minimum cost: if the route does not leave what you defined, move to the next.

5. Attempts that bill nothing but cost something

In dialer traffic, dozens of attempts per billed minute. They appear on no invoice, but they consume the switch and degrade your ASR with the carrier — which is what then determines the route quality you get.

6. The editable balance

If the balance lives in a column an UPDATE can change, there is no accounting: there is a number. When a customer disputes their usage, the only solid answer is a ledger that cannot be rewritten.

Balance as a ledger, not as a column

The right way to store money is the one accounting has used for centuries: append-only entries. The balance is not stored, it is derived from the sum of movements. Top-ups, usage, adjustments and credit notes are new rows; nothing is edited and nothing is deleted.

This can be enforced in the database, not only in the application: triggers that reject UPDATE and DELETE on the entries table. The practical difference is that not even the database administrator can alter a balance without leaving a trace — and that any figure you show a customer can be rebuilt movement by movement.

Reconciling against the carrier invoice

Every month the supplier's invoice arrives and has to be verified. That job takes hours or minutes depending on a single design decision: whether the CDR stores cost alongside sell.

The same applies to the question that actually matters: which destinations make me money, and which am I carrying out of habit?

How NEXIA Switch handles it

NEXIA Switch rates in the same compiled core that decides routing, before the call goes out: it resolves the prefix by longest match, applies minimum, increment and connection charge, and reserves credit on answer. Balances live in an append-only ledger the database refuses to modify, and every CDR carries cost, sell and margin on the same row.

Rates load by bulk import from CSV or Excel, buy and sell, and the complete switch is free and permanent up to 100 concurrent calls.

Frequently asked questions

What is the difference between real-time rating and end-of-month billing?
Real-time rating is drawing the balance down while the call is in progress, with credit reserved on answer; end-of-month billing is issuing the document. You need both: without the first, a prepaid customer can consume far more than they hold before any call hangs up.
What are a rate's minimum and increment?
The minimum is the least you charge when the call connects — 30 or 60 seconds is usual — and the increment is the step it rounds to afterwards: 1, 6 or 60 seconds. They are written 60/60 or 30/6. The survival rule is never to sell on a scheme less protected than the one you buy on.
Why store amounts with six decimals?
Because wholesale rates carry four or more decimals and calls are short. A 6-second call at 0.0098 is worth 0.00098: rounded to two decimals it is worth zero. At high volume that is thousands of free calls a day. Accumulate at the rate's precision and round only when issuing the invoice.
What is an immutable ledger and why does it matter for billing?
It means storing money as append-only entries: the balance is not stored, it is derived from the sum of movements. It matters because it lets you enforce in the database that no balance changes without leaving a trace, and because any figure you show a customer can be rebuilt movement by movement.
Can rates be imported from CSV or Excel?
Yes, and it is the norm: carriers send rates as spreadsheets and change them often. NEXIA Switch imports buy and sell rates by prefix from CSV or Excel, with minimum, increment and connection charge per row.

Run it on your own server

Free up to 100 concurrent calls, forever, no card. Installed in an afternoon, with public pricing for when you grow.