
## Update a booking

`PATCH /v1/bookings/:id`

Updates the fields of an existing booking. Pass only the editable fields flat at the root of the JSON.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `id` (path) | number | yes | Booking id |

## Request fields (body)

| Field | Type | Description |
|------|-----|---------|
| `resourceIds` | number[] | Ids of the resources the booking reserves. The array cannot be empty. The resource list cannot be fetched through the Vibecode API — specify the known ids |
| `datePeriod` | object | Booking period. Structure: `from` and `to`, each with `timestamp` (Unix seconds) and `timezone` (IANA-format time zone, e.g. `UTC`) |
| `name` | string | Booking name. May be `null` |
| `description` | string | Booking description. May be `null` |

## Examples

### curl — personal key

```bash
curl -X PATCH "https://vibecode.bitrix24.com/v1/bookings/27" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Meeting room (updated)",
    "description": "Changed description"
  }'
```

### curl — OAuth application

```bash
curl -X PATCH "https://vibecode.bitrix24.com/v1/bookings/27" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Meeting room (updated)",
    "description": "Changed description"
  }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/bookings/27', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'Meeting room (updated)',
    description: 'Changed description',
  }),
})

const { success, data } = await res.json()
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/bookings/27', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'Meeting room (updated)',
    description: 'Changed description',
  }),
})

const { success, data } = await res.json()
```

## Response fields

The full object of the updated booking is returned.

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data.id` | number | Booking id |
| `data.name` | string \| null | Booking name |
| `data.description` | string \| null | Booking description |
| `data.resourceIds` | number[] | Ids of the reserved resources |
| `data.datePeriod` | object | Booking period: `from` and `to`, each with `timestamp` and `timezone` |

## Response example

```json
{
  "success": true,
  "data": {
    "id": 27,
    "name": "Meeting room (updated)",
    "description": "Changed description",
    "resourceIds": [1],
    "datePeriod": {
      "from": { "timestamp": 1780132384, "timezone": "UTC" },
      "to":   { "timestamp": 1780135984, "timezone": "UTC" }
    }
  }
}
```

## Error response example

422 — booking not found:

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

## Errors

| HTTP | Code | Description |
|------|--------------|---------|
| 422 | `BITRIX_ERROR` | The booking with the given `id` does not exist. Message: `Booking not found` |
| 422 | `BITRIX_ERROR` | An empty `resourceIds` array was passed. Message: `Empty resource collection` |
| 403 | `SCOPE_DENIED` | The API key does not have the `booking` scope |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header was not passed |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |

Full list of common API errors — [Errors](/docs/errors).

## See also

- [Bookings](/docs/entities/bookings)
- [Create a booking](/docs/entities/bookings/create)
- [Get a booking](/docs/entities/bookings/get)
- [Delete a booking](/docs/entities/bookings/delete)
- [Batch](/docs/batch)
