The CDR API lets integrators push call records into PracBill for rating, look up the rated price of a billed call, check how up to date each CDR source is, and list customer CDR export schedules.
Base URL: https://billing.pracbill.com.au/api/:tokenid/...
POST /:tokenid/cdr/addAdd a call record for billing. It's designed for bespoke systems to integrate back into the billing platform to produce CDR results with additional non billing related information.
Important! You need to set the API Key variable of
cdr_sourceto the required CDR source in order for this to work.
The body is a JSON object.
| Parameter | Type | Required | Description |
|---|---|---|---|
tokenid |
string | Yes | Your API access token. |
orig_id |
string | Yes | id of the call from your platform/provider |
startdate |
datetime | Yes | This is the time of the call you want to present to your customer |
enddate |
datetime | ||
accountcode |
mixed (see note) | billing account identifier for this call | |
callerid |
mixed (see note) | Yes | callerid of the call, or the A Party |
did |
mixed (see note) | inbound phone number for inbound calls | |
direction |
enum(string) | Yes | either inbound or outbound |
destination |
mixed (see note) | Yes | destination of the call, or the B Party |
destination_info |
string | description for the destination | |
application |
string | internal application used for billing, some examples are Voicemail, IVR, Queue | |
duration |
int | number of total seconds for the call | |
billsec |
int | number billable seconds for the call | |
cost |
float | cost of the call | |
disposition |
string | text based status of the destination examples are ANSWERED, NO_ANSWER, BUSY | |
privacy_flag |
bool ( 0 / 1 ) | flag to define if we hide the A Party from all screens and outputs, but use the A Party to ensure billing can be accurate |
Note: the legacy field table marks accountcode, callerid, did and destination as "mixed*" with no footnote text; they accept either a string or a number, as in the example. The "Required" column is taken from the // required comments in the example request.
Request
var myData = {
orig_id: 'abc1234', // required
startdate: '2020-01-12 01:34:34', // required
enddate: '2020-01-12 01:34:54',
accountcode: 6113000111222,
callerid: 61399997777, // required
did: 611300111222,
direction: 'inbound', // or outbound required
destination: 61411222333, // required
destination_info: 'mobile',
application: 'bridge',
duration: 20, // in seconds
billsec: 20, // in seconds
cost: 0.01,
}
$.ajax({
url: '/api/892f86d5-da86-4e98-9343-1976a375/cdr/add',
type: 'POST',
data: JSON.stringify(myData),
contentType: 'application/json',
success: function( response ) {
console.log(response);
}
});
Response (success)
{"success":true,"yourid":"abc1234","id":5678}
Response (error)
{"success":false,"yourid":"abc1234","description":"CDR ID already exists"}
POST /:tokenid/cdr/multiple/addAdd several call records for billing in one request. You need to set the API Key variable of cdr_source to the required CDR source in order for this to work. It's designed for legacy systems to integrate back into the billing platform to produce CDR results with additional non billing related information.
The body is a JSON array of CDR objects; each object takes the same fields as Add a CDR.
| Parameter | Type | Required | Description |
|---|---|---|---|
tokenid |
string | Yes | Your API access token. |
| (body) | array | Yes | Array of CDR objects, fields as per Add a CDR. |
Request
var myData = [
{
orig_id: 'abc1234', // required
startdate: '2020-01-12 01:34:34', // required
enddate: '2020-01-12 01:34:54',
accountcode: 6113000111222,
callerid: 61399997777, // required
did: 611300111222,
direection: 'inbound', // or outbound required
destination: 61411222333, // required
destination_info: 'mobile',
application: 'bridge',
duration: 20, // in seconds
billsec: 20, // in seconds
cost: 0.01,
},
{
orig_id: 'abc1235', // required
startdate: '2020-01-12 01:36:34', // required
enddate: '2020-01-12 01:36:56',
accountcode: 6113000111222,
callerid: 61399997888, // required
did: 611300111222,
direection: 'inbound', // or outbound required
destination: 61411222333, // required
destination_info: 'mobile',
application: 'bridge',
duration: 22, // in seconds
billsec: 22, // in seconds
cost: 0.02,
}
];
$.ajax({
url: '/api/892f86d5-da86-4e98-9343-1976a375/cdr/multiple/add',
type: 'POST',
data: JSON.stringify(myData),
contentType: 'application/json',
success: function( response ) {
console.log(response);
}
});
Response (success)
[{"success":true,"yourid":"abc1234","id":5678},{"success":true,"yourid":"abc1235","id":5679}]
Response (error)
[{"success":false,"yourid":"abc1234","description":"CDR ID already exists"},{"success":false,"yourid":"abc1235","description":"CDR ID already exists"}]
Response (mixed)
[{"success":true,"yourid":"abc1234","id":5678},{"success":false,"yourid":"abc1235","description":"CDR ID already exists"}]
GET /:tokenid/cdr/ratingStatusReturn the latest CDR date that has been rated, grouped by CDR source.
| Parameter | Type | Required | Description |
|---|---|---|---|
tokenid |
string | Yes | Your API access token. |
Request
$.ajax({
url: '/api/892f86d5-da86-4e98-9343-1976a375/cdr/ratingStatus',
type: 'GET',
contentType: 'application/json',
success: function( response ) {
console.log(response);
}
});
Response
{
"success": true,
"data": [
{
"source": "AAPT",
"latest_date": "2020-05-31 12:58:52"
},
{
"source": "OPTUS",
"latest_date": "2020-06-22 17:59:29"
},
]
}
GET /:tokenid/cdr/statusUsed to check the status of what the CDR sources have been imported for your instance. This can be used for integrations that collect CDRs, to verify that the imports are up to date. It's grouped by CDR source.
| Parameter | Type | Required | Description |
|---|---|---|---|
tokenid |
string | Yes | Your API access token. |
Request
$.ajax({
url: '/api/892f86d5-da86-4e98-9343-1976a375/cdr/status',
type: 'GET',
contentType: 'application/json',
success: function( response ) {
console.log(response);
}
});
Response
{
"success": true,
"data": [
{
"source": "AAPT",
"latest_date": "2020-05-31 12:58:52"
},
{
"source": "OPTUS",
"latest_date": "2020-06-22 17:59:29"
},
]
}
GET /:tokenid/cdr/getPrice/:idRetrieve the rating information (rate code, rate name and price) for a single billed call record.
| Parameter | Type | Required | Description |
|---|---|---|---|
tokenid |
string | Yes | Your API access token. |
id |
string | Yes | The billed call record ID. |
Request
$.ajax({
url: '/api/892f86d5-da86-4e98-9343-1976a375/cdr/getPrice/CRDDJ6RYMBBNRXJQ2TWXDUWMWUWTL42Q',
type: 'GET',
contentType: 'application/json',
success: function( response ) {
console.log(response);
}
});
Response (success)
{
"success":true,
"data":
{
"id":"8776",
"ratecode":"*UAUS-M-@SIP",
"rate_name":"AU Mobile to SIP",
"price":"0.57"
}
}
Response (error)
{"success":false,"description":"no billed call found"}
POST /:tokenid/cdr/getMultiplePriceRetrieve the rating information for multiple call records. You need to set the API Key variable of cdr_source to the required CDR source in order for this to work. It's designed for legacy systems to integrate back into the billing platform to produce CDR results with additional non billing related information.
The body is a JSON array of call record IDs. IDs that could not be matched are returned in failures.
| Parameter | Type | Required | Description |
|---|---|---|---|
tokenid |
string | Yes | Your API access token. |
| (body) | array of string | Yes | Billed call record IDs to price. |
Request
var myData = [
"CU4Y5KKRJCXGVO4ITUBTRWR5VVGW6F3Q",
"CCWSSUWTVFLJSDQF4BEI2WQ2ROFNHHDI",
"CEKS7QZBGTQPIH5BOW3ZF74B6ALMZRIA",
"ABCHJKHKJHKJH7850HJGH34565KJVF7H"
];
$.ajax({
url: '/api/892f86d5-da86-4e98-9343-1976a375/cdr/getMultiplePrice',
data: JSON.stringify(myData),
type: 'POST',
contentType: 'application/json',
success: function( response ) {
console.log(response);
}
});
Response (success)
{
"success":true,
"data":[
{
"id":"CU4Y5KKRJCXGVO4ITUBTRWR5VVGW6F3Q",
"ratecode":"UAUS-MSIP",
"rate_name":"Mobile to SIP",
"price":"0.57"
},
{
"id":"CCWSSUWTVFLJSDQF4BEI2WQ2ROFNHHDI",
"ratecode":"1300MTF",
"rate_name":"Mobile to Landline",
"price":"0.0402"
},
{
"id":"CEKS7QZBGTQPIH5BOW3ZF74B6ALMZRIA",
"ratecode":"UAUS-MSIP",
"rate_name":"Mobile to SIP",
"price":"0.0049"
}
],
"failures":[
"ABCHJKHKJHKJH7850HJGH34565KJVF7H"
]
}
Response (error)
{"success":false,"description":"no billed call found"}
GET /:tokenid/cdr/exportsRetrieve the CDR export schedule information for all customers with an active export.
| Parameter | Type | Required | Description |
|---|---|---|---|
tokenid |
string | Yes | Your API access token. |
Request
$.ajax({
url: '/api/892f86d5-da86-4e98-9343-1976a375/cdr/exports',
type: 'GET',
contentType: 'application/json',
success: function( response ) {
console.log(response);
}
});
Response
{
"success":true,
"data":
[
{
"cid":"1234",
"company":"Test Company",
"frequency":"daily",
"path":"some_folder/daily",
"format":"basic",
"lastRun":"2022-02-26 02:00:00",
"nextRun":"2022-02-27 02:00:00"
}
]
}
GET /:tokenid/cdr/exports/include_inactiveRetrieve the information for all customers' CDR exports, including customers who won't export again.
| Parameter | Type | Required | Description |
|---|---|---|---|
tokenid |
string | Yes | Your API access token. |
Request
$.ajax({
url: '/api/892f86d5-da86-4e98-9343-1976a375/cdr/exports/include_inactive',
type: 'GET',
contentType: 'application/json',
success: function( response ) {
console.log(response);
}
});
Response
{
"success":true,
"data":
[
{
"cid":"1234",
"company":"Test Company",
"frequency":"daily",
"path":"some_folder/daily",
"format":"basic",
"lastRun":"2022-02-26 02:00:00",
"nextRun":null
}
]
}
Related: Getting started with the API, API overview, Call rates and call types API, Pricing API.