
## Transcribe an audio file

`POST /v1/chats/files/:fileId/transcribe`

Starts speech-to-text transcription of an audio or video file attached to a message — for example, a voice message or a video note. The transcription is done by CoPilot, the artificial intelligence (AI) of your Bitrix24 account. The call queues a job, and the text appears once the job finishes.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `fileId` (path) | number | yes | Chat file ID. Get it: `files[].id` in [Load a chat](/docs/chats/messages/load) or in the [message history in the v2 mode](/docs/chats/messages/list) |

## Request fields (body)

| Field | Type | Required | Description |
|------|-----|:-----:|---------|
| `messageId` | number | yes | ID of the message the file is attached to. Get it: `messages[].id` in [Load a chat](/docs/chats/messages/load) or in the [message history in the v2 mode](/docs/chats/messages/list) |
| `requestId` | string | no | Attempt identifier in UUID format, generated by the app. Sent only together with `contentVersion` and only when [transcription settings](/docs/chats/files/transcribe-transcription-config) were retrieved successfully |
| `contentVersion` | string | no | Expected file version from the file metadata: 1–128 visible ASCII characters, without spaces. Sent only together with `requestId` |

## Examples

### curl — personal key

```bash
curl -X POST https://vibecode.bitrix24.com/v1/chats/files/7701/transcribe \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"messageId": 1003}'
```

### curl — OAuth application

```bash
curl -X POST https://vibecode.bitrix24.com/v1/chats/files/7701/transcribe \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"messageId": 1003}'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/files/7701/transcribe', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ messageId: 1003 }),
})

const { success, data } = await res.json()
console.log('State:', data.status, data.transcriptText)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/files/7701/transcribe', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ messageId: 1003 }),
})

const { success, data } = await res.json()
console.log('State:', data.status, data.transcriptText)
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data.fileId` | number | File ID |
| `data.status` | string | Transcription state: `Pending` — the job is running, `Success` — the text is ready, `Error` — the transcription failed |
| `data.transcriptText` | string\|null | The transcript text. `null` while there is no text |
| `data.chatId` | number | ID of the message's chat |
| `data.messageId` | number | Message ID |
| `data.contentVersion` | string | File version from the request |
| `data.revision` | string | Job revision as a decimal string |
| `data.operationId` | string | Transcription job ID |
| `data.errorCode` | string\|null | Transcription error code |
| `data.retryable` | boolean | Whether the attempt can be retried |
| `data.pendingForMs` | number\|null | How many more milliseconds the job stays in the `Pending` state, from `0` to `300000`. `null` for a final result |

The fields from `data.chatId` to `data.pendingForMs` are returned only in response to a call with `requestId` and `contentVersion`.

## Response example

```json
{
  "success": true,
  "data": {
    "fileId": 7701,
    "status": "Pending",
    "transcriptText": null
  }
}
```

## Error response example

422 — the file is neither audio nor video:

```json
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "FILE_NOT_TRANSCRIBABLE",
    "b24Code": "FILE_NOT_TRANSCRIBABLE"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_PARAMS` | `fileId` is not a positive integer, `messageId` is missing or is not a positive integer, the body is not a JSON object, or an extra body field or a query parameter was sent. Checked before any call to Bitrix24 |
| 400 | `INVALID_PARAMS` | `requestId` is not a UUID, `contentVersion` is not 1–128 visible ASCII characters, or one of these fields was sent without the other. Checked before any call to Bitrix24 |
| 404 | `ENTITY_NOT_FOUND` | Bitrix24 returned a "not found" error. The Bitrix24 code is in `error.b24Code` |
| 422 | `BITRIX_ERROR` | `error.b24Code` = `100` — there is no file with this `fileId` |
| 422 | `BITRIX_ERROR` | `error.b24Code` = `FILE_NOT_TRANSCRIBABLE` — the file is neither audio nor video |
| 422 | `BITRIX_ERROR` | `error.b24Code` = `FILE_SIZE_EXCEEDED` — the file is larger than 25 MB |
| 422 | `BITRIX_ERROR` | `error.b24Code` = `TRANSCRIPTION_NOT_ACTIVE` — transcription is turned off in the Bitrix24 account |
| 422 | `BITRIX_ERROR` | `error.b24Code` = `LIMIT_IS_EXCEEDED_BAAS` — the AI request limit is used up |
| 422 | `BITRIX_ERROR` | `error.b24Code` = `TRANSCRIPTION_SERVICE_ERROR` — the transcription service failed |
| 422 | `BITRIX_ERROR` | `error.b24Code` = `FILE_ACCESS_ERROR` — no access to the file |
| 422 | `BITRIX_ERROR` | Another Bitrix24 refusal. The Bitrix24 code is in `error.b24Code` |
| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only. Checked before any call to Bitrix24 |
| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |

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

## Known specifics

**Counts against the AI request limit of your Bitrix24 account.** A repeated call for the same file does not queue a new job: while the transcription runs, it returns `Pending`, afterwards `Success` with the text.

**The call may add the user as a member.** If the message's chat can be joined without an invitation — for example, a comment chat, a collab or a task chat — the call adds the current user as a member, just as opening the chat in the Bitrix24 interface does.

**An attempt with the same `requestId`.** A repeat with the same `requestId` within 24 hours does not queue a new job. A new manual attempt sends a new UUID: it joins the running job and, once the repeat window expires, may consume the AI request limit again.

**No automatic retries.** The call reaches Bitrix24 exactly once and does not retry the request on its own.

## See also

- [Get transcription settings](/docs/chats/files/transcribe-transcription-config)
- [Chat files](/docs/chats/files)
- [Load a chat](/docs/chats/messages/load)
- [Save files to Drive](/docs/chats/files/save)
