Tariffs, rates & routing rules
Looking up a per-minute rate, reading a whole tariff's rate table, updating a manual currency exchange rate, and managing location rules (the number-rewriting rules behind Tariffs, Providers & Routing's localization feature).
rate_get
Looks up the rate that would apply to a dialled prefix, for one account's own tariff.
Who may call it: any account type. A plain user always gets their own rate; admin or reseller must pass username to say whose tariff to use (a reseller can only name their own customers).
Only answers at all if the installation has switched on rate-checking (confline Devices_Check_Rate); otherwise it answers Feature_Disabled.
| Parameter | Required | In hash | Meaning |
|---|---|---|---|
u | Yes | — | Caller's username. |
prefix | Yes | never — not part of any hash list | The number (or prefix) to rate. Non-digits are stripped before matching. |
username | Admin/reseller only | 1st | Whose tariff to rate against. |
Hash parameter order: just username — prefix never enters the hash string at all, even though it's the main input.
curl -X POST https://api.example.com/api/rate_get \
-d "u=demo_customer" \
-d "prefix=41441234567" \
-d "hash=PLACEHOLDER_HASH"<page>
<rate>0.0120#Switzerland Mobile#4144</rate>
</page>The value is rate#destination name#matched prefix, joined with # — not three separate tags. Errors: Dont_be_so_smart (no caller), Feature_Disabled, Empty_prefix, User was not found, Rate_was_not_found, Prefix_not_found.
Also reachable as: /api/rate.
tariff_rates_get
The full rate table of one tariff, with each rate's time-of-day windows.
Who may call it: any account type. Pass tariff_id to name a tariff directly (admin: any tariff; others: only their own) — otherwise it uses whichever tariff is assigned to user_id (or the caller's own tariff if user_id is omitted).
| Parameter | Required | In hash | Meaning |
|---|---|---|---|
u | Yes | — | Caller's username. |
tariff_id | No | 2nd | Numeric tariff id, looked up directly (ignored if user_id is also set and non-zero). |
user_id | No | 1st | Use this account's assigned tariff instead of naming one directly. |
Hash parameter order: user_id, then tariff_id — note user_id comes first even though tariff_id reads more naturally first; that's the shared list's fixed position for each name, not an editorial choice.
curl -X POST https://api.example.com/api/tariff_rates_get \
-d "u=admin" \
-d "tariff_id=593" \
-d "hash=PLACEHOLDER_HASH"<page>
<pagename>Tariff</pagename>
<tariff_name>Standard Retail</tariff_name>
<purpose>retail</purpose>
<currency>EUR</currency>
<rates>
<rate>
<direction>...</direction>
<destination>...</destination>
<prefix>...</prefix>
<code></code>
<tariff_rate>0.0120</tariff_rate>
<con_fee>0.0000</con_fee>
<increment>1</increment>
<min_time>0</min_time>
<start_time>00:00:00</start_time>
<end_time>23:59:59</end_time>
<daytype>everyday</daytype>
<effective_from>2026-01-01 00:00:00</effective_from>
</rate>
</rates>
</page>Note: this success body is not nested inside a <status> block. The failure case is — <page><status><error>No tariff found</error></status></page>.
Also reachable as: /api/get_tariff.
tariff_rates_get returns.exchange_rate_update
Sets a manual exchange rate for a currency that isn't on automatic updates.
Who may call it: admin only.
| Parameter | Required | Meaning |
|---|---|---|
currency | Yes (fixed hash order, 1st) | Currency name — must be a currency the installation does not auto-update. |
rate | Yes (fixed hash order, 2nd) | New exchange rate, a positive number. |
Hash parameter order: currency, then rate — fixed for this method.
curl -X POST https://api.example.com/api/exchange_rate_update \
-d "u=admin" \
-d "currency=USD" \
-d "rate=1.08" \
-d "hash=PLACEHOLDER_HASH"<page>
<status>
<success>Currency successfully updated</success>
</status>
</page>Errors: Access Denied (not admin), Currency was not found, Exchange rate is invalid.
Location rules
A location rule rewrites a number for one location (country/network profile), the same feature as Tariffs & routing → Localization in the product. All six methods below share one access rule.
Who may call them: admin, accountant, reseller or partner — not a plain user.
location_rule_get
| Parameter | Required | Meaning |
|---|---|---|
location_rule_id | Yes (fixed hash order) | Numeric id of the rule. |
curl -X POST https://api.example.com/api/location_rule_get \
-d "u=admin" \
-d "location_rule_id=12" \
-d "hash=PLACEHOLDER_HASH"<page>
<status>
<location_rule>
<location_id>3</location_id>
<name>...</name>
<cut>...</cut>
<add>...</add>
... every other column of the rule ...
</location_rule>
</status>
</page>Error: Location rule was not found.
location_rules_get
| Parameter | Required | Meaning |
|---|---|---|
location_id | Yes (fixed hash order) | Numeric id of the location whose rules to list. |
<page>
<status>
<location>
<name>...</name>
<location_rule>...</location_rule>
</location>
</status>
</page>Errors: Location was not found; or, inside <location>, No Location rules if the location exists but has none.
location_rule_create / location_rule_update
Both take the same rule fields; create needs location_id (the parent location, fixed hash order), update needs location_rule_id (the rule to change, fixed hash order). Both use the same cross-tenant check below.
| Parameter | Meaning |
|---|---|
name | Rule name. |
cut / add | Destination-number rewrite: strip / prepend digits. |
minlen / maxlen | Destination length bounds. |
lr_type | Rule type. |
lcr_id | Routing rule to switch to — must be one of the caller's own. |
tariff_id | Tariff to re-rate with — must be one of the caller's own. |
did_id | DID to use as CallerID — must be one of the caller's own. |
device_id | Device to send the call to — must be in the caller's scope. |
change_callerid_name | 1/0. |
src_cut / src_add / src_minlen / src_maxlen | Same rewrite/length fields, applied to the caller's number instead. |
location_group_id | Restrict the rule to one location group — must be the caller's own. |
enabled | location_rule_update only: 1/0. |
None of the fields above are in the hash — only location_id (create) or location_rule_id (update) is.
curl -X POST https://api.example.com/api/location_rule_create \
-d "u=admin" \
-d "location_id=3" \
-d "name=Demo rule" \
-d "cut=0" \
-d "hash=PLACEHOLDER_HASH"<page>
<status>
<status>Rule added (rule_id: 57)</status>
</status>
</page>Errors: Location was not found; Dont_be_so_smart if a reseller or partner names an lcr_id, tariff_id, did_id, device_id or location_group_id they don't own (admin/accountant are exempt from this check). location_rule_update answers the same shapes, with Location rule was not found for a missing/unowned rule.
location_rule_delete
| Parameter | Required | Meaning |
|---|---|---|
location_rule_id | Yes (fixed hash order) | Rule to delete. |
<page><status><status>Rule deleted</status></status></page>Error: Location rule was not found.
location_rule_copy
| Parameter | Required | Meaning |
|---|---|---|
location_rule_id | Yes (fixed hash order, 1st) | Source rule to copy. |
location_id | Yes (fixed hash order, 2nd) | Target location — for a reseller/partner, must be their own. |
<page><status><status>Rule copied</status></status></page>Errors: Location rule was not found (source), Location was not found (target).
Check
Call tariff_rates_get for demo tariff 593 and compare the returned rates against the Tariffs, Providers & Routing pages for the same tariff in the product.