Billing & Balance
ZPBX provides real-time billing. Every call is rated and debited instantly upon completion.

Check balance
GET /v1/balances
curl https://api.zpbx.es/v1/balances \
-H "Authorization: Bearer zpbx_your_api_key_here"
{
"billingGroupId": "cmq...",
"balance": 150.75,
"currency": "USD",
"disabled": false
}
Platform keys (no billing group assigned) cannot use this endpoint — they receive a 400. Specify a billing group via /v1/accounts first, or assign a billing group to the API key.
How billing works
Each call generates a CDR with financial fields:
| Field | Description | Scope required |
|---|---|---|
price | Sell price — what you charge the customer | calls:read |
buyCost | Buy cost — what the carrier charges | calls:read_cost |
margin | Profit — price - buyCost | calls:read_cost |
The customer's balance is debited automatically after each call.
Rate lookup
Look up the rate for a specific destination:
GET /v1/rates?destination=234813
curl "https://api.zpbx.es/v1/rates?destination=234813" \
-H "Authorization: Bearer zpbx_your_api_key_here"
{
"destination": "234813",
"matchedPrefix": "234",
"sellRate": 0.012,
"billingIncrement": "1/1",
"currency": "USD"
}
The API matches the longest prefix in your billing group's rate card. The billingIncrement field uses the format minimum/interval (e.g. 1/1 = per second, 60/60 = per minute).
Customers only see sell rates. Buy costs and margins require the calls:read_cost scope.