# Resource work-hour slots

Requires `booking` scope. Writes require READWRITE. Body fields are flat, without an outer fields object. Setting work hours does not create a booking.

PUT replaces ALL slots; DELETE removes ALL slots. from/to are minutes from midnight, 0 to 1440 and from < to; weekDays Mon to Sun, slotSize > 0, timezone IANA. Invalid IANA time zones and non-positive slotSize return 400 before dispatch: Bitrix24 silently falls back to UTC and accepts zero size. Other domain refusals return 422. Malformed body or id returns 400 before dispatch.

## GET /v1/booking-resources/:id/slots

`GET /v1/booking-resources/:id/slots`

### cURL — personal key

```bash
curl -X GET "https://vibecode.bitrix24.com/v1/booking-resources/10/slots" -H "X-Api-Key: $VIBE_API_KEY"
```

### cURL — OAuth

```bash
curl -X GET "https://vibecode.bitrix24.com/v1/booking-resources/10/slots" -H "X-Api-Key: $VIBE_API_KEY" -H "Authorization: Bearer $SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
const response = await fetch('https://vibecode.bitrix24.com/v1/booking-resources/10/slots', { method: 'GET', headers: { 'X-Api-Key': apiKey } });
if (response.status !== 204) console.log(await response.json());
```

### JavaScript — OAuth

```javascript
const response = await fetch('https://vibecode.bitrix24.com/v1/booking-resources/10/slots', { method: 'GET', headers: { 'X-Api-Key': apiKey, Authorization: `Bearer ${sessionToken}` } });
if (response.status !== 204) console.log(await response.json());
```

## PUT /v1/booking-resources/:id/slots

`PUT /v1/booking-resources/:id/slots`

### cURL — personal key

```bash
curl -X PUT "https://vibecode.bitrix24.com/v1/booking-resources/10/slots" -H "X-Api-Key: $VIBE_API_KEY" -H 'Content-Type: application/json' -d '{"slots":[{"from":600,"to":1140,"weekDays":["Mon","Tue","Wed","Thu","Fri"],"slotSize":30,"timezone":"Europe/London"}]}'
```

### cURL — OAuth

```bash
curl -X PUT "https://vibecode.bitrix24.com/v1/booking-resources/10/slots" -H "X-Api-Key: $VIBE_API_KEY" -H "Authorization: Bearer $SESSION_TOKEN" -H 'Content-Type: application/json' -d '{"slots":[{"from":600,"to":1140,"weekDays":["Mon","Tue","Wed","Thu","Fri"],"slotSize":30,"timezone":"Europe/London"}]}'
```

### JavaScript — personal key

```javascript
const response = await fetch('https://vibecode.bitrix24.com/v1/booking-resources/10/slots', { method: 'PUT', headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' }, body: JSON.stringify({"slots":[{"from":600,"to":1140,"weekDays":["Mon","Tue","Wed","Thu","Fri"],"slotSize":30,"timezone":"Europe/London"}]}) });
if (response.status !== 204) console.log(await response.json());
```

### JavaScript — OAuth

```javascript
const response = await fetch('https://vibecode.bitrix24.com/v1/booking-resources/10/slots', { method: 'PUT', headers: { 'X-Api-Key': apiKey, Authorization: `Bearer ${sessionToken}`, 'Content-Type': 'application/json' }, body: JSON.stringify({"slots":[{"from":600,"to":1140,"weekDays":["Mon","Tue","Wed","Thu","Fri"],"slotSize":30,"timezone":"Europe/London"}]}) });
if (response.status !== 204) console.log(await response.json());
```

## DELETE /v1/booking-resources/:id/slots

`DELETE /v1/booking-resources/:id/slots`

### cURL — personal key

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/booking-resources/10/slots" -H "X-Api-Key: $VIBE_API_KEY"
```

### cURL — OAuth

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/booking-resources/10/slots" -H "X-Api-Key: $VIBE_API_KEY" -H "Authorization: Bearer $SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
const response = await fetch('https://vibecode.bitrix24.com/v1/booking-resources/10/slots', { method: 'DELETE', headers: { 'X-Api-Key': apiKey } });
if (response.status !== 204) console.log(await response.json());
```

### JavaScript — OAuth

```javascript
const response = await fetch('https://vibecode.bitrix24.com/v1/booking-resources/10/slots', { method: 'DELETE', headers: { 'X-Api-Key': apiKey, Authorization: `Bearer ${sessionToken}` } });
if (response.status !== 204) console.log(await response.json());
```

## Response fields

GET: `success: true`, `data.slots[]`: id, from, to, weekDays[], slotSize, timezone. PUT: `data: true`. DELETE: 204, empty body.

```json
{
  "success": true,
  "data": {
    "slots": [
      {
        "id": 2,
        "from": 600,
        "to": 1140,
        "weekDays": [
          "Mon",
          "Tue",
          "Wed",
          "Thu",
          "Fri"
        ],
        "slotSize": 30,
        "timezone": "Europe/London"
      }
    ]
  }
}
```

## Errors

| HTTP | Code | Condition |
|---|---|---|
| 400 | INVALID_PARAMS | Malformed id/body |
| 403 | SCOPE_DENIED | Missing booking scope |
| 403 | WRITE_BLOCKED_READONLY_KEY | Read-only write |
| 404 | ENTITY_NOT_FOUND | Missing resource |
| 422 | BITRIX_ERROR | Invalid range values or another business refusal |
| 502 | BITRIX_RESPONSE_INVALID | Unexpected response |

[Errors](/docs/errors).

404 — missing resource:

```json
{"success":false,"error":{"code":"ENTITY_NOT_FOUND","message":"Booking resource not found"}}
```
