For AI agents: markdown of this page — /docs-content-en/entities/booking-resources/slots-set.md documentation index — /llms.txt
Set resource work hours
PUT /v1/booking-resources/:id/slots
Sets the work hours of a booking resource to the passed set of intervals: the previous intervals are deleted. An empty slots array removes all work hours.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
Parameterid (path) |
Typenumber | Requiredyes | DescriptionBooking resource ID. List: GET /v1/booking-resources |
Request fields (body)
| Field | Type | Required | Description |
|---|---|---|---|
Fieldslots |
Typearray | Requiredyes | DescriptionNew set of work hour intervals. An empty array removes all work hours |
Fieldslots[].from |
Typenumber | Requiredyes | DescriptionStart of the interval in minutes from midnight, at least 0: 600 is 10:00 |
Fieldslots[].to |
Typenumber | Requiredyes | DescriptionEnd of the interval in minutes from midnight, greater than from and no greater than 1440: 1140 is 19:00 |
Fieldslots[].weekDays |
Typearray | Requiredyes | DescriptionDays of the week the interval applies to: Mon, Tue, Wed, Thu, Fri, Sat, Sun. At least one day is required |
Fieldslots[].slotSize |
Typenumber | Requiredyes | DescriptionLength of one booking slot in minutes, at least 1. The fractional part is discarded: 45.7 is stored as 45 |
Fieldslots[].timezone |
Typestring | Requiredyes | DescriptionTime zone in which from and to are set — a name from the IANA time zone database, for example Europe/London. An offset such as +03:00 is not accepted |
The body accepts no other fields: any field alongside slots returns 400 INVALID_PARAMS. An id field in an element, as returned when reading the work hours, is ignored: after the write, the intervals get new id values.
Examples
curl — personal key
curl -X PUT "https://vibecode.bitrix24.com/v1/booking-resources/65/slots" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"slots": [
{ "from": 600, "to": 1140, "weekDays": ["Mon", "Tue", "Wed", "Thu", "Fri"], "slotSize": 30, "timezone": "Europe/London" },
{ "from": 600, "to": 840, "weekDays": ["Sat"], "slotSize": 60, "timezone": "Europe/London" }
]
}'
curl — OAuth application
curl -X PUT "https://vibecode.bitrix24.com/v1/booking-resources/65/slots" \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"slots": [
{ "from": 600, "to": 1140, "weekDays": ["Mon", "Tue", "Wed", "Thu", "Fri"], "slotSize": 30, "timezone": "Europe/London" },
{ "from": 600, "to": 840, "weekDays": ["Sat"], "slotSize": 60, "timezone": "Europe/London" }
]
}'
JavaScript — personal key
const res = await fetch('https://vibecode.bitrix24.com/v1/booking-resources/65/slots', {
method: 'PUT',
headers: {
'X-Api-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
slots: [
{ from: 600, to: 1140, weekDays: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'], slotSize: 30, timezone: 'Europe/London' },
{ from: 600, to: 840, weekDays: ['Sat'], slotSize: 60, timezone: 'Europe/London' },
],
}),
})
const { success, data } = await res.json()
console.log('Work hours set:', data)
JavaScript — OAuth application
const res = await fetch('https://vibecode.bitrix24.com/v1/booking-resources/65/slots', {
method: 'PUT',
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({
slots: [
{ from: 600, to: 1140, weekDays: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'], slotSize: 30, timezone: 'Europe/London' },
{ from: 600, to: 840, weekDays: ['Sat'], slotSize: 60, timezone: 'Europe/London' },
],
}),
})
const { success, data } = await res.json()
Response fields
The written intervals are not included in the response — GET /v1/booking-resources/:id/slots returns them.
| Field | Type | Description |
|---|---|---|
Fieldsuccess |
Typeboolean | Descriptiontrue on success |
Fielddata |
Typeboolean | Descriptiontrue — the work hours are written |
Response example
{
"success": true,
"data": true
}
Error response example
422 — the time range or the days of the week are set incorrectly:
{
"success": false,
"error": {
"code": "BITRIX_ERROR",
"message": "Invalid range fields",
"b24Code": "422"
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| HTTP422 | CodeBITRIX_ERROR |
DescriptionInvalid range fields — to is not greater than from, a time is outside the range from 0 to 1440, the weekDays array is empty or contains an unknown day. The work hours do not change |
| HTTP422 | CodeBITRIX_ERROR |
DescriptionRequired fields: from — the element has no from. For to and weekDays, the message names that field |
| HTTP400 | CodeINVALID_PARAMS |
DescriptionProvide slots as an array of objects — the body has no slots, slots is not an array, an array element is not an object, or another field is passed alongside slots |
| HTTP400 | CodeINVALID_PARAMS |
DescriptionslotSize must be positive — the element has no slotSize or it is less than 1 |
| HTTP400 | CodeINVALID_PARAMS |
DescriptionslotSize must be a positive decimal number — slotSize is passed as a string that is not a number |
| HTTP400 | CodeINVALID_PARAMS |
Descriptiontimezone must be an IANA time zone — the element has no timezone, it holds an offset such as +03:00, or the IANA time zone database has no such name |
| HTTP400 | CodeINVALID_PARAMS |
Descriptionid must be a positive safe integer — the resource id is not a positive integer |
| HTTP404 | CodeENTITY_NOT_FOUND |
DescriptionBooking resource not found — no resource with this id exists |
| HTTP401 | CodeMISSING_API_KEY |
DescriptionThe X-Api-Key header is not passed |
| HTTP401 | CodeTOKEN_MISSING |
DescriptionThe key has no Bitrix24 tokens |
| HTTP403 | CodeWRITE_BLOCKED_READONLY_KEY |
DescriptionThe key is in read-only mode. The request is rejected before it reaches Bitrix24 |
| HTTP403 | CodeSCOPE_DENIED |
DescriptionThe key does not have the booking scope |
| HTTP429 | CodeRATE_LIMITED |
DescriptionRequest rate exceeded. The effective cap is in the x-ratelimit-limit header |
| HTTP502 | CodeBITRIX_RESPONSE_INVALID |
DescriptionBitrix24 returned an invalid booking response — Bitrix24 did not confirm the write |
Full list of common API errors — Errors.
Known specifics
Do not set work hours in parallel with a resource edit. Editing a resource erases its work hours, so when work hours are set, PATCH /v1/booking-resources/:id responds with 422 BOOKING_RESOURCE_SCHEDULE_CONFLICT. If work hours are written in the gap between this check and the edit itself, the edit erases them, and both requests respond with success. After editing a resource, verify the work hours via GET /v1/booking-resources/:id/slots.