Outgoing call rules (/dial_rule/)

You can test API methods on the interactive API browser page and without writing code
Some of the resources described on the page may not be available by default due to the type of application (see Creating and authorizing applications).

This resource is convenient to use for tasks:

  • banning calls to certain destinations;

  • various custom set conversions (for example, adding a prefix).

You can specify a list of rules for the internal number and/or the entire client. The PBX, after receiving a call request from the internal number (direct dial or by forwarding), first checks the rules of the internal number, then the rules of the client. The list of rules in each block (internal number or client block) is checked before the first match.

Description of data structures

Outgoing call rule (dial_rule)

Name

Type

Mandatory

Default value

Description

Name

Type

Mandatory

Default value

Description

match_exp

string

yes

null

The rule applies if the set matches "match_exp". Recorded in PCRE format

repl_exp

string

yes

null

This parameter describes what to do with the set if it matches "match_exp"

Examples

For example, a client with id=12 needs to add the prefix "8812" to a seven-digit set (it will be applied to all internal client numbers). First, you need to create the desired list of set rules:

System response:

{   "id": 61,   "client_id": 12,   "dial_rules": [     {       "repl_exp": "8812\\1",       "match_exp": "^([0-9]{7})$"     }   ] }

Next, you need to apply the created list of rules to the client:

System response:

{ ...   "dial_rule_id": 61 ... }

And one of the internal numbers with the id=164 must be prohibited from calling anywhere other than Russian numbers, but by dialing "1" to allow a call to a specific international number. Let's say that a higher-level provider receives international calls in the format 8-10-country code_number, and the number 000001 has an answering machine that prohibits outgoing calls to the destination. Creating a list of set rules:

System response:

{   "id": 62,   "client_id": 12,   "dial_rules": [     {       "repl_exp": "8104412345678",       "match_exp": "^1$"     },     {       "repl_exp": "000001",       "match_exp": "^810(77|[012345689])"     }   ] }

Applying a list of rules to an internal number:

System response:

Resources of the "Client" section

POST /client/{client_id}/dial_rule/

Add a list of outgoing client call rules

URL Parameters

Name

Type

Name

Type

client_id

string

JSON parameters

Name

Type

Mandatory

Name

Type

Mandatory

dial_rules

Array[dial_rule]

yes

name 

string

yes

dial_rule resource

Name

Type

Mandatory

Name

Type

Mandatory

comment 

string

none

match_exp

string

yes

repl_exp

string

yes

Response fields

Name

Type

Name

Type

client_id

long

dealer_id

long

dial_rules

Array[dial_rule]

id 

long

name 

string

dial_rule resource

Name

Type

Name

Type

comment 

string

match_exp

string

repl_exp

string

PUT /client/{client_id}/dial_rule/{dial_rules_id}/

Update the list of outgoing client call rules

URL Parameters

Name

Type

Name

Type

client_id

string

dial_rules_id

integer

JSON parameters

Name

Type

Mandatory

Name

Type

Mandatory

dial_rules

Array[dial_rule]

none

name 

string

none

dial_rule resource

Name

Type

Mandatory

Name

Type

Mandatory

comment 

string

none

match_exp

string

yes

repl_exp

string

yes

Response fields

Name

Type

Name

Type

client_id

long

dealer_id

long

dial_rules

Array[dial_rule]

id 

long

name 

string

dial_rule resource

Name

Type

Name

Type

comment 

string

match_exp

string

repl_exp

string

GET /client/{client_id}/dial_rule/

Get lists of client outgoing call rules

URL Parameters

Name

Type

Name

Type

client_id

string

Response fields

Name

Type

Name

Type

client_id

long

dealer_id

long

dial_rules

Array[dial_rule]

id 

long

name 

string

dial_rule resource

Name

Type

Name

Type

comment 

string

match_exp

string

repl_exp

string