API - Users status¶
API Users status is used to monitor the status of the users in the PBX (phone registration, calls in progress, pause).
API URL¶
https://[YOUR-PBX-URL]/api/users-status
Data is sent via POST or GET and must be of the form:¶
Array
(
[type] => sip
[get_stats] => false
[api_hash] => bb76587c4cc53d74fecbb189dd5dbbb8
)
The type parameter is required and must have the value sip.
The get_stats parameter is optional: if it is true, the response also contains outbound_calls (the number of outbound calls today, within working hours), last_status, last_status_time and last_status_diff (the user's last status today: OK, offline, paused or no_schedule, and for how long the user has had it). In JSON send true / false; in form-data send 1 / 0 (any non-empty value, including the text "false", enables the statistics).
HTTP Headers:¶
Content-Type: application/json Authorization: Bearer <token>
Example of hash generation:
$params['api_hash'] = md5(json_encode($params) . 'your_api_key'); // make hash
Example for data sending:
$url = 'https://[YOUR-PBX-URL]/api/users-status';
$token = 'your_api_token';
echo curlPost($url, json_encode($params), array("Authorization: Bearer {$token}", "Content-Type: application/json"));
Response¶
If successful (with get_stats = true):
The results are keyed by username. All the users configured in the PBX are listed; id, extension, remote_id and pause_info appear only for the users active in the application. registrar contains the phones registered on the user (there can be several), and pause_info the active pause (empty if the user is not on pause).
{
"has_error": false,
"messages": [ ],
"results": {
"john-doe": {
"username": "john-doe",
"dnid": "0212345000",
"status": "OK",
"in_use": 1,
"limit": 3,
"status_info": "In use",
"registrar": [
{
"uri": "sip:john-doe@203.0.113.10:5060;x-ast-orig-host=192.168.1.20:5060",
"ip": "203.0.113.10",
"port": "5060",
"info": "x-ast-orig-host=192.168.1.20:5060",
"useragent": "Yealink SIP-T46U 108.86.0.20",
"key": "@4f6c1d0a9b8e7f6a5b4c3d2e1f0a9b8c",
"status_info": "Avail (12.5 ms)"
}
],
"outbound_calls": 14,
"last_status": "paused",
"last_status_time": "2024-03-14 09:12:31",
"last_status_diff": "02:15:40",
"id": "12",
"extension": "101",
"remote_id": null,
"pause_info": {
"id": "5310",
"user_id": "12",
"pause_start": "2024-03-14 11:20:05",
"pause_time": "15",
"reason": "Pauza masa",
"paused_by": null
}
}
}
}
Or in case of error (Invalid type: ... or Manager error: ... if the PBX does not respond):
{
"has_error": true,
"messages": [
"Invalid type: sipx"
],
"results": [ ]
}
Available in other languages: RO