## CRM chat members

Scope: `imopenlines`. Writes require a write-enabled key. Bitrix24 checks user permissions.

### POST /v1/openlines/crm/chats/users

`POST /v1/openlines/crm/chats/users`

### DELETE /v1/openlines/crm/chats/users

`DELETE /v1/openlines/crm/chats/users`

```json
{
  "crmEntityType": "deal",
  "crmEntityId": 42,
  "userId": 7,
  "chatId": 123
}
```

Use the same `crmEntityType` and `crmEntityId` as `GET /v1/openlines/crm/chats`: lead, deal, company or contact; type is case-insensitive. `userId` is a positive integer. Optional `chatId`: without it Bitrix24 selects the last chat of the CRM card. A missing chat returns 404 before the write. Returns `{ chatId, userId, added: true }` or `{ chatId, userId, deleted: true }`.

## Example

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/openlines/crm/chats/users" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"crmEntityType": "deal", "crmEntityId": 42, "userId": 7, "chatId": 123}'
```

Response:

```json
{
  "success": true,
  "data": {
    "chatId": 123,
    "userId": 7,
    "added": true
  }
}
```

## Errors

`400 INVALID_PARAMS / INVALID_CHAT_ID / MISSING_REQUIRED_FIELDS`, `401 TOKEN_MISSING`, `403 SCOPE_DENIED / WRITE_BLOCKED_READONLY_KEY / BITRIX_ACCESS_DENIED`, `404 ENTITY_NOT_FOUND`, `422 BITRIX_ERROR`, `429`, `502 OPENLINE_OPERATOR_FAILED / BITRIX_UNAVAILABLE`, `503`.
