API 2.0

We have released API version 2.0 into the user portal. Please download the latest documentation to take advantage of all the new features that are available.

Creating a SIP Trunk

In your php file, you will run the command trunk_create(). The command takes these parameters: $trunkname, $ip_address, $trunk_type, $concurrent_max, $caller_id. All parameters are going to be strings, enclosed by ” “. You will find the new trunk listed in your customer user portal.

EXAMPLE:

<?php
 
$api = new Trapi();
    $result = $api->trunk_create(‘mySipReg’, ‘8.8.8.10’, ‘static’);
//$result = $api->trunk_create(‘mySipReg’, ”, ‘dynamic’, 0);
//$result = $api->trunk_create(‘mySipReg’, ”, ‘dynamic’);
 
echo ‘<pre>’;
print_r($result); die;
 
?>

Replace “trunkName” with the desired name of your trunk. Keep in mind if the trunk has already been created in your account, another trunk will not be made with the same name, even with a different IP.

List trunks and their properties in your account

In your php file, you will run the command trunk_props(). The command takes one parameter: trunk. The parameter will be a string enclosed by ” “. Leaving the function blank, no parameter listed, will return all sip trunks in the account with their properties. With a name listed (ex: trunk_props(‘mySipTrunk’);) will return the properties of that single trunk. An array may also be entered in as a parameter. This is useful if you maintain multiple PBX systems and want to look at a groups properties. Listing a string will show the properties of

EXAMPLE:

<?php
 
$api = new Trapi();
    $result = $api->trunk_props();
//$result = $api->trunk_props(‘mySipTrunk’); //List one account props
//$result = $api->trunk_props( array(‘mySipTrunk’, ‘mySipTrunk2’) ); //Multi accounts props
 
echo ‘<pre>’;
print_r($result); die;
 
?>
 
Will Output:
[trunk] => trunkName
[ip_address] => xxx.xxx.xxx.xxx
[status] => Active

Set backup trunk in case of local outage

In your php file, you will run the command trunk_failovereip(). The command takes three parameters: trunk, action, and props. trunk: the name of the trunk, in ” ” that will use the backup. action: “enable” or “disable”. Enable will set the failover IP so that when the conditions are met, the trunk will automatically be switched. Disable should be sent if you no longer desire a backup. props: this will be an array of 3 values to be sent in. The Ip address of the failover location, the number of failed calls to trigger the failover, and the time interval that it checks for. This interval can only be 3, 5, 7, 10, 15, 20, 30.

EXAMPLE:

<?php
 
$api = new Trapi();
$props = array(“xxx.xxx.xxx.xxx”,13,30);
$result = $api->trunk_failovereip(“trunkName”,”enable”,$props);
echo ‘<pre>’;
print_r($result);
 
?>

This will not print anything unless there has been an error in the parameters.

Update a trunk’s IP

In your php file, you will run the command trunk_updateip().
The command takes two parameters: name and IP.
Both parameters are going to be strings, enclosed by ” “.
You will not see anything in your log if you do not print the results to console, but you will find the new IP listed in your acccount.


EXAMPLE:

<?php
 
$api = new Trapi();
$result = $api->trunk_updateip(“trunkName”,”xxx.xxx.xxx.xxx”);
echo ‘<pre>’;
print_r($result);
?>

Contact Us

Triton Communications