API - Call Detail Records - CDR¶
The API CDR is used to read the PBX call list
API URL¶
https://[YOUR-PBX-URL]/api/cdr
Data is sent via POST or GET and must be of the form:¶
Array ( [page] => 1 [filters] => Array ( [date_between] => Array ( [0] => 2024-01-01 00:00:00 [1] => 2024-01-15 23:59:59 ) [project_id] => [user_id] => [inbound_route_id] => [direction] => [call_status] => [telephone_like] => [telephone] => [source] => [destination] => [hour_between] => [from_id] => [uniqueid] => [linkedid] => [external_id] => [has_transcription] => [has_monitor_file] => [has_recording_file] => ) [api_hash] => 07112231a9c89f5b108af08608a97b07 )
The action parameter must be read. The page parameter's default value is 1, it will need to be incremented to extract the data from all pages.
HTTP Headers:¶
Content-Type: text/xml Authorization: Bearer <token>
Filters:¶
- date_between: the interval for which filtering is performed
- project_id: project ID in PBX
- user_id: User ID in PBX
- inbound_route_id: Inbound routes IDs
- direction: call type: inbound or outbound (IN, OUT)
- call_status: call status (NO ANSWER, CONGESTION, FAILED, BUSY, ANSWERED)
- telephone_like: filter by any phone number (wildcard)
- telephone: filter by any phone number (exact)
- source: the phone number from which the call was initiated
- destination: the telephone number to which the call was initiated
- hour_between: the time interval for which filtering is performed
- from_id: ID start for retrieving information (when the last synchronized ID is retained)
- uniqueid: Call ID
- linkedid: Linked calls ID
- external_id: External ID
Example of parameters generation:
$params = array(
'page' => 1,
'filters' => array(
'date_between' => array('2024-01-01 00:00:00', '2024-01-15 23:59:59'), // array(from, to)
'project_id' => null,
'user_id' => null, // Users IDs
'inbound_route_id' => null, // array(1,2,3,4) Inbound Routes IDs
'direction' => null, // IN, OUT
'call_status' => null, // NO ANSWER, CONGESTION, FAILED, BUSY, ANSWERED
'telephone_like' => null, // Wildcard search for source OR destination
'telephone' => null, // Exact search for source OR destination
'source' => null, // Wildcard search for source
'destination' => null, // Wildcard search for destination
'hour_between' => null, // array(from, to)
'from_id' => null, // >= id
'uniqueid' => null,
'linkedid' => null,
'has_transcription' => null,
'has_monitor_file' => null,
'has_recording_file' => null,
'external_id' => null,
)
);
Example of hash generation:
$params['api_hash'] = md5(http_build_query($params) . 'your_api_key'); // make hash
Example for data sending:
$url = 'https://[YOUR-PBX-URL]/api/cdr';
$token = 'your_api_token';
echo curlPost($url, http_build_query($params), array("Authorization: Bearer {$token}"));
Answer¶
If successful:
{
"has_error": false,
"messages": [ ],
"pagination": {
"row_count": 0,
"page_size": 100,
"current_page": 0,
"max_page": 0
},
"results": [
{
"id": "29056",
"uniqueid": "1710401324.480",
"linkedid": "1710401324.480",
"time": "2024-03-14 09:28:44",
"time_end": "2024-03-14 09:29:00",
"caller_id": "\"John Doe\" <0312000000>",
"source": "0312285000",
"destination": "0700000000",
"direction": "OUT",
"channel_formatted": "PJSIP/john-doe",
"dstchannel_formatted": "",
"customer_id": null,
"user_fullname": "John Doe",
"qname": null,
"code": "outbound",
"call_status": "FAILED",
"call_status_info": "DS:CONGESTION|HC:34|HI:SIP 503 Service Unavailable",
"call_codes": "out no answer",
"accounting_code": null,
"accounting_value": null,
"comments": null,
"monitor_file": null,
"monitor_url": null,
"recording_file": null,
"recording_url": null,
"transfers": null,
"project": "My Project",
"inbound_route": null,
"inbound_route_id": null,
"queue_log": null,
"ivr_log": null,
"external_id": null,
"external_info": null,
"agent_details": null,
"is_recovered": null,
"transcription_id": null,
"transcription_text": null,
"bill_duration": "00:00:00",
"duration": "00:00:15",
"bill_minutes": 0,
"ivr_duration": "00:00:00",
"hold_time": "00:00:00",
"ring_time": "00:00:00"
}
]
}
}
Or in case of error:
{
"has_error": true,
"messages": [
"Invalid filter: from_idxx"
],
"pagination": [ ],
"results": [ ]
}
Available in other languages: RO