## Message to the client

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

### POST /v1/openlines/crm/messages

`POST /v1/openlines/crm/messages`

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

**The message goes to the CLIENT in their messenger on behalf of the employee or bot identified by userId.** Use only the intended dialog. `chatId` and non-empty `message` are required; an omitted chatId is refused before any call. The CRM card must contain this chat. Returns `{ chatId, messageId }`.

## Example

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

Response:

```json
{
  "success": true,
  "data": {
    "chatId": 123,
    "messageId": 456
  }
}
```

## 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`.
