REST API for Charging enables external applications to connect to PortaBilling for real-time service authorization and charging, without requiring developers to implement telecom protocols such as RADIUS/Diameter. This is useful when you offer web/internet-based services (for example, an MVNO bundling a video streaming service) and want to bill customers for those services through PortaBilling, allowing them to receive a single consolidated invoice.
This module acts as a Web Charging Gateway, converting HTTP REST API requests into requests that PortaBilling understands and can process. Because REST over HTTP is already familiar to most developers, connecting a new application to PortaBilling requires no special knowledge. Developers work with a small set of intuitive parameters – such as service_type (e.g., IPTV), item (the unit being priced, e.g., e-book or Pay-Per-View), and units (how much was consumed) – rather than the complex telecom-specific parameters used by telecom protocols.
As a result, you can start monetizing a new service more quickly and with significantly less effort.
Examples
AI services
A service provider extends its Cloud PBX service with AI-powered voice bots by partnering with an AI platform. Business customers can configure and assign voice bots to their phone numbers to handle calls automatically. The service provider bills customers per minute of voice bot usage: before the bot answers or initiates a call, the platform checks with PortaBilling that the customer has sufficient prepaid balance or remaining quota and reserves an estimated amount; after the call ends, the platform reports the actual usage, and the customer is charged accordingly. Once the balance or quota is exhausted, the voice bot stops handling calls, preventing unpaid overages.
EV charging
An IoT service provider extends their services with EV charging. Its customers, such as delivery companies, can charge their vehicles at partner stations, with the usage added to their existing IoT service bill alongside other connected devices. When a driver starts charging a vehicle, the EV charging platform sends an authorization request to PortaBilling to verify that the account has sufficient balance or available quota (e.g., kilowatt-hours). If funds or quota are insufficient, the charging does not start. PortaBilling can also prevent the same account from charging two vehicles simultaneously. The platform reports the amount of electricity consumed to PortaBilling, which charges the customer for the supplied kilowatt-hours (or deducts them from the available quota).
Value-added services in mobile networks (LTE/5G)
A mobile operator charges for partner video streaming or game streaming directly from the subscriber’s mobile balance or bundle, with usage authorized and charged in real time via PortaBilling.
Pay-per-view and digital content purchases
A mobile operator offers pay-per-view events and digital content purchases to its subscribers. When a user purchases access to a one-time event (such as a live boxing match) or digital content (such as an audiobook or mobile game), the partner platform sends an authorization request to PortaBilling to verify that the account has sufficient available balance. If the balance is insufficient, the purchase is declined before access is granted. Otherwise, the platform reports the purchase to PortaBilling, which immediately charges the user’s account.
Requirements
To deploy REST API for Charging, you need an active subscription to the corresponding module in the Add-on Mart.
How it works
The module is deployed as the Web Charging Gateway, a component that sits between your application and PortaBilling. Your application sends HTTP REST API requests to the gateway to authorize a service (check the customer’s balance or quota and reserve the required units, charge for actual consumption, or release a reservation if the session is canceled. Each request includes a simple set of parameters (such as service_type, item, and units). The gateway communicates with PortaBilling and returns the result to your application.
See the Web Charging Gateway API reference.
Here’s how a charge request flows:

POST /services/15552345678/charges
{
"service_elements": [{
"billing_session_id": "7B6AA461 4C5C21EF D47D5CBE AD918421",
"service_type": "IPTV",
"item": "Pay-per-view",
"units": 1
}]
}

{
"success": true,
"service_elements": [{
"user_id": "15552345678",
"service_type": "IPTV",
"item": "Pay-per-view",
"units": 1,
"charged_units": 1,
"charged_amount": 9.99
}]
}