# Create a chat poll

`POST /v1/chats/:dialogId/polls`

Creates a message containing one question and 2–10 answers. A Feed post cannot have a poll added through the API.

**Scope:** `vote`; additionally `im` for a user ID or `me`. Key restrictions: [Polls](/docs/polls).

## Parameters

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `dialogId` (path) | string | yes | — | `chatN`, a positive user ID or `me`. Chat IDs: [chat discovery](/docs/chats/discovery); user IDs: [employees](/docs/entities/users/list) |

## Request body

| Field | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `question` | string | yes | — | Non-empty question; whitespace alone is invalid |
| `answers` | string[] | yes | — | 2 to 10 non-empty strings |
| `anonymous` | boolean | no | false | Hide voter identities from everyone |
| `multipleChoice` | boolean | no | false | Allow multiple choices |
| `allowRevote` | boolean | no | false | Allow revoting |
| `idempotencyKey` | string | no | new UUID | UUID only. Retry with the same key and unchanged body; use a new key for a new poll |

Duplicate protection depends on the Bitrix24 version. A supported version returns the existing poll on key reuse, but does not compare bodies. After `502 POLL_CREATE_OUTCOME_UNKNOWN`, inspect the chat first. The platform never automatically replays the write.

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/chats/chat5/polls" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"question": "When?", "answers": ["Now", "Later"], "anonymous": true, "multipleChoice": true, "allowRevote": true, "idempotencyKey": "3f2b8c1e-6a4d-4f7b-9c2e-1d5a7b9e0c4f"}'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/chats/chat5/polls" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"question": "When?", "answers": ["Now", "Later"], "anonymous": true, "multipleChoice": true, "allowRevote": true, "idempotencyKey": "3f2b8c1e-6a4d-4f7b-9c2e-1d5a7b9e0c4f"}'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/chat5/polls', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"question": "When?", "answers": ["Now", "Later"], "anonymous": true, "multipleChoice": true, "allowRevote": true, "idempotencyKey": "3f2b8c1e-6a4d-4f7b-9c2e-1d5a7b9e0c4f"}),
})
const result = await res.json()
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/chat5/polls', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"question": "When?", "answers": ["Now", "Later"], "anonymous": true, "multipleChoice": true, "allowRevote": true, "idempotencyKey": "3f2b8c1e-6a4d-4f7b-9c2e-1d5a7b9e0c4f"}),
})
const result = await res.json()
```

## Response fields

| Field | Type | Description |
| --- | --- | --- |
| `success` | boolean | `true` on success |
| `data.messageId` | number | ID of the created or previously created message |
| `data.voteId` | number | Bitrix24 poll number; not `pollId` |
| `data.poll` | object \| null | [Poll object](/docs/polls). `null` if the read after publication failed |

## Response example

Illustrative response based on the normalizer and test fixtures; not a live Bitrix24 response.

HTTP `201`: the message was published, but the subsequent read failed. Do not create it again; find the attachment using `messageIds`.

```json
{
  "success": true,
  "data": {
    "messageId": 42,
    "voteId": 8,
    "poll": null
  }
}
```

## Errors

| HTTP | Code | Cause and action |
| --- | --- | --- |
| 400 | `INVALID_PARAMS` | Invalid ID or request parameter |
| 401 | `TOKEN_MISSING` | No Bitrix24 user session |
| 403 | `SCOPE_DENIED` | Required scope is missing |
| 403 | `COWORK_READONLY` | Operation forbidden for a Cowork portal-readonly key |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key permits reads only |
| 403 | `CHAT_ACCESS_DENIED` | Chat access denied |
| 403 | `POLL_ACCESS_DENIED` | Bitrix24 denied access to the personal chat while resolving it; no poll was sent |
| 404 | `CHAT_NOT_FOUND` | The personal chat could not be resolved |
| 409 | `POLL_CREATE_IN_PROGRESS` | Creation with this key is still in progress; inspect the chat first |
| 409 | `IDEMPOTENCY_KEY_CONFLICT` | Key already used by another user or in another chat |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected the request, for example because the method is unavailable in this version |
| 502 | `ME_ALIAS_RESOLUTION_FAILED` | The user behind `me` could not be resolved; no poll was sent |
| 502 | `POLL_CREATE_OUTCOME_UNKNOWN` | Outcome unknown: inspect the chat first |

Other authentication refusals, limits and shared errors: [error codes](/docs/errors).

```json
{
  "success": false,
  "error": {
    "code": "INVALID_PARAMS",
    "message": "Invalid poll parameters."
  }
}
```
