Project

General

Profile

API - Queues Read

Queues Read API is used to read the queues from the PBX, with their members and real-time statistics.

API URL

https://[YOUR-PBX-URL]/api/queues

Data is sent via POST or GET and must be of the form:

Array
(
    [action] => read
    [data] => Array
        (
            [get_info] => false
            [get_db_reports] => false
        )
    [filters] => Array
        (
            [project_id] => 
            [queues] => Array
                (
                    [0] => demo-queue
                    [1] => sales-queue
                )

        )

    [api_hash] => 07112231a9c89f5b108af08608a97b07
)

The action parameter must have the value read.

Options in data (optional, default false):
  • get_info: adds to stats the members with their status in the PBX (members, including the active pause), the waiting callers (callers), available_members, paused_members, available_slots and the queue settings (vars)
  • get_db_reports: today's statistics (answered / unanswered calls, wait / talk time, answered transferred calls, recovered callers) are calculated from the database, not from the PBX counters (which are reset on restart or on Reset stats)

HTTP Headers:

Content-Type: application/json
Authorization: Bearer <token>

Filters:

  • project_id: project ID in the PBX or an array of IDs; -1 in the list also includes queues without a project
  • queues: queue names (array or a single queue as text)

Any other filter returns the Invalid filter: ... error. If no queue is found, the error is No Queues found.

Example of parameters generation:

$params = array(
    'action' => 'read',
    'data' => array(
        'get_info' => false,
        'get_db_reports' => false
    ),
    'filters' => array(
        'project_id' => null,
        'queues' => array('demo-queue', 'sales-queue')
    )
);

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": "read",
  "data": {
    "get_info": false,
    "get_db_reports": false
  },
  "filters": {
    "project_id": null,
    "queues": [
      "demo-queue",
      "sales-queue" 
    ]
  },
  "api_hash": "de1b56d49bf027503ef3ecee05b9c59d" 
}

Response

If successful, results is keyed by the queue ID. members contains the members configured in the application, and stats the statistics from the PBX (example with get_info = true; the vars and info_block fields are shortened):

{
    "has_error": false,
    "messages": [ ],
    "results": {
        "3": {
            "id": 3,
            "name": "sales-queue",
            "extension": 501,
            "project_id": 1,
            "user_id": null,
            "service_level": 60,
            "critical_service_level": 30,
            "outbound_number": null,
            "reset_stats": null,
            "vars": {
                "maxlen": "15",
                "strategy": "linear",
                "timeout": "30" 
            },
            "status": "active",
            "project_name": "Test project",
            "members_cnt": 2,
            "max_penalty": 1,
            "members": {
                "john-doe": {
                    "id": 151,
                    "queue_id": 3,
                    "type": "sip",
                    "name": "John Doe",
                    "alias": "john-doe",
                    "user_id": 12,
                    "penalty": 0,
                    "order": 0,
                    "fallback_number": null,
                    "user_type": "sip",
                    "is_active": 1
                }
            },
            "stats": {
                "queue_name": "sales-queue",
                "calls_no": "1",
                "calls_max": "15",
                "strategy": "linear",
                "hold_time": "4",
                "talk_time": "161",
                "weight": "0",
                "calls_answered": "3",
                "calls_unanswered": "0",
                "service_level": "100.0",
                "service_level2": "100.0",
                "service_time_period": "60",
                "available_members": 1,
                "paused_members": 0,
                "available_slots": 14,
                "callers": [ ],
                "members": {
                    "john-doe": {
                        "type": "PJSIP",
                        "username": "john-doe",
                        "penalty": "",
                        "status": "Not in use",
                        "cnt_calls": "3",
                        "cnt_call_seconds": "1325",
                        "cnt_login_seconds": "16853",
                        "name": "John Doe",
                        "pause": [ ]
                    }
                },
                "info_block": "..." 
            }
        }
    }
}

Or in case of error:

{

    "has_error": true,
    "messages": [
        "No Queues found" 
    ],
    "results": [ ]

}

Available in other languages: RO