API - Call Detail Records - CDR¶
API CDR se foloseste pentru a citi lista de apeluri din centrala
API URL¶
https://[YOUR-PBX-URL]/api/cdr
Datele se trasmit prin POST sau GET si trebuie sa fie de forma:¶
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
)
Parametrul page este implicit 1, va trebui incrementat pentru a extrage datele de pe toate paginile.
Headere HTTP:¶
Content-Type: text/xml Authorization: Bearer <token>
Filtre:¶
- date_between: intervalul pentru care se face filtrare
- project_id: ID proiect in centrala
- user_id: ID user in centrala
- inbound_route_id: ID-uri Inbound routes
- direction: tipul de apel: inbound sau outbound (IN, OUT)
- call_status: status apel (NO ANSWER, CONGESTION, FAILED, BUSY, ANSWERED)
- telephone_like: filtru dupa un numar de telefon indiferent (wildcard)
- telephone: filtru dupa un numar de telefon indiferent (exact)
- source: numarul de telefon de la care s-a initiat apelul
- destination: numarul de telefon catre care s-a initiat apelul
- hour_between: intervalul orar pentru care se face filtrare
- from_id: ID start pentru extragere informatii (cand se retine ultimul ID sincronizat)
- uniqueid: ID apel
- linkedid: ID apeluri inrudite
- external_id: ID extern
Exemplu generare parametri:
$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,
)
);
Exemplu generare hash:
$params['api_hash'] = md5(http_build_query($params) . 'your_api_key'); // make hash
Exemplu trimitere date:
$url = 'https://[YOUR-PBX-URL]/api/cdr';
$token = 'your_api_token';
echo curlPost($url, http_build_query($params), array("Authorization: Bearer {$token}"));
Date trimise JSON:¶
{
"page": 1,
"filters": {
"date_between": [
"2024-01-01 00:00:00",
"2024-01-15 23:59:59"
],
"project_id": null,
"user_id": null,
"inbound_route_id": null,
"direction": null,
"call_status": null,
"telephone_like": null,
"telephone": null,
"source": null,
"destination": null,
"hour_between": null,
"from_id": null,
"uniqueid": null,
"linkedid": null,
"has_transcription": null,
"has_monitor_file": null,
"has_recording_file": null,
"external_id": null
},
"api_hash": "ff9a6b157cb1f79db73e7507635f878a"
}
Raspuns¶
In caz de succes:
{
"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_files": null,
"monitor_urls": 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"
}
]
}
}
Sau in caz de eroare:
{
"has_error": true,
"messages": [
"Invalid filter: from_idxx"
],
"pagination": [ ],
"results": [ ]
}
Disponibil si in alte limbi: EN