# Work schedule library

Work schedules for servers in the on-a-schedule run mode: the server runs during the schedule windows and sleeps outside them. The library is shared across the Bitrix24 account — one schedule is assigned to many servers, and editing its windows changes the run of every assigned machine at once.

**Preset and custom schedules.** The platform provides the presets: `weekdays-9-18` — weekdays from 9 to 18, `weekdays-8-20` — weekdays from 8 to 20, `daily-9-21` — every day from 9 to 21. They cannot be edited or deleted: for a different week, create a custom schedule. A Bitrix24 account can keep up to 50 custom schedules.

**Week windows.** A window is an object `{ isoDay, start, end }` in the schedule's local time: `isoDay` from 1 (Monday) to 7, `start` and `end` as `HH:MM` on a 30-minute step, the end of the day is `24:00`. A window lasts at least an hour and never crosses midnight. A day holds up to two windows, at least 30 minutes apart.

**Who edits.** A custom schedule is edited and deleted by its author or by an administrator of the Bitrix24 account. The `canEdit` field in the response tells whether the key owner may do it.

**Before run modes are enabled.** Reading the library is always available. Creating, editing and deleting, like [setting a server's run mode](/docs/infra/lifecycle/run-mode), answer `400 RUN_MODE_UNAVAILABLE` until run modes are enabled for the Bitrix24 account. Until then the library is empty: the presets appear in it together with the run modes.

Scope: `vibe:infra`

## Operations

- [List schedules](./work-schedules/list.md) — `GET /v1/work-schedules`
- [Get a schedule](./work-schedules/get.md) — `GET /v1/work-schedules/:id`
- [Create a schedule](./work-schedules/create.md) — `POST /v1/work-schedules`
- [Update a schedule](./work-schedules/update.md) — `PATCH /v1/work-schedules/:id`
- [Delete a schedule](./work-schedules/delete.md) — `DELETE /v1/work-schedules/:id`

## Typical scenario

1. Find a matching schedule in the [list](./work-schedules/list.md) or add a custom one by [creating it](./work-schedules/create.md).
2. Assign it to a server — [`PATCH /v1/infra/servers/:id/run-mode`](/docs/infra/lifecycle/run-mode) with `mode: "SCHEDULE"` and `scheduleId`.
3. Change the windows for all assigned servers at once — [update the schedule](./work-schedules/update.md) with the current `version`.

## See also

- [Infrastructure](/docs/infra)
- [Set the server run mode](/docs/infra/lifecycle/run-mode)
- [Scheduled wake](/docs/infra/wake-schedules)
