## Add managers

`POST /v1/chats/:dialogId/managers`

Makes members of a group chat its managers. The other managers keep their role; to set the whole list, use [Replace managers](/docs/chats/members/managers-set).

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `dialogId` (path) | string | yes | Group chat identifier `chatXXX`. A personal dialog is refused |

## Request fields (body)

| Field | Type | Required | Description |
|------|-----|:-----:|---------|
| `userIds` | number[] | yes | From 1 to 50 chat member IDs. Each element is a positive integer: a number or a string of decimal digits without leading zeros or spaces, up to 2^53−1. Members: [`GET /v1/chats/:dialogId/users`](/docs/chats/members/list) |

Other body fields and any query parameters are rejected with `400 INVALID_PARAMS`.

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/chats/chat42/managers" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "userIds": [7] }'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/chats/chat42/managers" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "userIds": [7] }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/chat42/managers', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ userIds: [7] }),
})

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

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/chat42/managers', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ userIds: [7] }),
})

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

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data.result` | boolean | `true` — the request was carried out. It does not confirm that each of the given users got the role |

## Response example

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

## Error response example

403 — a personal dialog instead of a group chat:

```json
{
  "success": false,
  "error": {
    "code": "BITRIX_ACCESS_DENIED",
    "message": "ACCESS_DENIED"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_PARAMS` | `userIds` is absent, empty, not an array, longer than 50 or holds something other than a positive integer — the index and type are named in `message`; an extra body field or a query parameter; the body is not a JSON object. Checked before any call to Bitrix24 |
| 403 | `BITRIX_ACCESS_DENIED` | No right to change the managers, or `dialogId` is a personal dialog |
| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only — see [access rights](/docs/access-rights) |
| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |
| 404 | `ENTITY_NOT_FOUND` | Bitrix24 returned "not found"; the portal code is in `error.b24Code` |
| 422 | `BITRIX_ERROR` | Bitrix24 returned an error; the portal code is in `error.b24Code`. A missing chat lands here with the code `CHAT_NOT_FOUND` |
| 502 | `ME_ALIAS_RESOLUTION_FAILED` | The user could not be resolved for the `me` alias |

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

## Known specifics

**The response does not confirm the assignment.** A user outside the chat and an existing manager are skipped without an error, and the response stays the same. The [membership records](/docs/chats/members/relations) show who got the role.

## See also

- [Replace managers](/docs/chats/members/managers-set)
- [Remove managers](/docs/chats/members/managers-remove)
- [Membership records](/docs/chats/members/relations)
- [Chat members](/docs/chats/members)
