
## Update a chat

`PATCH /v1/bots/:botId/chats/:dialogId`

Updates chat settings. The bot must be a participant of the chat. Only the passed fields are updated.

> **Two body forms — both valid.** The platform accepts a flat record (`{ title, description, ... }`) and the Bitrix24 format wrapped in `fields`. If the body contains `fields`, the request is forwarded to Bitrix24 unchanged. Otherwise the known top-level fields are automatically expanded into `fields.*`.

## Request fields (body)

| Parameter (flat) | Parameter (Bitrix24 format) | Type | Description |
|---|---|-----|---------|
| `title` | `fields.title` | string | New chat name |
| `description` | `fields.description` | string | New description |
| `color` | `fields.color` | string | New color |
| `avatar` | `fields.avatar` | string | New avatar URL |

## Examples

### curl — personal key

```bash
curl -X PATCH https://vibecode.bitrix24.com/v1/bots/42/chats/chat456 \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "fields": {
      "title": "New chat name",
      "description": "Updated description"
    }
  }'
```

### curl — OAuth application

```bash
curl -X PATCH https://vibecode.bitrix24.com/v1/bots/42/chats/chat456 \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "fields": {
      "title": "New chat name",
      "description": "Updated description"
    }
  }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/bots/42/chats/chat456', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    fields: {
      title: 'New chat name',
      description: 'Updated description',
    },
  }),
})

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

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/bots/42/chats/chat456', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    fields: {
      title: 'New chat name',
      description: 'Updated description',
    },
  }),
})

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

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `data.result` | boolean | `true` on a successful update |

## Response example

```json
{
  "success": true,
  "data": {
    "result": true
  }
}
```

## Error response example

403 — the bot belongs to a different key:

```json
{
  "success": false,
  "error": {
    "code": "BOT_ACCESS_DENIED",
    "message": "This bot belongs to a different API key"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_BOT_ID` | `botId` is not a number |
| 404 | `BOT_NOT_FOUND` | No bot found with this ID |
| 403 | `BOT_ACCESS_DENIED` | The bot belongs to another API key |
| 502 | `BITRIX_ERROR` | Bitrix24 error (error text in `message`) |
| 403 | `SCOPE_DENIED` | The API key does not have the `imbot` scope |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |

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

## See also

- [Get a chat](/docs/bots/chats/get)
- [Create a chat](/docs/bots/chats/create)
- [Bot platform](/docs/bots)
- [Limits and optimization](/docs/optimization)
