[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-entities\u002Fbooking-resources\u002Fslots-set":3,"docs-tabs-entities\u002Fbooking-resources\u002Fslots-set":6},{"content":4,"lastmod":5},"## Set resource work hours\n\n`PUT \u002Fv1\u002Fbooking-resources\u002F:id\u002Fslots`\n\nSets 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.\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|----------|\n| `id` (path) | number | yes | Booking resource ID. List: [`GET \u002Fv1\u002Fbooking-resources`](\u002Fdocs\u002Fentities\u002Fbooking-resources\u002Flist) |\n\n## Request fields (body)\n\n| Field | Type | Required | Description |\n|------|-----|:-----:|----------|\n| `slots` | array | yes | New set of work hour intervals. An empty array removes all work hours |\n| `slots[].from` | number | yes | Start of the interval in minutes from midnight, at least `0`: `600` is 10:00 |\n| `slots[].to` | number | yes | End of the interval in minutes from midnight, greater than `from` and no greater than `1440`: `1140` is 19:00 |\n| `slots[].weekDays` | array | yes | Days of the week the interval applies to: `Mon`, `Tue`, `Wed`, `Thu`, `Fri`, `Sat`, `Sun`. At least one day is required |\n| `slots[].slotSize` | number | yes | Length of one booking slot in minutes, at least `1`. The fractional part is discarded: `45.7` is stored as `45` |\n| `slots[].timezone` | string | yes | Time zone in which `from` and `to` are set — a name from the IANA time zone database, for example `Europe\u002FLondon`. An offset such as `+03:00` is not accepted |\n\nThe 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](\u002Fdocs\u002Fentities\u002Fbooking-resources\u002Fslots-list), is ignored: after the write, the intervals get new `id` values.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X PUT \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fbooking-resources\u002F65\u002Fslots\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"slots\": [\n      { \"from\": 600, \"to\": 1140, \"weekDays\": [\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\"], \"slotSize\": 30, \"timezone\": \"Europe\u002FLondon\" },\n      { \"from\": 600, \"to\": 840, \"weekDays\": [\"Sat\"], \"slotSize\": 60, \"timezone\": \"Europe\u002FLondon\" }\n    ]\n  }'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X PUT \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fbooking-resources\u002F65\u002Fslots\" \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"slots\": [\n      { \"from\": 600, \"to\": 1140, \"weekDays\": [\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\"], \"slotSize\": 30, \"timezone\": \"Europe\u002FLondon\" },\n      { \"from\": 600, \"to\": 840, \"weekDays\": [\"Sat\"], \"slotSize\": 60, \"timezone\": \"Europe\u002FLondon\" }\n    ]\n  }'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fbooking-resources\u002F65\u002Fslots', {\n  method: 'PUT',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({\n    slots: [\n      { from: 600, to: 1140, weekDays: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'], slotSize: 30, timezone: 'Europe\u002FLondon' },\n      { from: 600, to: 840, weekDays: ['Sat'], slotSize: 60, timezone: 'Europe\u002FLondon' },\n    ],\n  }),\n})\n\nconst { success, data } = await res.json()\nconsole.log('Work hours set:', data)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fbooking-resources\u002F65\u002Fslots', {\n  method: 'PUT',\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({\n    slots: [\n      { from: 600, to: 1140, weekDays: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'], slotSize: 30, timezone: 'Europe\u002FLondon' },\n      { from: 600, to: 840, weekDays: ['Sat'], slotSize: 60, timezone: 'Europe\u002FLondon' },\n    ],\n  }),\n})\n\nconst { success, data } = await res.json()\n```\n\n## Response fields\n\nThe written intervals are not included in the response — [`GET \u002Fv1\u002Fbooking-resources\u002F:id\u002Fslots`](\u002Fdocs\u002Fentities\u002Fbooking-resources\u002Fslots-list) returns them.\n\n| Field | Type | Description |\n|------|-----|----------|\n| `success` | boolean | `true` on success |\n| `data` | boolean | `true` — the work hours are written |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": true\n}\n```\n\n## Error response example\n\n422 — the time range or the days of the week are set incorrectly:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"BITRIX_ERROR\",\n    \"message\": \"Invalid range fields\",\n    \"b24Code\": \"422\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|----------|\n| 422 | `BITRIX_ERROR` | `Invalid 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 |\n| 422 | `BITRIX_ERROR` | `Required fields: from` — the element has no `from`. For `to` and `weekDays`, the message names that field |\n| 400 | `INVALID_PARAMS` | `Provide 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` |\n| 400 | `INVALID_PARAMS` | `slotSize must be positive` — the element has no `slotSize` or it is less than `1` |\n| 400 | `INVALID_PARAMS` | `slotSize must be a positive decimal number` — `slotSize` is passed as a string that is not a number |\n| 400 | `INVALID_PARAMS` | `timezone 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 |\n| 400 | `INVALID_PARAMS` | `id must be a positive safe integer` — the resource `id` is not a positive integer |\n| 404 | `ENTITY_NOT_FOUND` | `Booking resource not found` — no resource with this `id` exists |\n| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is not passed |\n| 401 | `TOKEN_MISSING` | The key has no Bitrix24 tokens |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is in read-only mode. The request is rejected before it reaches Bitrix24 |\n| 403 | `SCOPE_DENIED` | The key does not have the `booking` scope |\n| 429 | `RATE_LIMITED` | Request rate exceeded. The effective cap is in the `x-ratelimit-limit` header |\n| 502 | `BITRIX_RESPONSE_INVALID` | `Bitrix24 returned an invalid booking response` — Bitrix24 did not confirm the write |\n\nFull list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n**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 \u002Fv1\u002Fbooking-resources\u002F:id`](\u002Fdocs\u002Fentities\u002Fbooking-resources\u002Fupdate) 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 \u002Fv1\u002Fbooking-resources\u002F:id\u002Fslots`](\u002Fdocs\u002Fentities\u002Fbooking-resources\u002Fslots-list).\n\n## See also\n\n- [Resource work hours](\u002Fdocs\u002Fentities\u002Fbooking-resources\u002Fslots)\n- [Get resource work hours](\u002Fdocs\u002Fentities\u002Fbooking-resources\u002Fslots-list)\n- [Remove resource work hours](\u002Fdocs\u002Fentities\u002Fbooking-resources\u002Fslots-delete)\n- [Update a booking resource](\u002Fdocs\u002Fentities\u002Fbooking-resources\u002Fupdate)\n- [List booking resources](\u002Fdocs\u002Fentities\u002Fbooking-resources\u002Flist)\n","2026-10-15",{},1795343768974]