## Get a schedule

`GET /v1/work-schedules/:id`

Returns one work schedule from the library of the Bitrix24 account: windows by weekday, time zone, version and the number of assigned servers.

## Parameters

| Parameter | In | Type | Required | Description |
|----------|---|-----|:-----:|----------|
| `id` | path | string | yes | Schedule ID. Source — `data[].id` from the [schedule list](./list.md) or `workSchedule.id` in [`GET /v1/infra/servers/:id`](/docs/infra/servers/get) |

## Examples

### curl — personal key

```bash
curl -H "X-Api-Key: YOUR_API_KEY" \
  https://vibecode.bitrix24.com/v1/work-schedules/WORK_SCHEDULE_ID
```

### curl — OAuth application

```bash
curl -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  https://vibecode.bitrix24.com/v1/work-schedules/WORK_SCHEDULE_ID
```

### JavaScript — personal key

```javascript
const res = await fetch(
  `https://vibecode.bitrix24.com/v1/work-schedules/${workScheduleId}`,
  { headers: { 'X-Api-Key': 'YOUR_API_KEY' } }
)
const { data } = await res.json()
console.log(`${data.name}: ${data.windows.length} windows, ${data.assignedCount} servers`)
```

### JavaScript — OAuth application

```javascript
const res = await fetch(
  `https://vibecode.bitrix24.com/v1/work-schedules/${workScheduleId}`,
  {
    headers: {
      'X-Api-Key': 'YOUR_APP_KEY',
      'Authorization': 'Bearer USER_SESSION_TOKEN',
    },
  }
)
const { data } = await res.json()
```

## Response fields

| Field | Type | Description |
|------|-----|----------|
| `success` | boolean | Always `true` on success |
| `data.id` | string | Schedule ID |
| `data.kind` | string | `PRESET` — a platform preset, `CUSTOM` — a custom schedule |
| `data.name` | string | Name. A preset's name comes in the key owner's language |
| `data.presetKey` | string \| null | Preset key: `weekdays-9-18`, `weekdays-8-20`, `daily-9-21`. `null` for a custom schedule |
| `data.timezone` | string | IANA time zone the windows are read in |
| `data.windows` | array | Windows `{ isoDay, start, end }`: `isoDay` from 1 (Monday) to 7, `start` and `end` in local `HH:MM`, the end of the day is `24:00` |
| `data.version` | number | Version number. Passed to [update](./update.md) |
| `data.canEdit` | boolean | Whether the key owner may edit and delete the schedule. Always `false` for a preset |
| `data.assignedCount` | number | How many servers of the Bitrix24 account run on the schedule, other employees' servers included. The servers themselves are not named |

## Response example

```json
{
  "success": true,
  "data": {
    "id": "cmfp4r0q2000a1ocg7h2k9x3d",
    "kind": "CUSTOM",
    "name": "Warehouse shifts",
    "presetKey": null,
    "timezone": "Europe/Berlin",
    "windows": [
      { "isoDay": 1, "start": "09:00", "end": "18:00" },
      { "isoDay": 2, "start": "09:00", "end": "13:00" },
      { "isoDay": 2, "start": "14:00", "end": "24:00" }
    ],
    "version": 2,
    "canEdit": true,
    "assignedCount": 1
  }
}
```

## Error response example

404 — no such schedule in the key's Bitrix24 account:

```json
{
  "success": false,
  "error": {
    "code": "NOT_FOUND",
    "message": "Work schedule not found"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |
| 401 | `INVALID_API_KEY` | The key is not recognized: no such key exists on the platform |
| 403 | `INFRA_SCOPE_REQUIRED` | The key lacks the `vibe:infra` scope |
| 403 | `INFRA_FORBIDDEN_FOR_COWORK_KEY` | The call was made with a Cowork/Code key. The schedule library manages servers and what they cost, so it is closed to such a key entirely, reads included. What to do — [Project deploy key](/docs/cowork/deploy-key) |
| 404 | `NOT_FOUND` | No schedule with this `id` exists in the key's Bitrix24 account, or the key is not bound to a Bitrix24 account. A schedule of another account gets the same answer — the response does not confirm that it exists |
| 429 | `RATE_LIMITED` | The limit of 60 requests per minute per key is exceeded. The exact value is in the `x-ratelimit-limit` header (the ceiling is split between replicas) |

Full list of shared error codes — [Errors](/docs/errors).

## See also

- [List schedules](./list.md)
- [Update a schedule](./update.md)
- [Delete a schedule](./delete.md)
