Manage tariffs
Цей контент ще не доступний вашою мовою.
A tariff is a price list: a currency, per-call parameters such as connect fee and grace period, and a set of rates. These methods manage the tariff itself, the same as the Tariffs screen of the panel. To read its rates, see List the rates of a tariff.
All methods support trusted mode with i_customer.
Tariff structure
Section titled “Tariff structure”createTariff and updateTariff take these fields, and getTariffInfo returns them. Required applies to createTariff.
| Name | Type | Required | Description |
|---|---|---|---|
name |
string | yes | Tariff Name |
currency |
string | yes | Currency of every rate, ISO 4217. Fixed after creation |
i_tariff_type |
int | no | Type: 1 Tariff for outgoing calls (default), 2 Incoming Tariff for DID calls. Fixed after creation. Dictionary tariff_types |
connect_fee |
double | no | Connect Fee per connected call, in the tariff currency. Default 0 |
free_seconds |
int | no | Free Seconds. Default 0 |
post_call_surcharge |
double | no | Post Call Surcharge, % as a fraction: 0.05 adds 5%. Default 0 |
grace_period |
int | no | Grace Period, sec: shorter calls are free on rates with grace period on. Default 0 |
loss_protection |
boolean | no | Enable Loss Protection. Default False |
max_loss |
double | no | Max Loss, % as a fraction: 0.1 allows 10%. Used with loss_protection |
cost_round_up |
boolean | no | Calls Cost: True for Round-Up, False (default) for Round |
decimal_precision |
int | no | Cost Decimal Precision: decimals kept for the cost of each call. Default 20 |
average_duration |
int | no | Avg. Call Duration, sec, used to compare route costs. Default 200 |
local_calling |
boolean | no | Local calling Enabled: area-based prices on the rates. Default False |
local_calling_cli_validation_rule |
string | no | CLI Validation Rule that decides from the caller’s number whether a call is local |
createTariff
Section titled “createTariff”Creates a tariff without rates.
Parameters
Section titled “Parameters”The fields of the tariff structure.
Returns
Section titled “Returns”| Name | Type | Description |
|---|---|---|
result |
string | OK |
i_tariff |
int | ID of the new tariff |
Example
Section titled “Example”call("createTariff", { "name": "Wholesale USD", "currency": "USD", "loss_protection": True, "max_loss": 0.0,}){"result": "OK", "i_tariff": 12}updateTariff
Section titled “updateTariff”Changes a tariff. Fields you leave out keep their values. currency and i_tariff_type cannot be changed.
Parameters
Section titled “Parameters”| Name | Type | Required | Description |
|---|---|---|---|
i_tariff |
int | yes | ID of the tariff |
| other fields | no | Any field of the tariff structure |
Returns
Section titled “Returns”| Name | Type | Description |
|---|---|---|
result |
string | OK |
Example
Section titled “Example”call("updateTariff", {"i_tariff": 12, "connect_fee": 0.01, "grace_period": 3}){"result": "OK"}deleteTariff
Section titled “deleteTariff”Deletes a tariff with its rates.
Parameters
Section titled “Parameters”| Name | Type | Required | Description |
|---|---|---|---|
i_tariff |
int | yes | ID of the tariff |
Returns
Section titled “Returns”| Name | Type | Description |
|---|---|---|
result |
string | OK |
Example
Section titled “Example”call("deleteTariff", {"i_tariff": 12}){"result": "OK"}getTariffInfo
Section titled “getTariffInfo”Returns one tariff.
Parameters
Section titled “Parameters”| Name | Type | Required | Description |
|---|---|---|---|
i_tariff |
int | yes | ID of the tariff |
Returns
Section titled “Returns”| Name | Type | Description |
|---|---|---|
result |
string | OK |
tariff |
struct | The fields of the tariff structure |
Example
Section titled “Example”call("getTariffInfo", {"i_tariff": 12}){ "result": "OK", "tariff": { "name": "Wholesale USD", "i_tariff_type": 1, "connect_fee": 0.01, "grace_period": 3, "loss_protection": True, # … the other fields },}getTariffsList
Section titled “getTariffsList”Returns your tariffs.
Parameters
Section titled “Parameters”| Name | Type | Required | Description |
|---|---|---|---|
name_pattern |
string | no | Filter by tariff name |
limit |
int | no | Return at most this many tariffs |
offset |
int | no | Skip this many tariffs first |
Returns
Section titled “Returns”| Name | Type | Description |
|---|---|---|
result |
string | OK |
tariffs |
array | One struct per tariff with i_tariff, name, currency and i_tariff_type |
Example
Section titled “Example”call("getTariffsList", {"name_pattern": "Wholesale USD"}){ "result": "OK", "tariffs": [ {"i_tariff": 12, "name": "Wholesale USD", "currency": "USD", "i_tariff_type": 1}, ],}Related
Section titled “Related”- Tariffs: the same fields in the panel
- List the rates of a tariff
- Loss protection and margin-based routing
- CDR call cost rounding
- Create a customer: assign a tariff with
i_tariff