Project

General

Profile

API - Schedule Read

API Schedule Read is used to read the schedule (opening hours) of the PBX elements: projects, Inbound routes, IVRs, queues, users, contacts.

API URL

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

The data is transmitted via POST or GET and must be of the form:

Array
(
    [action] => read
    [data] => Array
        (
            [type] => weekdays
        )

    [api_hash] => 07112231a9c89f5b108af08608a97b07
)

The action parameter must have the value read.
The data parameter must contain type with the value weekdays (weekly schedule) or custom (schedule on calendar dates, e.g. holidays).

The response contains all the elements that have a schedule of the requested type. For each element: element_type (project, inbound_route, contact, user, ivr_menu, pbx_queue), element_id, name, project_id, wdays (the days with a schedule, 0 = Sunday ... 6 = Saturday), dates (for custom) and intervals (the intervals, with weekday or date, key - the number of the interval in the day, start / end and the associated messages). An interval 00:00:00 - 00:00:00 means closed all day.

HTTP Headers:

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

Example of parameter generation:

$params = array(
    'action' => 'read',
    'data' => array(
        'type' => 'weekdays', // custom
    )
);

Example hash generation:

$params['api_hash'] = md5(json_encode($params) . 'your_api_key'); // make hash

Example of sending data:

$url = 'https://[YOUR-PBX-URL]/api/schedule';
$token = 'your_api_token';
echo curlPost($url, json_encode($params), array("Authorization: Bearer {$token}", "Content-Type: application/json"));

Data sent JSON

{
   "action":"read",
   "data":{
      "type":"weekdays" 
   },
   "api_hash":"de1b56d49bf027503ef3ecee05b9c59d" 
}

Response

In case of success:

{

    "has_error": false,
    "messages": [ ],
    "results": [
        {
            "element_id": 1,
            "element_type": "project",
            "cnt": 7,
            "wdays": [0, 1, 2, 3, 4, 5, 6],
            "dates": [ ],
            "name": "Test project",
            "project_id": 1,
            "intervals": [
                {
                    "id": 1,
                    "element_type": "project",
                    "element_id": 1,
                    "weekday": 0,
                    "date": null,
                    "key": 1,
                    "start": "00:00:00",
                    "end": "00:00:00",
                    "break_interval": null,
                    "welcome_message": null,
                    "ns_welcome_message": null,
                    "closed_message": null,
                    "closed_gosub": null,
                    "break_message": null,
                    "status": "active" 
                },
                {
                    "id": 2,
                    "element_type": "project",
                    "element_id": 1,
                    "weekday": 1,
                    "date": null,
                    "key": 1,
                    "start": "09:00:00",
                    "end": "18:00:00",
                    "break_interval": "13:00-14:00",
                    "welcome_message": null,
                    "ns_welcome_message": null,
                    "closed_message": null,
                    "closed_gosub": null,
                    "break_message": "lunch-break",
                    "status": "active" 
                }
            ]
        }
    ]

}

Or in case of error:

{

    "has_error": true,
    "messages": [
        "Invalid schedule type: xxx" 
    ],
    "results": [ ]

}

Available in other languages: RO