For AI agents: markdown of this page — /docs-content-en/infra/work-schedules/update.md documentation index — /llms.txt
Update a schedule
PATCH /v1/work-schedules/:id
Changes the name, time zone or windows of a custom schedule. The library is shared across the Bitrix24 account, so new windows apply at once to every server assigned to the schedule, and the edit carries a version number so as not to overwrite someone else's edit.
Parameters
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
Parameterid |
Inpath | Typestring | Requiredyes | DescriptionID of a custom schedule. Source — data[].id from the schedule list |
Request fields (body)
| Field | Type | Required | Description |
|---|---|---|---|
Fieldversion |
Typenumber | Requiredyes | DescriptionThe version you read. Source — version in the list or in Get a schedule |
Fieldname |
Typestring | Requiredno | DescriptionNew name, from 1 to 80 characters |
Fieldtimezone |
Typestring | Requiredno | DescriptionNew IANA time zone |
Fieldwindows |
Typearray | Requiredno | DescriptionNew windows { isoDay, start, end } — they replace the previous ones entirely. For the window rules, see the section index |
Examples
curl — personal key
curl -X PATCH https://vibecode.bitrix24.com/v1/work-schedules/WORK_SCHEDULE_ID \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"version": 2,
"windows": [
{ "isoDay": 1, "start": "08:00", "end": "17:00" },
{ "isoDay": 2, "start": "08:00", "end": "17:00" }
]
}'
curl — OAuth application
curl -X PATCH https://vibecode.bitrix24.com/v1/work-schedules/WORK_SCHEDULE_ID \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"version": 2,
"windows": [
{ "isoDay": 1, "start": "08:00", "end": "17:00" },
{ "isoDay": 2, "start": "08:00", "end": "17:00" }
]
}'
JavaScript — personal key
const res = await fetch(
`https://vibecode.bitrix24.com/v1/work-schedules/${workScheduleId}`,
{
method: 'PATCH',
headers: {
'X-Api-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
version: 2,
windows: [
{ isoDay: 1, start: '08:00', end: '17:00' },
{ isoDay: 2, start: '08:00', end: '17:00' },
],
}),
}
)
const body = await res.json()
console.log(`Version ${body.data.version}, servers affected: ${body.affectedServers}`)
JavaScript — OAuth application
const res = await fetch(
`https://vibecode.bitrix24.com/v1/work-schedules/${workScheduleId}`,
{
method: 'PATCH',
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({
version: 2,
windows: [
{ isoDay: 1, start: '08:00', end: '17:00' },
{ isoDay: 2, start: '08:00', end: '17:00' },
],
}),
}
)
const body = await res.json()
Response fields
| Field | Type | Description |
|---|---|---|
Fieldsuccess |
Typeboolean | DescriptionAlways true on success |
Fielddata |
Typeobject | DescriptionThe schedule after the edit — the same shape as in Get a schedule |
Fielddata.version |
Typenumber | DescriptionThe new version: every successful edit raises it by one |
FieldaffectedServers |
Typenumber | DescriptionHow many servers of the Bitrix24 account run on the schedule after the edit, other employees' servers included |
Response example
{
"success": true,
"data": {
"id": "cmfp4r0q2000a1ocg7h2k9x3d",
"kind": "CUSTOM",
"name": "Warehouse shifts",
"presetKey": null,
"timezone": "Europe/Berlin",
"windows": [
{ "isoDay": 1, "start": "08:00", "end": "17:00" },
{ "isoDay": 2, "start": "08:00", "end": "17:00" }
],
"version": 3,
"canEdit": true,
"assignedCount": 1,
"defaultForNewMachines": true,
"defaultForNewAgents": false
},
"affectedServers": 1
}
Error response example
409 — the schedule was changed after you read it:
{
"success": false,
"error": {
"code": "WORK_SCHEDULE_STALE",
"message": "The work schedule was changed by someone else — reload it and repeat the edit"
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| HTTP400 | CodeVALIDATION_ERROR |
DescriptionThe body does not match the schema — a missing version, an unknown field, an unknown time zone — or the windows violate the rules for weekly schedules. For a schema violation, message carries the field path and the reason. For a week-rule violation, message carries the day and the window bounds in minutes from midnight |
| HTTP400 | CodeWORK_SCHEDULE_EMPTY |
DescriptionAn empty windows was passed: servers on such a schedule would never run |
| HTTP400 | CodeRUN_MODE_UNAVAILABLE |
DescriptionRun modes are not enabled for the Bitrix24 account yet |
| HTTP401 | CodeMISSING_API_KEY |
DescriptionThe X-Api-Key header is missing |
| HTTP401 | CodeINVALID_API_KEY |
DescriptionThe key is not recognized: no such key exists on the platform |
| HTTP403 | CodeWORK_SCHEDULE_PRESET_READONLY |
DescriptionThe schedule is a preset — it cannot be edited. For a different week, create a custom one |
| HTTP403 | CodeWORK_SCHEDULE_EDIT_FORBIDDEN |
DescriptionOnly the author or an administrator of the Bitrix24 account may edit the schedule |
| HTTP403 | CodeWRITE_BLOCKED_READONLY_KEY |
DescriptionThe key is in read-only mode — it cannot edit schedules |
| HTTP403 | CodeINFRA_SCOPE_REQUIRED |
DescriptionThe key lacks the vibe:infra scope |
| HTTP403 | CodeINFRA_FORBIDDEN_FOR_COWORK_KEY |
DescriptionThe call was made with a Cowork key, which cannot access the schedule library. For guidance, see Project deploy key |
| HTTP404 | CodeNOT_FOUND |
DescriptionNo schedule with this id exists in the key's Bitrix24 account, or the key is not bound to a Bitrix24 account |
| HTTP409 | CodeWORK_SCHEDULE_STALE |
DescriptionThe version in the request is out of date: the schedule was changed after you read it. Read it again and repeat the edit with the new version |
| HTTP429 | CodeRATE_LIMITED |
DescriptionThe limit of 30 requests per minute per key is exceeded. The effective value is in the x-ratelimit-limit header |
For the full list of common API errors, see Errors.
Known specifics
- Editing windows or the time zone rebuilds the wake-ups of every assigned server. The new windows, the recomputed wake-ups of each server on the schedule and the new version are written as one operation: if the operation fails, nothing changes. A name-only edit does not touch the wake-ups.
- Server costs change with the windows. A server on the schedule runs during its windows, so a longer week raises the cost of every assigned server, other employees' servers included — the number of assigned servers is returned in
affectedServers.