Set up an API token, make a first request in JavaScript or PHP, and reset the demo database. For developers integrating with a PracBill department.
Every request carries your API token as the first path segment. There is no separate header or login step.
https://billing.pracbill.com.au/api/:tokenid/<endpoint>
Requests that send data use POST with Content-Type: application/json and a JSON body. Responses are JSON with a success boolean (older endpoints return result), plus a description or reason on failure.
tokenid.alloweduser{username} with the value yes. For username testuser:| Key data | Value |
|---|---|
allowedusertestuser |
yes |
That user can then retrieve the key with the endpoint below.
GET /get-key/:username/:passwordReturns the API key for a portal user who has been allowed on a key (see above).
| Parameter | Type | Required | Description |
|---|---|---|---|
username |
string | Yes | Portal username. |
password |
string | Yes | Portal password. |
Request
$.ajax({
url: '/get-key/testuser/somepass',
type: 'GET',
contentType: 'application/json',
success: function( response ) {
console.log(response);
}
});
Response (success)
{
"success":true,
"key": "xcsdfdsfjdskvmnxclkvnjklcdxjglkfdj xc.nmx"
}
Response (error)
{"success":false,"description":"no billed call found"}
Adds a call record with jQuery. See CDR API for the fields.
Request
var myData = {
id: 123456,
startdate: '2015-05-05 10:00:00',
accountcode: '1300557823',
callerid: '0447979043',
did: '1300557823',
direction: 'outbound',
destination: '1300557823',
duration: 450,
billsec: 420,
cost: 0.20,
error: 5555
}
$.ajax({
url: 'https://portal.xenis.com.au/api/892f86d5-da86-4e98-9343-1976a375/cdr/add',
data: JSON.stringify(myData),
type: 'POST',
contentType: 'application/json',
success: function( response ) {
console.log(response);
}
});
Response (success)
{"success":true,"id":"a550126e-283a-4fda-9d83-6f25a34da249"}
Response (error)
{"success":false,"description":"CDR Already Exists"}
Creates a customer with cURL. See Customers API for the fields.
$api_key = '892f86d5-da86-4e98-9343-1976a375';
$post_url = "https://portal.xenis.com.au/api/$api_key/customer/add";
$post_data = array(
'name' => 'Test',
'surname' => 'Person',
'phone' => '0411222333',
);
$data_string = json_encode($post_data);
$ch = curl_init($post_url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // don't worry about ssl too much
curl_setopt($ch, CURLOPT_SSLVERSION,1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
header('Location: success.html');
GET /:tokenid/resetdbClears the demo database of customers, invoices, services, call packs, addresses, orders and events. The department must be enabled for this; on a production department it returns "Not Available".
| Parameter | Type | Required | Description |
|---|---|---|---|
tokenid |
string | Yes | Your API access token. |
Request
$.ajax({
url: '/api/892f86d5-da86-4e98-9343-1976a375/resetdb ',
type: 'GET',
contentType: 'application/json',
success: function( response ) {
console.log(response);
}
});
Response (success)
{
"success":true,
"description": "Demo Database Reset"
}
Response (error)
{"success":false,"description":"Not Available"}
{"success":false,"description":"invalid key"}
Never call
resetdbagainst a live department token. It only works where the reset is enabled, but check the token first.
Related: API overview, Customers API, CDR API.