Skip to content

Manage post-authentication rules

A post-authentication rule applies after a call has been authenticated to an account, by any method: digest, authentication rule or DID. When the call’s remote IP, CLI or CLD match the rule, the call gets the rule’s tariff and routing group, and its CLI and CLD are rewritten by the rule’s translation rules. See Post-authentication rules for scenarios.

All methods support trusted mode with i_customer.

Name Type Description
i_post_auth_rule int ID of the rule. Returned, never sent to addPostAuthRule
remote_ip string IP address the call comes from
cli string Caller’s number
cld string Dialled number
cli_translation_rule string Translation rule applied to the CLI of matched calls
cld_translation_rule string Translation rule applied to the CLD of matched calls
i_tariff int Tariff for matched calls. Nil uses the tariff of the account’s service plan
i_routing_group int Routing group for matched calls. Nil uses the account’s routing group

cli and cld accept wildcards: * matches any sequence of characters, ? one character, [1-5] or [^p] a character from a range or outside it, and \ makes the next character literal. For example, 0038* matches 0038943794.

Adds a rule to an account.

Name Type Required Description
i_account int yes ID of the account
remote_ip string one of At least one of remote_ip, cli and cld is required
cli string one of
cld string one of
cli_translation_rule, cld_translation_rule string no
i_tariff int no Default nil: the account’s service plan tariff
i_routing_group int no Default nil: the account’s routing group
Name Type Description
result string OK
i_post_auth_rule int ID of the new rule
request
call("addPostAuthRule", {
"i_account": 3092,
"remote_ip": "198.51.100.20",
"cld": "44*",
"i_routing_group": 7,
})
response
{"result": "OK", "i_post_auth_rule": 418}

Changes a rule. Send only the fields you change.

Name Type Required Description
i_post_auth_rule int yes ID of the rule
any other field as in the structure no New value of a field of the structure. Send nil in i_tariff or i_routing_group to use the account’s again
Name Type Description
result string OK
request
call("updatePostAuthRule", {"i_post_auth_rule": 418, "i_tariff": 12})
response
{"result": "OK"}

Deletes a rule.

Name Type Required Description
i_post_auth_rule int yes ID of the rule
Name Type Description
result string OK
request
call("deletePostAuthRule", {"i_post_auth_rule": 418})
response
{"result": "OK"}

Returns one rule.

Name Type Required Description
i_post_auth_rule int yes ID of the rule
Name Type Description
result string OK
post_auth_rule struct The rule, with the fields of the structure
request
call("getPostAuthRuleInfo", {"i_post_auth_rule": 418})
response
{
"result": "OK",
"post_auth_rule": {
"i_post_auth_rule": 418,
"remote_ip": "198.51.100.20",
"cli": "",
"cld": "44*",
"cli_translation_rule": "",
"cld_translation_rule": "",
"i_tariff": 12,
"i_routing_group": 7,
},
}

Lists the rules of an account.

Name Type Required Description
i_account int yes ID of the account
remote_ip string no Only rules with this remote IP address
offset int no Skip this many rules
limit int no Return at most this many rules
Name Type Description
result string OK
post_auth_rules array Rules, each a struct with the fields of the structure
request
call("listPostAuthRules", {"i_account": 3092})
response
{
"result": "OK",
"post_auth_rules": [
{"i_post_auth_rule": 418, "remote_ip": "198.51.100.20", "cli": "",
"cld": "44*", "cli_translation_rule": "", "cld_translation_rule": "",
"i_tariff": 12, "i_routing_group": 7},
],
}