Get Resource Bookings by Filter calendar.resource.booking.list
Scope:
calendarWho can execute the method: any user
This method retrieves resource bookings based on a filter.
Method Parameters
Required parameters are marked with *
|
Name |
Description |
|
filter* |
Filter fields |
Filter Parameter
Required parameters are marked with *
|
Name |
Description |
|
resourceTypeIdList* |
List of resource identifiers. Identifiers can be obtained using the method calendar.resource.list |
|
from |
Start date of the period |
|
to |
End date of the period |
|
resourceIdList* |
List of resource booking identifiers from the custom field of type Identifiers can be obtained via:
To find out which custom fields have the type |
In the method calendar.resource.booking.list, you must use only one of the two required parameters: resourceTypeIdList or resourceIdList. Both parameters cannot be used together.
Code Examples
Example 1. Assess resource availability over a period, for instance, to create custom views of availability or for use in application logic.
How to Use Examples in Documentation
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"filter":{"resourceTypeIdList":[10852,10888,10873,10871,10853],"from":"2024-06-20","to":"2024-08-20"}}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/calendar.resource.booking.list
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"filter":{"resourceTypeIdList":[10852,10888,10873,10871,10853],"from":"2024-06-20","to":"2024-08-20"},"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/calendar.resource.booking.list
// callListMethod: Retrieves all data at once. Use only for small selections (< 1000 items) due to high memory usage.
try {
const response = await $b24.callListMethod(
'calendar.resource.booking.list',
{
filter: {
resourceTypeIdList: [10852, 10888, 10873, 10871, 10853],
from: '2024-06-20',
to: '2024-08-20',
}
},
(progress) => { console.log('Progress:', progress) }
);
const items = response.getData() || [];
for (const entity of items) { console.log('Entity:', entity); }
} catch (error) {
console.error('Request failed', error);
}
// fetchListMethod: Retrieves data in parts using an iterator. Use it for large data volumes to optimize memory usage.
try {
const generator = $b24.fetchListMethod('calendar.resource.booking.list', {
filter: {
resourceTypeIdList: [10852, 10888, 10873, 10871, 10853],
from: '2024-06-20',
to: '2024-08-20',
}
}, 'ID');
for await (const page of generator) {
for (const entity of page) { console.log('Entity:', entity); }
}
} catch (error) {
console.error('Request failed', error);
}
// callMethod: Manually controls pagination through the start parameter. Use it for precise control of request batches. For large datasets, it is less efficient than fetchListMethod.
try {
const response = await $b24.callMethod('calendar.resource.booking.list', {
filter: {
resourceTypeIdList: [10852, 10888, 10873, 10871, 10853],
from: '2024-06-20',
to: '2024-08-20',
}
}, 0);
const result = response.getData().result || [];
for (const entity of result) { console.log('Entity:', entity); }
} catch (error) {
console.error('Request failed', error);
}
try {
$response = $b24Service
->core
->call(
'calendar.resource.booking.list',
[
'filter' => [
'resourceTypeIdList' => [10852, 10888, 10873, 10871, 10853],
'from' => '2024-06-20',
'to' => '2024-08-20',
],
]
);
$result = $response
->getResponseData()
->getResult();
echo 'Success: ' . print_r($result, true);
// Your logic for processing data
processData($result);
} catch (Throwable $e) {
error_log($e->getMessage());
echo 'Error fetching resource booking list: ' . $e->getMessage();
}
BX24.callMethod(
'calendar.resource.booking.list',
{
filter: {
resourceTypeIdList: [10852, 10888, 10873, 10871, 10853],
from: '2024-06-20',
to: '2024-08-20',
}
}
);
require_once('crest.php');
$result = CRest::call(
'calendar.resource.booking.list',
[
'filter' => [
'resourceTypeIdList' => [10852, 10888, 10873, 10871, 10853],
'from' => '2024-06-20',
'to' => '2024-08-20'
]
]
);
echo '<PRE>';
print_r($result);
echo '</PRE>';
Example 2. Select bookings by their identifiers from custom fields of the CRM entity.
How to Use Examples in Documentation
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"filter":{"resourceIdList":[10,18,17]}}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/calendar.resource.booking.list
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"filter":{"resourceIdList":[10,18,17]},"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/calendar.resource.booking.list
// callListMethod: Retrieves all data at once. Use only for small selections (< 1000 items) due to high memory usage.
try {
const response = await $b24.callListMethod(
'calendar.resource.booking.list',
{
filter: {
resourceIdList: [10, 18, 17]
}
},
(progress) => { console.log('Progress:', progress) }
)
const items = response.getData() || []
for (const entity of items) { console.log('Entity:', entity) }
} catch (error) {
console.error('Request failed', error)
}
// fetchListMethod: Retrieves data in parts using an iterator. Use it for large data volumes to optimize memory usage.
try {
const generator = $b24.fetchListMethod('calendar.resource.booking.list', {
filter: {
resourceIdList: [10, 18, 17]
}
}, 'ID')
for await (const page of generator) {
for (const entity of page) { console.log('Entity:', entity) }
}
} catch (error) {
console.error('Request failed', error)
}
// callMethod: Manually controls pagination through the start parameter. Use it for precise control of request batches. For large datasets, it is less efficient than fetchListMethod.
try {
const response = await $b24.callMethod('calendar.resource.booking.list', {
filter: {
resourceIdList: [10, 18, 17]
}
}, 0)
const result = response.getData().result || []
for (const entity of result) { console.log('Entity:', entity) }
} catch (error) {
console.error('Request failed', error)
}
try {
$response = $b24Service
->core
->call(
'calendar.resource.booking.list',
[
'filter' => [
'resourceIdList' => [10, 18, 17]
]
]
);
$result = $response
->getResponseData()
->getResult();
echo 'Success: ' . print_r($result, true);
// Your logic for processing data
processData($result);
} catch (Throwable $e) {
error_log($e->getMessage());
echo 'Error fetching resource booking list: ' . $e->getMessage();
}
BX24.callMethod(
'calendar.resource.booking.list',
{
filter: {
resourceIdList: [10, 18, 17]
}
}
);
require_once('crest.php');
$result = CRest::call(
'calendar.resource.booking.list',
[
'filter' => [
'resourceIdList' => [10, 18, 17]
]
]
);
echo '<PRE>';
print_r($result);
echo '</PRE>';
Response Handling
HTTP Status: 200
{
"result": [
{
"ID": "1408",
"PARENT_ID": "1408",
"DELETED": "N",
"CAL_TYPE": "resource",
"OWNER_ID": "0",
"NAME": "Booking",
"DATE_FROM": "20.12.2024 00:00:00",
"DATE_TO": "21.12.2024 00:00:00",
"TZ_FROM": "Europe/Riga",
"TZ_TO": "Europe/Riga",
"TZ_OFFSET_FROM": "7200",
"TZ_OFFSET_TO": "7200",
"DATE_FROM_TS_UTC": "1734652800",
"DATE_TO_TS_UTC": "1734739200",
"DT_SKIP_TIME": "Y",
"DT_LENGTH": 172800,
"EVENT_TYPE": "#resourcebooking#",
"CREATED_BY": "1",
"DATE_CREATE": "18.12.2024 13:55:35",
"TIMESTAMP_X": "18.12.2024 13:55:35",
"DESCRIPTION": "Service: some",
"IS_MEETING": false,
"MEETING_STATUS": "Y",
"MEETING_HOST": "0",
"VERSION": "1",
"SECTION_ID": "198",
"DATE_FROM_FORMATTED": "Fri Dec 20 2024",
"DATE_TO_FORMATTED": "Sat Dec 21 2024",
"SECT_ID": "198",
"RESOURCE_BOOKING_ID": "10"
},
{
"ID": "1409",
...
}
],
"time": {
"start": 1733318565.183275,
"finish": 1733318565.695058,
"duration": 0.5117831230163574,
"processing": 0.29406094551086426,
"date_start": "2024-12-04T13:22:45+00:00",
"date_finish": "2024-12-04T13:22:45+00:00"
}
}
Returned Data
|
Name |
Description |
|
result |
Array of objects. Each object describes a booking |
Booking Object
Technically, a booking is a calendar event. The method retrieves a set of fields similar to those of a calendar event. Some fields remain empty as they are not relevant for bookings. Below are only the relevant or filled fields.
|
Name |
Description |
|
ID |
Booking identifier |
|
PARENT_ID |
For a booking object, always equal to the |
|
DELETED |
Flag indicating whether the booking is deleted. Possible values:
|
|
CAL_TYPE |
Type of calendar in which the booking is located |
|
OWNER_ID |
For a booking object, always equals |
|
NAME |
Name of the booking |
|
DATE_FROM |
Start date of the booking |
|
DATE_TO |
End date of the booking |
|
TZ_FROM |
Timezone of the start date of the booking |
|
TZ_TO |
Timezone of the end date of the booking |
|
TZ_OFFSET_FROM |
Time offset of the start of the booking relative to UTC in seconds |
|
TZ_OFFSET_TO |
Time offset of the end of the booking relative to UTC in seconds |
|
DATE_FROM_TS_UTC |
Start date and time of the booking in UTC in timestamp format |
|
DATE_TO_TS_UTC |
End date and time of the booking in UTC in timestamp format |
|
DT_SKIP_TIME |
Flag indicating whether the booking lasts all day. Possible values:
|
|
DT_LENGTH |
Duration of the booking in seconds |
|
EVENT_TYPE |
Type of booking |
|
CREATED_BY |
Identifier of the user who created the booking |
|
DATE_CREATE |
Creation date of the booking |
|
TIMESTAMP_X |
Date of modification of the booking |
|
DESCRIPTION |
Description of the booking |
|
IS_MEETING |
For a booking object, always |
|
MEETING_STATUS |
For a booking object, always |
|
MEETING_HOST |
For a booking object, always |
|
VERSION |
Version of booking changes |
|
SECTION_ID |
Identifier of the resource in which the booking is located |
|
DATE_FROM_FORMATTED |
Formatted start date of the booking |
|
DATE_TO_FORMATTED |
Formatted end date of the booking |
|
SECT_ID |
Identifier of the resource in which the booking is located |
|
RESOURCE_BOOKING_ID |
Booking identifier |
Error Handling
HTTP Status: 400
{
"error": "",
"error_description": "The required parameter "filter['resourceTypeIdList']" is not set for the method "calendar.resource.booking.list""
}
|
Name |
Description |
|
error |
String error code. It may consist of digits, Latin letters, and underscores |
|
error_description |
Textual description of the error. The description is not intended to be shown to the end user in its raw form |
Possible Error Codes
|
Code |
Error Message |
Description |
|
Empty string |
Access denied |
Access to the method is prohibited for external users |
|
Empty string |
The required parameter "filter['resourceTypeIdList']" is not set for the method "calendar.resource.booking.list" |
Neither of the required parameters: |
Statuses and System Error Codes
HTTP Status: 20x, 40x, 50x
The errors described below may occur when calling any method.
|
Status |
Code |
Description |
|
|
|
An internal server error has occurred, please contact the server administrator or Bitrix24 technical support |
|
|
|
An internal server error has occurred, please contact the server administrator or Bitrix24 technical support |
|
|
|
The request intensity limit has been exceeded |
|
|
|
The current method is not allowed to be called using batch |
|
|
|
The maximum length of parameters passed to the batch method has been exceeded |
|
|
|
Invalid access token or webhook code |
|
|
|
The methods must be called using the HTTPS protocol |
|
|
|
The REST API is blocked due to overload. This is a manual individual block, to remove it you need to contact Bitrix24 technical support |
|
|
|
The REST API is available only on commercial plans |
|
|
|
The user whose access token or webhook was used to call the method lacks permissions |
|
|
|
The manifest is not available |
|
|
|
The request requires higher privileges than those provided by the webhook token |
|
|
|
The provided access token has expired |
|
|
|
The user does not have access to the application. This means that the application is installed, but the account administrator has allowed access to this application only for specific users |
|
|
|
The public part of the site is closed. To open the public part of the site on an on-premise installation, disable the option "Temporary closure of the public part of the site". Path to the setting: Desktop > Settings > Product Settings > Module Settings > Main Module > Temporary closure of the public part of the site |
Continue Learning
- Resource Booking: Overview of Methods
- Add a new resource calendar.resource.add
- Update resource calendar.resource.update
- Get a list of all resources calendar.resource.list
- Delete Resource calendar.resource.delete