Telecom / Mobile Carrier
The telecom pattern is one of the most operationally complex in commercial billing - carriers run prepaid wallet balances, postpaid recurring plans, included allowances per metered dimension, per-destination-country roaming pricing, family-plan pooled allowances, and overage handling, all inside a single subscription. Every primitive in Kontorion shows up somewhere in a carrier's billing model.
Real-world examples. T-Mobile, Vodafone, Verizon, AT&T, Free Mobile, Vodafone Italy, Telekom Deutschland, Orange, O2, Three UK, Mint Mobile. Common shape: monthly plan with X minutes + Y SMS + Z GB included, additional usage at per-unit rates, roaming priced per destination country and per service type, family plan with pooled allowance across N lines, prepaid option with topup-and-spend wallet model.
The shape of the problem
Telecoms hit nearly every operational complexity dimension at once:
- Prepaid + postpaid coexistence. The same carrier offers customer-funded wallet balances (prepaid SIMs - load €20, talk until empty) and monthly recurring plans (postpaid - bill at the end of the month). Often one customer has both.
- Multi-dimensional metered allowances. A single plan includes minutes, SMS, and data, each with their own allowance and own overage rate. Real-time visibility per dimension is non-negotiable.
- Roaming as keyed pricing. International roaming charges per destination country and per service (call vs SMS vs data). Modeling each as a separate product creates 200+ entries per service; modeling roaming as a keyed product (one product per service, attached to a key set, with one price per destination-country
price_key) collapses to one product. - Family plans / pooled allowances. A family plan has 5 lines but shares a pooled allowance for data; minutes might be per-line. Pool semantics live at the subscription level, per-line semantics at the line level.
- Real-time hard caps. Customers expect to be able to set "stop me from using more than 5 GB this month" caps that actually enforce in real time, not "send me an invoice after the fact."
- Mid-cycle plan changes. Upgrading from a 5GB plan to a 20GB plan mid-cycle triggers immediate access to the new allowance (less the consumed portion of the old one) and prorated billing.
Kontorion blueprint
| Concern | Kontorion primitive |
|---|---|
| Prepaid SIM balance | Wallet per customer; debit per usage event |
| Monthly recurring plan | Standard subscription with metered products |
| Per-dimension allowance | PlanVersionProduct.included_quantity per metered product |
| Per-destination roaming | Keyed product: a key_set_id on the product, a price_key on each price and usage event |
| Family plan pooled allowance | Subscription-level allowance shared across event sources |
| Mid-cycle plan upgrade | POST /subscriptions/{id}/transition-plan with proration |
Build it
1. Define the metered products
Code
Roaming is one keyed product per service. The set of destination keys
lives in a key set; each product opts in
via key_set_id, and individual prices carry a price_key matching one of
the set's entries. Create the key set once:
Code
Then attach the key set to each roaming product:
Code
"Rest of world" is handled by a single set price (is_set_price: true,
no price_key): the resolver falls back to it for any key in the set that
has no exact-match price, so you only price the destinations that differ from
the catch-all rate.
2. Build the postpaid plan with allowances
Code
3. Set domestic and overage prices
Code
4. Set roaming rates per destination country
Code
5. Subscribe a customer
Code
6. Network ingests usage events
For every call, SMS, or data session, the carrier's network sends an event:
Code
The first event consumes 5 minutes of the 1,000-minute domestic allowance; the second is roaming-priced from event 1 because roaming products carry no allowance.
7. Hard cap on data with network enforcement
Hard caps are built on meter thresholds, not billing milestones.
(Billing milestones are percentage-of-contract invoice triggers -
POST /subscriptions/{subscriptionId}/milestones with a trigger_type of
MANUAL, DATE, or EVENT - a different feature.) A meter carries a list
of thresholds; each declares a comparator + value over the meter's
evaluated total and an action. When usage crosses the threshold the
monitor fires the action - action.kind is one of webhook, slack, or
emit_event.
Define the data meter with a threshold that webhooks your network OSS when the customer crosses 25 GB (25,000 MB) in the window:
Code
When the customer crosses 25 GB in the period, Kontorion fires the webhook to the network OSS, which blocks further data sessions for that MSISDN until the next cycle. No "I got a $500 surprise bill" support tickets.
Scope note. Kontorion emits the breach signal (the webhook to your OSS) and records the breach (
GET /meters/{id}/breaches); actually cutting off the MSISDN happens in the carrier's network. The threshold is currently defined on the meter itself, so it applies to every subscription that consumes the meter - per-subscriber caps with subscriber-specific limits are not yet first-class.
Variations
- Prepaid SIM mode. Same products, but no recurring plan - all events charge against a wallet balance. Top-ups credit the wallet via a manual or auto-topup flow.
- Family plan with pooled data. Use a single subscription with multiple
metadata.line_idvalues on each event; aggregator pools them all into the same bucket. - Unlimited plans with fair-use throttling. Set the data product's
included_quantityto a very high number (effectively unlimited) and add a meter threshold whoseaction.kindiswebhookto throttle (not bill overage) when the customer crosses a fair-use threshold. - Add-on data packs. Customer buys a one-time 5GB pack: post a
wallet_creditof 5GB to a data-specific allowance pool that the aggregator consumes before the plan allowance.
What you don't have to build
- Per-dimension allowance bookkeeping with real-time drawdown
- Roaming destination dispatch (keyed product + per-
price_keyprices, with anis_set_pricecatch-all) - Pooled-allowance family plan accounting
- Hard-cap enforcement webhook integration with the network OSS
- Mid-cycle plan upgrade with prorated allowance and billing
- Reconciliation between CDR ingest and the customer's invoice
Next steps
- Wallets - prepaid SIM balance management
- Pricing - Keyed Prices - per-destination roaming rates
- Plans - allowances, pooled buckets, multi-product bundles