Code groups
A code group is a collection of phone number prefixes (rate codes) that are treated the same way, e.g., assigned the same price or classified into a common category.
Code group sets
A code group set is a collection of code groups. Since the same rate codes can be grouped in different ways (based on specific purposes or service provider requirements), code group sets allow you to maintain multiple versions of rate code groupings.
A service provider offers both bundled voice plans (with included minutes) and pay-as-you-go calling. For these scenarios, they maintain two different code group sets:
- The Bundled services UK & EU code group set uses broad regional groupings, suitable for managing allowances in bundled plans (such as offering 200 minutes to all European destinations under a single group).
- The Pay-as-you-go UK & EU code group set is used in customer and vendor tariffs, and follows the vendor’s pricing structure, which requires more granular destination breakdowns (such as defining separate code groups for each European country).
| Code group set | Code group name | Included prefixes |
| Bundled services UK&EU | UK | 441, 442, 447 |
| EU | 33, 39, 420, … | |
| Pay-as-you-go UK&EU | UK fixed line | 441, 442 |
| UK mobile | 447 | |
| France | 33 | |
| Italy | 39 | |
| Czech Republic | 420 | |
| … |
When code group sets are used
Code group sets can be used in:
- Tariffs – simplify rate configuration. Instead of adding separate rates for each rate code, you can enter a single rate using the code group name. PortaBilling then applies that rate to all rate codes in the group. Note that origin-based tariffs work exclusively with code groups.
- Bundles – define which rate codes are included in a package. For example, a bundle may include 100 free minutes for calls to all destinations in the “Spain” code group. The code group set linked to the bundle defines which prefixes are part of that group.
- Invoice pre-processing rules – categorize charges by rate codes before generating the invoice. You can apply specific rules based on code group, e.g., apply a promotion to calls made to Spain during the billing period.
- Fraud traffic profiles – monitor and control traffic to specific regions or high-risk destinations. You can create a code group set that segments destinations (e.g., US & Canada, Europe, Middle East), and define thresholds for alerting or blocking voice traffic based on these groupings.
Managing code group-based rates in tariffs
Standard tariffs
In standard tariffs, the prices are defined per individual rate code, even if you use code groups when uploading rates.
Here’s how it works:
- To use code group-based rating, you assign a code group set to a tariff.
- You add a new rate using a code group name (e.g., CZ-Mobile).
- PortaBilling:
- Looks up that group (e.g., CZ-Mobile) in the assigned code group set.
- Finds all prefixes in the group (e.g., 420602, 420603).
- Creates individual rate entries for each of those rate codes in the tariff.
Important note
Adding or removing rate codes to/from a code group does not update existing rates.
For example:
- Suppose CZ-Mobile originally includes prefixes 420602 and 420603.
- You upload a rate for CZ-Mobile to a tariff, and PortaBilling inserts rate entries for those two prefixes.
- Later, you add the prefix 420737 to the CZ-Mobile group.
As a result, the CZ-Mobile group is updated, but the existing tariff remains unchanged – it still only contains rates for 420602 and 420603.
To add a rate for 420737, you must either re-upload the code group-based rate or manually add the rate to the tariff.
Origin-based tariffs
In origin-based tariffs, basic and extra (origin-based) prices are always defined per code group, not per individual rate code. For these tariffs, changing the contents of a code group automatically updates existing rates.
For example, when you add a new prefix (e.g., 420737) to an existing code group (e.g., CZ-Mobile), the rate automatically applies to the new prefix – no manual action is needed.
Types of code group sets
PortaBilling supports two types of code group sets: regular and complete. The type determines in which scenarios it can be used.
Regular code group set (default)
A regular code group set includes only the code groups created by the admin, with the rate codes explicitly assigned to those groups.
- The admin selects rate codes from PortaBilling’s general rate code list and assigns them to one or more groups within the set.
- Rate codes not assigned to any group are excluded from the set.
This type is typically used in:
- Tariffs
- Invoice pre-processing rules
- Bundles
Complete code group set
A complete code group set ensures that all PortaBilling rate codes are included in the set, either in a manually created group or in a special Default group. Complete code group sets are useful to ensure that all rate codes used in PortaBilling are covered, e.g., to monitor international traffic and detect fraudulent calls.
- The set initially includes a Default group that contains all rate codes (if a new rate code is added to PortaBilling, it appears in the Default group automatically).
- The admin creates additional code groups and moves selected rate codes from the Default group into those.
- Rate codes that are not reassigned to a manually created group remain in the Default group.
- Complete code group sets also allow creating code groups inside other code groups (except the Default group).
This type is typically used in:
- Fraud traffic profiles
- Bundles (when full coverage of rate codes is needed)
Let’s consider an example where a complete code group set is used to configure a fraud traffic profile. A service provider sells VoIP services to customers in the US, Canada, and Europe, and wants to prevent potential fraudulent traffic to other destinations. To receive alerts when “unusual” traffic is detected, the admin configures a fraud traffic profile:
- Creates a complete code group set “World”, and code groups “US&Canada” and “Europe” within this code group set. The rate codes that are not typically used are left in the “Default” code group.
- Creates the “Business customers” fraud traffic profile and configures service usage monitoring for the “Default” code group. The admin sets the expected total volume of voice traffic, to be sent by customers to destinations other than US/Canada/Europe to 10 minutes per hour.
- Assigns the fraud traffic profile to the customer class.
If the total volume of traffic to destinations from the “Default” code group exceeds the 10-minute threshold, it may indicate potential fraud. In this case, the admin receives an alert notification and takes the necessary measures to minimize potential losses.

