# Update: Booking resources

`PATCH /v1/booking-resources/:id`

Changes the fields of a booking resource that are passed in the request. Fields missing from the request body keep their previous values.

Fields go at the root of the JSON, without a `fields` wrapper. A resource with work hours set is not changed — see "Known specifics".

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|----------|
| `id` (path) | number | yes | Resource identifier. List: [`GET /v1/booking-resources`](/docs/entities/booking-resources/list) |

## Request fields (body)

All fields are optional, but the body cannot be empty.

| Field | Type | Required | Description |
|------|-----|:-----:|----------|
| `name` | string | no | Resource name |
| `description` | string \| null | no | Resource description |
| `typeId` | number | no | Resource type identifier. List: [`GET /v1/booking-resource-types`](/docs/entities/booking-resource-types/list) |
| `isMain` | boolean \| string | no | Main resource. `true` / `false` or `"Y"` / `"N"` |
| `isInfoNotificationOn` | boolean \| string | no | Booking info message to the client. `true` / `false` or `"Y"` / `"N"` |
| `isConfirmationNotificationOn` | boolean \| string | no | Booking confirmation request |
| `isReminderNotificationOn` | boolean \| string | no | Booking reminder |
| `isFeedbackNotificationOn` | boolean \| string | no | Feedback request |
| `isDelayedNotificationOn` | boolean \| string | no | Message to a client who is running late |
| `isCancellationNotificationOn` | boolean \| string | no | Booking cancellation message to the client |
| `senderCode` | string \| null | no | Service that sends messages to the client, for example `bitrix24` |
| `infoNotificationDelay` | number \| null | no | How many seconds after the booking is made to send the booking info message |
| `confirmationNotificationDelay` | number \| null | no | How many seconds before the booking to send the first confirmation request |
| `confirmationNotificationRepetitions` | number \| null | no | How many times to repeat the confirmation request, not counting the first one |
| `confirmationNotificationRepetitionsInterval` | number \| null | no | Interval between repeats of the confirmation request, in seconds |
| `confirmationCounterDelay` | number \| null | no | How many seconds before the booking an unconfirmed booking enters the counter |
| `reminderNotificationDelay` | number \| null | no | How many seconds before the booking to send the reminder. `-1` — on the morning of the booking day |
| `delayedNotificationDelay` | number \| null | no | After how many seconds of lateness to send the message to the client |
| `delayedCounterDelay` | number \| null | no | After how many seconds of lateness the booking enters the calendar counter |
| `cancellationNotificationDelay` | number \| null | no | Delay of the booking cancellation message, in seconds |
| `templateTypeInfo` | string | no | Booking info message template: `inanimate`, `animate`, `inanimate_long` |
| `templateTypeConfirmation` | string | no | Confirmation request template: `inanimate`, `animate`, `inanimate_long` |
| `templateTypeReminder` | string | no | Reminder template. The only value is `base` |
| `templateTypeFeedback` | string | no | Feedback request template: `inanimate`, `animate` |
| `templateTypeDelayed` | string | no | Late-arrival message template: `inanimate`, `animate` |

## Examples

### curl — personal key

```bash
curl -X PATCH "https://vibecode.bitrix24.com/v1/booking-resources/51" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"description": "Appointments by prior booking"}'
```

### curl — OAuth application

```bash
curl -X PATCH "https://vibecode.bitrix24.com/v1/booking-resources/51" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"description": "Appointments by prior booking"}'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/booking-resources/51', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ description: 'Appointments by prior booking' }),
})

const { data } = await res.json()
console.log(data.description)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/booking-resources/51', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ description: 'Appointments by prior booking' }),
})

const { data } = await res.json()
console.log(data.description)
```

## Response fields

| Field | Type | Description |
|------|-----|----------|
| `success` | boolean | `true` on success |
| `data` | object | Card of the resource after the change. The card fields are listed in the "Response fields" section of the [Get a booking resource](/docs/entities/booking-resources/get) page |

## Response example

```json
{
  "success": true,
  "data": {
    "id": 51,
    "description": "Appointments by prior booking",
    "typeId": 1,
    "isMain": true,
    "name": "Room 3",
    "senderCode": "bitrix24",
    "isInfoNotificationOn": false,
    "isConfirmationNotificationOn": false,
    "isReminderNotificationOn": false,
    "isFeedbackNotificationOn": false,
    "isDelayedNotificationOn": false,
    "isCancellationNotificationOn": false,
    "infoNotificationDelay": null,
    "confirmationNotificationDelay": 86400,
    "confirmationNotificationRepetitions": null,
    "confirmationNotificationRepetitionsInterval": 10800,
    "confirmationCounterDelay": 10800,
    "reminderNotificationDelay": -1,
    "delayedNotificationDelay": 300,
    "delayedCounterDelay": 300,
    "cancellationNotificationDelay": 600,
    "templateTypeInfo": "inanimate",
    "templateTypeConfirmation": "inanimate",
    "templateTypeReminder": "base",
    "templateTypeFeedback": "inanimate",
    "templateTypeDelayed": "inanimate"
  }
}
```

## Error response example

422 — the resource has work hours set:

```json
{
  "success": false,
  "error": {
    "code": "BOOKING_RESOURCE_SCHEDULE_CONFLICT",
    "message": "Bitrix24 resource.update removes work-hour slots. Explicitly remove the slots before editing this resource, then set the intended schedule again."
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 404 | `ENTITY_NOT_FOUND` | No resource with this `id`. Message `Booking record not found` |
| 422 | `BOOKING_RESOURCE_SCHEDULE_CONFLICT` | The resource has work hours set. The resource is not changed |
| 422 | `BITRIX_ERROR` | No resource type with this `typeId`, `b24Code` `1013` |
| 422 | `BITRIX_ERROR` | Invalid template value, for example in `templateTypeInfo`. Message `Invalid value of the templateTypeInfo field` |
| 400 | `INVALID_PARAMS` | `id` is not a positive integer. Message `id must be a positive safe integer` |
| 400 | `INVALID_PARAMS` | Empty body. Message `Provide a non-empty object of fields` |
| 400 | `INVALID_PARAMS` | A field not listed in the "Request fields (body)" table. Message `Unknown booking field` |
| 400 | `INVALID_PARAMS` | A field value is an object or an array. Message `Fields must contain scalar values` |
| 400 | `READONLY_FIELD` | `id` is passed in the body. Message `id is read-only` |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is not passed |
| 401 | `TOKEN_MISSING` | The key has no Bitrix24 tokens |
| 403 | `SCOPE_DENIED` | The key does not have the `booking` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is in read-only mode |
| 429 | `RATE_LIMITED` | Request rate limit exceeded. The effective cap is in the `x-ratelimit-limit` header |
| 502 | `BITRIX_RESPONSE_INVALID` | Bitrix24 returned a response of an unexpected shape. If this happened while re-reading the card after the write, the changes are already saved — check the resource with a [get request](/docs/entities/booking-resources/get) before retrying |

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

## Known specifics

**Remove the schedule from a resource with work hours first.** Editing a resource erases its work hours, so when work hours are set, the request is rejected with `422 BOOKING_RESOURCE_SCHEDULE_CONFLICT` and the resource is not changed. The order is: remove the work hours with [`DELETE /v1/booking-resources/:id/slots`](/docs/entities/booking-resources/slots), change the resource, then set the work hours again with `PUT /v1/booking-resources/:id/slots`. Work hours are checked by a separate request before the edit. If work hours are set by a concurrent request in the gap between the check and the edit, the edit erases them, and both requests respond with success. Do not set work hours while editing the resource, and after the edit verify the schedule with `GET /v1/booking-resources/:id/slots`.

## See also

- [Get a booking resource](/docs/entities/booking-resources/get)
- [List booking resources](/docs/entities/booking-resources/list)
- [Create a booking resource](/docs/entities/booking-resources/create)
- [Resource work hours](/docs/entities/booking-resources/slots)
- [Errors](/docs/errors)
