Time Intervals (/interval/)

Time Intervals (/interval/)

You can test API methods on the interactive API browser page and without writing code
Some of the resources described on the page may not be available by default due to the type of application (see Creating and authorizing applications).

This resource is used to manage time intervals that can be used later, for example, to specify the validity period of incoming call rules.

Description of data structures

Interval (IntervalItem)

Name

Type

Mandatory

Default value

Description

Name

Type

Mandatory

Default value

Description

conditions

Array[condition]

yes



List of interval time range conditions

name

string

yes



Interval name

timezone

string

yes



Time zone of the interval

Condition (Condition) 

The parameters must be set in pairs (if "start_time" is set, then there must also be "end_time"), except for the "month" parameter, which can be set by itself.

If "start_datetime" and "end_datetime" are set, the other parameters will be ignored. All parameters (except "start_datetime" and "end_datetime") complement each other. If, for example, "month=7, start_dow=2, end_dow=3" are defined, then this implies all Mondays and Tuesdays in July.

Parameters with the "start" prefix must be smaller than parameters with the "end" prefix. The exception is the pair "start_dow/end_dow", where the entry "start_dow=3, end_dow=1" can specify all days of the week, except Monday.

At the first match by the condition, the interval is worked out, at the absence of matches in the conditions of the interval, the interval does not work.

Name

Type

Mandatory

Default value

Description

Name

Type

Mandatory

Default value

Description

end_dow

long

none

0

End day of the week 1-7 (1-Sunday, 7-Saturday)

end_mday

long

none

0

End day of the month (1-31)

end_time

string

none

 

End time in the format " hh:mm:ss"

month

long

none

0

Month of validity in the range of 1-12

sched_active_days

long

none

0

Number of working days (minimum 1) starting from the start date (sched_start_date)

Used for an interval of the scheduled_days type

sched_skip_days

long

none

0

The number of non-working days (at least 1) to skip before the next working days (sched_active_days).
For example, if "sched_active_days=1", "sched_skip_days=2", the working day will be the 1st, the weekend-the 2nd and 3rd, the working day-the 4th and non-working day - the 5th and 6th, etc.

Used for an interval of the scheduled_days type

sched_start_date

string

none



Work start date in the format "YYYY-MM-DD hh:mm:ss", for example: "2015-02-20 15:33:01"

Used for an interval of the scheduled_days type

start_datetime

string

none



Start date in the format "YYYY-MM-DD hh:mm:ss", for example: "2015-02-20 15:33:01"

Used for an interval of the datetime_range type. 

end_datetime

string

none



End date in the format "YYYY-MM-DD hh:mm:ss", for example: "2015-02-20 16:34:00"

Used for an interval of the datetime_range type. 

start_dow

long

none

0

Start day of week 1-7 (1-Sunday, 7-Saturday)

start_mday

long

none

0

Start day of the month (1-31)

start_time

string

none

 

Start time in the format "hh:mm:ss"

type

string

none



response parameter. May be one of the: 

datetime_range

interval

scheduled_days

usage

object

none

null

{ 'task_scheduler': {}, # {task_sched_id: null} 'context_rule': {}, # {ext_id: [{context: 1, option: ‘start’, rule: 2}], } 'incom_rule': {} # {ext_id: [{rule: 1}], } }

Contains information on the use of intervals in Task Schedulers, inbound call rules, and IVR context rules. Relevant only for client-level and extension intervals.

Example

For a client with ID 12, create a range that is responsible for Monday-Friday from 09:00 to 18:00 and Saturday from 09:00 to 14:00:

Composition - Tabs
{   "timezone": "Europe/Moscow",   "conditions": [     {       "start_datetime": null,       "start_dow": 2,       "start_time": "09:00:00",       "month": null,       "end_mday": null,       "end_dow": 6,       "end_time": "18:00:00",       "start_mday": null,       "end_datetime": null     },     {       "start_datetime": null,       "start_dow": 7,       "start_time": "09:00:00",       "month": null,       "end_mday": null,       "end_dow": 7,       "end_time": "14:00:00",       "start_mday": null,       "end_datetime": null     }   ],   "id": 85,   "client_id": 12,   "name": "working hours" }

Resources of the "Client" section

POST /client/{client_id}/interval/ Add a time interval URL Parameters Name Type client_id string JSON parameters Name Type Mandatory conditions Array[condition] yes name string yes timezone string yes Condition resource Name Type Mandatory end_datetime string none end_dow long none end_mday long none end_time string none month long none sched_active_days long none sched_skip_days long none sched_start_date string none start_datetime string none start_dow long none start_mday long none start_time string none Response fields Name Type client_id long conditions Array[interval_condition] dealer_id long extension_id long id long name string timezone string Interval_condition resource Name Type Mandatory end_datetime string none end_dow long none end_mday long none end_time string none month long none sched_active_days long none sched_skip_days long none sched_start_date string none start_datetime string none start_dow long none start_mday long none start_time string none type  string none
GET /client/{client_id}/interval/ Get a list of time intervals URL Parameters Name Type client_id string Response fields Name Type client_id long conditions Array[interval_condition] dealer_id long extension_id long id long name string timezone string Interval_condition resource Name Type Mandatory end_datetime string none end_dow long none end_mday long none end_time string none month long none sched_active_days long none sched_skip_days long none sched_start_date string none start_datetime string none start_dow long none start_mday long none start_time string none type  string none
PUT /client/{client_id}/interval/{interval_id} Update the time interval URL Parameters Name Type client_id string interval_id integer JSON parameters Name Type Mandatory conditions Array[condition] yes name string yes timezone string yes Condition resource Name Type Mandatory end_datetime string none end_dow long none end_mday long none end_time string none month long none sched_active_days long none sched_skip_days long none sched_start_date string none start_datetime string none start_dow long none start_mday long none start_time string none Response fields Name Type client_id long conditions Array[interval_condition] dealer_id long extension_id long id long name string timezone string Interval_condition resource Name Type Mandatory end_datetime string none end_dow long none end_mday long none end_time string none month long none sched_active_days long none sched_skip_days long none sched_start_date string none start_datetime string none start_dow long none start_mday long none start_time string none type  string none
GET /client/{client_id}/interval/{interval_id} Get the time interval URL Parameters Name Type client_id string interval_id integer Response fields Name Type client_id long conditions Array[interval_condition] dealer_id long extension_id long id long name string timezone string Interval_condition resource Name Type Mandatory end_datetime string none end_dow long none end_mday long none end_time string none month long none sched_active_days long none sched_skip_days long none sched_start_date string none start_datetime string none start_dow long none start_mday long none start_time string none type  string none
DELETE /client/{client_id}/interval/{interval_id} Delete the time interval URL Parameters Name Type client_id string interval_id integer

Resources of the "Internal number" section

GET /extension/{extension_id}/interval/ Get a list of time intervals URL Parameters Name Type extension_id string Response fields Name Type client_id long conditions Array[interval_condition] dealer_id long extension_id long id long name string timezone string Interval_condition resource Name Type Mandatory end_datetime string none end_dow long none end_mday long none end_time string none month long none sched_active_days long none sched_skip_days long none sched_start_date string none start_datetime string none start_dow long none start_mday long none start_time string none type  string none