Add File to Chat im.disk.file.commit
Choose a tool for developing with an AI agent:
- use Alaio Vibecode to build an app for Bitrix24 from a task description without knowing any programming language. The agent writes the code and deploys the app to a server, with no manual hosting setup
- use the MCP server to develop a REST API integration in your own project. The agent refers to the official REST documentation
Scope:
imWho can execute the method: chat participant
Deprecated method
The method is kept to support existing integrations. For new development, use im.v2.File.upload: it uploads a file to the chat in a single call, without uploading the file through Drive methods first.
The method im.disk.file.commit adds a file to a chat.
To add a file, specify:
- one of the chat identifier parameters —
CHAT_IDorDIALOG_ID - one of the file identifier parameters —
FILE_IDorUPLOAD_ID
If multiple parameters are passed simultaneously, the method processes only the first one.
You can obtain the identifier of the new file after uploading it using the method disk.folder.upload.file. To get the identifier of an existing file, use:
- disk.storage.getchildren — if the file is located in the root of the storage
- disk.folder.getchildren — if the file is located in a folder
Method Parameters
Required parameters are marked with *
|
Name |
Description |
|
CHAT_ID* |
Identifier of the chat. Required if |
|
DIALOG_ID* |
Identifier of the dialog in the format:
Required if |
|
FILE_ID* |
Identifier of the file on Drive. An array can be passed. Required if |
|
UPLOAD_ID* |
Identifier of the file on Drive. An array can be passed. Supports an additional parameter Required if |
|
MESSAGE |
Text message with the file |
|
SILENT_MODE |
Parameter for Open Channels chat Possible values:
|
|
AS_FILE |
Send as a file. Only for Possible values:
|
Code Examples
How to Use Examples in Documentation
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"CHAT_ID":1489,"FILE_ID":[5249,5250],"MESSAGE":"Project documents"}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/im.disk.file.commit
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"CHAT_ID":1489,"FILE_ID":[5249,5250],"MESSAGE":"Project documents","auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/im.disk.file.commit
// This snippet is an ES module: top-level await requires type="module" or a bundler.
// $b24 is an already-initialized SDK instance (see the SDK "Get started" guide).
import { Text } from '@bitrix24/b24jssdk'
import type { B24Frame } from '@bitrix24/b24jssdk'
declare const $b24: B24Frame
type FileUploadItem = {
id: number
chatId: number
name: string
extension: string
size: number
status: string
authorId: number
authorName: string
urlPreview: string
urlShow: string
urlDownload: string
isTranscribable: boolean
isVideoNote: boolean
isVoiceNote: boolean
}
type FileModelItem = {
id: number
name: string
storageId: number
size: number
etag: string
links: {
download: string
showInGrid: string
preview: string
}
}
// Shape of the payload returned in result (match the "response handling" section of the page)
type ImDiskFileCommitResult = {
FILES: Record<string, FileUploadItem>
DISK_ID: string[]
FILE_MODELS: Record<string, FileModelItem>
MESSAGE_ID: number
}
try {
const response = await $b24.actions.v2.call.make<ImDiskFileCommitResult>({
method: 'im.disk.file.commit',
params: {
CHAT_ID: 1489,
FILE_ID: [5249, 5250],
MESSAGE: 'Project documents',
},
requestId: Text.getUuidRfc4122()
})
// The payload is available only on a successful response
if (!response.isSuccess) {
console.error(response.getErrorMessages().join('; '))
} else {
const result = response.getData()!.result
console.info(result.MESSAGE_ID, result.DISK_ID, result.FILES)
}
} catch (error) {
// Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
console.error(error)
}
<!-- Load the SDK (UMD build); it is exposed as the global B24Js -->
<script src="https://unpkg.com/@bitrix24/b24jssdk@1/dist/umd/index.min.js"></script>
<script>
async function commitFileToChat() {
try {
// Initialize the SDK inside a Bitrix24 frame
const $b24 = await B24Js.initializeB24Frame()
const response = await $b24.actions.v2.call.make({
method: 'im.disk.file.commit',
params: {
CHAT_ID: 1489,
FILE_ID: [5249, 5250],
MESSAGE: 'Project documents',
},
requestId: B24Js.Text.getUuidRfc4122()
})
// The payload is available only on a successful response
if (!response.isSuccess) {
console.error(response.getErrorMessages().join('; '))
return
}
const result = response.getData().result
console.info(result.MESSAGE_ID, result.DISK_ID, result.FILES)
} catch (error) {
// Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
console.error(error)
}
}
document.addEventListener('DOMContentLoaded', commitFileToChat)
</script>
from b24pysdk.errors import BitrixAPIError, BitrixSDKException
try:
bitrix_response = client.im.disk.file.commit(
chat_id=1489,
file_id=[
5249,
5250,
],
message="Project documents",
).response
result = bitrix_response.result
print(result)
except BitrixAPIError as error:
print(
"Bitrix API error",
f"error: {error.error}",
f"error_description: {error.error_description}",
sep="\n",
)
except BitrixSDKException as error:
print(f"Bitrix SDK error: {error.message}")
except Exception as error:
print(f"Unexpected error: {error}")
try {
$response = $b24Service
->core
->call(
'im.disk.file.commit',
[
'CHAT_ID' => 1489,
'FILE_ID' => [5249, 5250],
'MESSAGE' => 'Project documents',
]
);
$result = $response
->getResponseData()
->getResult();
echo 'Success: ' . print_r($result, true);
} catch (Throwable $e) {
error_log($e->getMessage());
echo 'Error: ' . $e->getMessage();
}
BX24.callMethod(
'im.disk.file.commit',
{
CHAT_ID: 1489,
FILE_ID: [5249, 5250],
MESSAGE: 'Project documents',
},
function(result)
{
if (result.error())
{
console.error(result.error());
}
else
{
console.log(result.data());
}
}
);
require_once('crest.php');
$result = CRest::call(
'im.disk.file.commit',
[
'CHAT_ID' => 1489,
'FILE_ID' => [5249, 5250],
'MESSAGE' => 'Project documents',
]
);
echo '<PRE>';
print_r($result);
echo '</PRE>';
// client and ctx are already created — see the Go SDK section
res, err := client.Core().Call(ctx, "im.disk.file.commit", b24.Params{
"CHAT_ID": 1489,
"FILE_ID": []int{5249, 5250},
"MESSAGE": "Project documents",
})
if err != nil {
return fmt.Errorf("im.disk.file.commit: %w", err)
}
var item struct {
MessageID b24.ID `json:"MESSAGE_ID"`
}
if err := json.Unmarshal(res.Result, &item); err != nil {
return fmt.Errorf("parse response: %w", err)
}
fmt.Println(item.MessageID)
Response Handling
HTTP Status: 200
{
"result": {
"FILES": {
"upload5249": {
"id": 5249,
"chatId": 1489,
"date": {},
"type": "file",
"name": "image.png",
"extension": "png",
"size": 2144,
"image": {
"height": 61,
"width": 72
},
"status": "done",
"progress": 100,
"authorId": 503,
"authorName": "John Smith",
"urlPreview": "https://mysite.com/bitrix/services/main/ajax.php?action=disk.api.file.download&SITE_ID=s1&humanRE=1&fileId=5249&exact=N&_esd=hpbccd%2FZFlCVMvT8%2FoXYU%2FfMrCjiXqxIAf6V4Sv1rR0euQRiW7%2BsdhF7n1QGRL8ZBBmpuiVaX9sY2NbsyigTzBiykXGbFEbXUAmoPO8IvcdVkdoD5n6CJHZG9DZ0DRpH6i5goVbMdjo%3D&fileName=image.png",
"urlShow": "https://mysite.com/bitrix/services/main/ajax.php?action=disk.api.file.showImage&SITE_ID=s1&humanRE=1&fileId=5249&width=1280&height=1280&signature=9f56cfa3412e55679012a6c3bef9ff391f1fc7becf6dc42bea2b8d68656934ce&exact=N&_esd=hpbccd%2FZFlCVMvT8%2FoXYU%2FfMrCjiXqxIAf6V4Sv1rR0euQRiW7%2BsdhF7n1QGRL8ZBBmpuiVaX9sY2NbsyigTzBiykXGbFEbXUAmoPO8IvcdVkdoD5n6CJHZG9DZ0DRpH6i5goVbMdjo%3D&fileName=image.png",
"urlDownload": "https://mysite.com/bitrix/services/main/ajax.php?action=disk.api.file.download&SITE_ID=s1&humanRE=1&fileId=5249&exact=N&_esd=hpbccd%2FZFlCVMvT8%2FoXYU%2FfMrCjiXqxIAf6V4Sv1rR0euQRiW7%2BsdhF7n1QGRL8ZBBmpuiVaX9sY2NbsyigTzBiykXGbFEbXUAmoPO8IvcdVkdoD5n6CJHZG9DZ0DRpH6i5goVbMdjo%3D&fileName=image.png",
"viewerAttrs": {
"viewer": "",
"viewerType": "image",
"src": "https://mysite.com/bitrix/services/main/ajax.php?action=disk.api.file.download&SITE_ID=s1&humanRE=1&fileId=5249&exact=N&_esd=hpbccd%2FZFlCVMvT8%2FoXYU%2FfMrCjiXqxIAf6V4Sv1rR0euQRiW7%2BsdhF7n1QGRL8ZBBmpuiVaX9sY2NbsyigTzBiykXGbFEbXUAmoPO8IvcdVkdoD5n6CJHZG9DZ0DRpH6i5goVbMdjo%3D&fileName=image.png",
"viewerResized": "",
"objectId": "5249",
"viewerGroupBy": "1489",
"imChatId": 1489,
"title": "image.png",
"actions": "[{\"type\":\"download\"},{\"type\":\"copyToMe\",\"text\":\"Save to Drive\",\"action\":\"BXIM.disk.saveToDiskAction\",\"params\":{\"fileId\":\"5249\"},\"extension\":\"disk.viewer.actions\",\"buttonIconClass\":\"ui-btn-icon-cloud\"}]"
},
"mediaUrl": {
"preview": {
"250": "https://mysite.com/bitrix/services/main/ajax.php?action=disk.api.file.download&SITE_ID=s1&humanRE=1&fileId=5249&exact=N&_esd=hpbccd%2FZFlCVMvT8%2FoXYU%2FfMrCjiXqxIAf6V4Sv1rR0euQRiW7%2BsdhF7n1QGRL8ZBBmpuiVaX9sY2NbsyigTzBiykXGbFEbXUAmoPO8IvcdVkdoD5n6CJHZG9DZ0DRpH6i5goVbMdjo%3D&fileName=image.png"
}
},
"isTranscribable": false,
"isVideoNote": false,
"isVoiceNote": false
}
},
"DISK_ID": [
"5249"
],
"FILE_MODELS": {
"upload5249": {
"id": 5249,
"name": "image.png",
"createTime": {},
"updateTime": {},
"deleteTime": null,
"code": "media_original",
"xmlId": null,
"storageId": 663,
"realObjectId": 5249,
"parentId": 4821,
"deletedType": 0,
"createdBy": "503",
"updatedBy": "503",
"deletedBy": "0",
"uniqueCode": "k7lj3sQxTRWSi6K93Vyh",
"typeFile": 2,
"globalContentVersion": 2,
"fileId": 57077,
"size": 2144,
"etag": "73c045036a9e96943fa57316371655c2",
"links": {
"download": "/bitrix/services/main/ajax.php?action=disk.file.download&SITE_ID=s1&fileId=5249",
"showInGrid": "/bitrix/tools/disk/focus.php?objectId=5249&action=showObjectInGrid&ncc=1",
"preview": "/bitrix/services/main/ajax.php?action=disk.api.file.showImage&SITE_ID=s1&humanRE=1&width=640&height=640&signature=8e152b3f4820b07a3f8ea79a6de60b0ae5a82a57467d08d1e8a8a399afb0330f&fileId=5249"
}
}
},
"MESSAGE_ID": 84779
},
"time": {
"start": 1772451339,
"finish": 1772451339.658828,
"duration": 0.6588280200958252,
"processing": 0,
"date_start": "2026-03-02T14:35:39+01:00",
"date_finish": "2026-03-02T14:35:39+01:00",
"operating_reset_at": 1772451939,
"operating": 0
}
}
Returned Data
|
Name |
Description |
|
result |
Root object of the result (detailed description) |
|
time |
Information about the execution time of the request |
Object result-item
|
Name |
Description |
|
FILES |
Data of added files (detailed description) |
|
DISK_ID |
Array of file identifiers on Drive |
|
FILE_MODELS |
Models of added files on Drive (detailed description) |
|
MESSAGE_ID |
Identifier of the message with files |
Object FILES
|
Name |
Description |
|
upload{id} |
File object, where |
Object FILES.upload{id}
|
Name |
Description |
|
id |
Identifier of the file on Drive |
|
chatId |
Identifier of the chat |
|
date |
Date of file creation |
|
type |
Type of the item |
|
name |
Name of the file |
|
extension |
File extension |
|
size |
Size of the file in bytes |
|
image |
Image parameters (detailed description) |
|
status |
Status of file processing |
|
progress |
Progress of file processing in percentage |
|
authorId |
Identifier of the file author |
|
authorName |
Name of the file author |
|
urlPreview |
Link to the file preview |
|
urlShow |
Link to view the file |
|
urlDownload |
Link to download the file |
|
viewerAttrs |
File viewer parameters (detailed description) |
|
mediaUrl |
Links to media file (detailed description) |
|
isTranscribable |
Is the file transcribable |
|
isVideoNote |
Is the file a video note |
|
isVoiceNote |
Is the file a voice note |
Object image
|
Name |
Description |
|
height |
Height of the image |
|
width |
Width of the image |
Object viewerAttrs
|
Name |
Description |
|
viewer |
Viewer identifier |
|
viewerType |
Type of viewer |
|
src |
Source file for the viewer |
|
viewerResized |
Source of the reduced version of the file |
|
objectId |
Identifier of the object in the viewer |
|
viewerGroupBy |
Identifier of the viewer group |
|
imChatId |
Identifier of the chat for the viewer |
|
title |
Title in the viewer |
|
actions |
List of actions in the viewer in JSON string format |
Object mediaUrl
|
Name |
Description |
|
preview |
Set of links to file previews by size (detailed description) |
Object mediaUrl.preview
|
Name |
Description |
|
250 |
Link to preview with a width of 250 px |
Object FILE_MODELS
|
Name |
Description |
|
upload{id} |
File model object, where |
Object FILE_MODELS.upload{id}
|
Name |
Description |
|
id |
Identifier of the file on Drive |
|
name |
Name of the file |
|
createTime |
Date of file creation |
|
updateTime |
Date of file update |
|
deleteTime |
Date of file deletion, can be |
|
code |
File type code |
|
xmlId |
External identifier, can be |
|
storageId |
Identifier of the storage |
|
realObjectId |
Identifier of the real object |
|
parentId |
Identifier of the parent folder |
|
deletedType |
Deletion type |
|
createdBy |
Identifier of the creator |
|
updatedBy |
Identifier of the updater |
|
deletedBy |
Identifier of the deleter |
|
uniqueCode |
Unique code of the file |
|
typeFile |
Numeric code of the file type |
|
globalContentVersion |
Global content version |
|
fileId |
Identifier of the related file |
|
size |
Size of the file in bytes |
|
etag |
ETag of the file |
|
links |
Links for working with the file (detailed description) |
Object links
|
Name |
Description |
|
download |
Link to download the file |
|
showInGrid |
Link to show the file in the grid |
|
preview |
Link to preview the file |
Error Handling
HTTP Status: 400
{
"error": "CHAT_ID_EMPTY",
"error_description": "Chat ID can't be empty"
}
|
Name |
Description |
|
error |
String error code. It consists of digits, Latin letters, and underscores. It may arrive empty — in that case only |
|
error_description |
Error message for the developer. Do not show it to the end user without processing |
Possible Error Codes
|
Status |
Code |
Description |
Value |
|
|
|
Chat ID can't be empty |
Possible reasons:
|
|
|
|
Dialog ID can't be empty |
Empty or invalid |
|
|
|
List of files is not specified |
One of the required parameters |
|
|
|
Error during saving file to chat |
Possible reasons:
|
|
|
|
You do not have access to the specified dialog |
Insufficient rights to view the dialog or a non-existent dialog is passed |
Statuses and System Error Codes
HTTP Status: 4xx, 5xx
The errors described below are returned by the REST API itself, not by the logic of a specific method. They can arrive in response to any method.
|
Status |
Code |
Description |
|
|
|
An internal server error has occurred. Retry the call, and if the error persists, contact the server administrator or Bitrix24 technical support |
|
|
|
The server returned an unexpected response. Retry the call, and if the error persists, contact the server administrator or Bitrix24 technical support |
|
|
|
The request intensity limit has been exceeded |
|
|
|
The method is blocked because the request resource intensity limit has been exceeded. The block is lifted automatically once the accumulated execution time of the method no longer exceeds the limit |
|
|
|
The request contains no authorization data: neither an access token nor a webhook code was passed |
|
|
|
Methods are called over the HTTPS protocol only |
|
|
|
The REST API is blocked due to overload. This is a manual individual block. To have it lifted, contact Bitrix24 technical support |
|
|
|
REST API access is not active for this account. In Bitrix24 Cloud, check the current plan or trial status: Vibe+ plans include REST API access, while Essentials plans do not. A webhook receives a different error message — |
|
|
|
No active webhook with the specified user identifier and secret code was found |
|
|
|
No method with this name was found. The name is misspelled, the method does not exist in the REST API, or it is unavailable without the required scope |
|
|
|
The request requires broader permissions than the token has: for a webhook these are the permissions granted to it, for an application it is the scope. For an application, the error message ends with |
|
|
|
The access token has expired |
|
|
|
The application is installed, but the Bitrix24 administrator has granted access to it only to specific users |
|
|
|
The public part of the site is closed. To open it on an on-premise installation, disable the "Temporary closure of the public part of the site" option. Path to the setting: Desktop > Settings > Product Settings > Module Settings > Main Module > Temporary closure of the public part of the site |