API - Queues Save¶
Queues Save API is used to update the members of 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] => save
[data] => Array
(
[demo-queue] => Array
(
[members] => Array
(
[john-doe] => Array
(
[type] => sip
[penalty] => 0
[order] => 0
[is_active] => 1
)
[jane-doe] => Array
(
[type] => fallback
[penalty] => 0
[order] => 0
[is_active] => 1
)
[+40123456789] => Array
(
[type] => remote
[penalty] => 0
[order] => 0
[is_active] => 1
)
)
)
)
[api_hash] => 07112231a9c89f5b108af08608a97b07
)
The action parameter must have the value save (default). In data the key is the queue name, and in members the key is the member: the username for the sip and fallback types, the phone number for remote.
Member parameters:- type: mandatory, sip (the user's phone), fallback (the user's fallback number) or remote (external number)
- is_active: mandatory; 1 = member in the queue, 0 = removed from the queue
- penalty: optional, default 0
- order: optional, default 0
- name: optional; for users the user's name is used by default
WARNING: the list sent replaces the queue members. Any existing member that is not sent, is sent with is_active = 0 or has invalid data is removed from the queue. If the members list is empty, all members are removed.
After saving, the queue configuration is regenerated and reloaded in the PBX.
HTTP Headers:¶
Content-Type: application/json Authorization: Bearer <token>
Example of parameters generation:
$params = array(
'action' => 'save',
'data' => array(
'demo-queue' => array(
'members' => array(
'john-doe' => array(
'type' => 'sip',
'penalty' => 0,
'order' => 0,
'is_active' => 1
),
'jane-doe' => array(
'type' => 'fallback',
'penalty' => 0,
'order' => 0,
'is_active' => 1
),
'+40123456789' => array(
'type' => 'remote',
'penalty' => 0,
'order' => 0,
'is_active' => 1
)
)
)
)
);
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": "save",
"data": {
"demo-queue": {
"members": {
"john-doe": {
"type": "sip",
"penalty": 0,
"order": 0,
"is_active": 1
},
"jane-doe": {
"type": "fallback",
"penalty": 0,
"order": 0,
"is_active": 1
},
"+40123456789": {
"type": "remote",
"penalty": 0,
"order": 0,
"is_active": 1
}
}
}
},
"api_hash": "d8f317d9c98cfa2b14e5049ca4b1af81"
}
Response¶
If successful, results is keyed by the queue name and contains the saved members, with their ID and the ID of the associated user (user_id is null for remote):
{
"has_error": false,
"messages": [ ],
"results": {
"demo-queue": {
"john-doe": {
"id": "151",
"user_id": "12",
"alias": "john-doe",
"name": "John Doe",
"type": "sip",
"penalty": 0,
"order": 0,
"is_active": 1
},
"jane-doe": {
"id": "152",
"user_id": "14",
"alias": "jane-doe",
"name": "Jane Doe",
"type": "fallback",
"penalty": 0,
"order": 0,
"is_active": 1
},
"+40123456789": {
"id": 153,
"user_id": null,
"alias": "+40123456789",
"name": null,
"type": "remote",
"penalty": 0,
"order": 0,
"is_active": 1
}
}
}
}
If several queues are sent, each one is processed separately: valid queues are saved even if others have errors.
Possible errors: Request data array is missing, Members are missing from Queue ..., skipping update, Invalid Queue name: ..., Invalid parameters for user ..., Queue ... (is_active missing or invalid type), Duplicate alias ... for member ..., You can't use same Queue extension (...) as a remote number, You can't use a Trunk identity (...) as a remote number.
Or in case of error:
{
"has_error": true,
"messages": [
"Invalid Queue name: demo-queuex"
],
"results": [ ]
}
Available in other languages: RO