API - Queues Stats¶
Queues Stats API is used to extract statistics about the queues in the PBX
API URL¶
https://[YOUR-PBX-URL]/api/queues
Data is sent via POST or GET and must be of the form:¶
Array
(
[action] => stats
[data] => Array
(
[queue_status] => true
)
[filters] => Array
(
[queues] => Array
(
[0] => demo-queue
[1] => sales-queue
)
[date_between] => Array
(
[0] => 2023-01-01 00:00:00
[1] => 2023-01-01 23:59:59
)
)
[api_hash] => 07112231a9c89f5b108af08608a97b07
)
The action parameter must have the value stats.
The queue_status parameter in data must be true to receive the statistics (otherwise results is empty). The statistics are calculated from the calls that entered the queues (position in the queue, wait time, ring time, talk duration).
HTTP Headers:¶
Content-Type: application/json Authorization: Bearer <token>
Filters:¶
- queues: queue names (array or a single queue as text); without the filter, all queues
- date_between: array(from, to). Format: Y-m-d H:i:s (eg: 2023-01-01 00:00:00); applied only if it has exactly 2 values. Without the filter, the whole period
Any other filter (eg: project_id) returns the Invalid filter: ... error.
Example of parameters generation:
$params = array(
'action' => 'stats',
'data' => array(
'queue_status' => true
),
'filters' => array(
'queues' => array('demo-queue', 'sales-queue'),
'date_between' => array('2023-01-01 00:00:00', '2023-01-01 23:59:59'), // array(from, to)
)
);
Example of hash generation:
$params['api_hash'] = md5(json_encode($params) . 'your_api_key'); // make hash
Example of sending data:
$url = 'https://[YOUR-PBX-URL]/api/queues';
$token = 'your_api_token';
echo curlPost($url, json_encode($params), array("Authorization: Bearer {$token}", "Content-Type: application/json"));
Data sent JSON¶
{
"action": "stats",
"data": {
"queue_status": true
},
"filters": {
"queues": [
"demo-queue",
"sales-queue"
],
"date_between": [
"2023-01-01 00:00:00",
"2023-01-01 23:59:59"
]
},
"api_hash": "27a081a1267f30fe7261c99f6a50b9ca"
}
Response¶
If successful (avg = average per call, sum = total; times are in seconds):
{
"has_error": false,
"messages": [ ],
"results": {
"queue_status": {
"avg_position": "1.0055",
"avg_original_position": "0.9746",
"avg_hold_time": "14.4917",
"sum_hold_time": "26201",
"avg_ring_time": "7.0902",
"sum_ring_time": "12819",
"avg_call_duration": "174.9082",
"sum_call_duration": "316234"
}
}
}
Or in case of error:
{
"has_error": true,
"messages": [
"Invalid filter: project_id"
],
"results": [ ]
}
Available in other languages: RO