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: im

Who 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_ID or DIALOG_ID
  • one of the file identifier parameters — FILE_ID or UPLOAD_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:

Method Parameters

Required parameters are marked with *

Name
type

Description

CHAT_ID*
integer

Identifier of the chat.

Required if DIALOG_ID is not provided

DIALOG_ID*
string

Identifier of the dialog in the format:

  • chatXXX — chat
  • sgXXX — group or project chat
  • XXX — user identifier for personal chat

Required if CHAT_ID is not provided

FILE_ID*
integer

Identifier of the file on Drive. An array can be passed.

Required if UPLOAD_ID is not provided

UPLOAD_ID*
integer

Identifier of the file on Drive. An array can be passed.

Supports an additional parameter AS_FILE, which allows sending the image without compression, as a file.

Required if FILE_ID is not provided

MESSAGE
string

Text message with the file

SILENT_MODE
string

Parameter for Open Channels chat

Possible values:

  • Y — send notification to the client
  • N — do not send notification to the client

AS_FILE
string

Send as a file. Only for UPLOAD_ID.

Possible values:

  • Y — yes
  • N — no

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
type

Description

result
object

Root object of the result (detailed description)

time
time

Information about the execution time of the request

Object result-item

Name
type

Description

FILES
object

Data of added files (detailed description)

DISK_ID
array

Array of file identifiers on Drive

FILE_MODELS
object

Models of added files on Drive (detailed description)

MESSAGE_ID
integer

Identifier of the message with files

Object FILES

Name
type

Description

upload{id}
object

File object, where id — identifier of the upload file (detailed description)

Object FILES.upload{id}

Name
type

Description

id
integer

Identifier of the file on Drive

chatId
integer

Identifier of the chat

date
object

Date of file creation

type
string

Type of the item

name
string

Name of the file

extension
string

File extension

size
integer

Size of the file in bytes

image
object

Image parameters (detailed description)

status
string

Status of file processing

progress
integer

Progress of file processing in percentage

authorId
integer

Identifier of the file author

authorName
string

Name of the file author

urlPreview
string

Link to the file preview

urlShow
string

Link to view the file

urlDownload
string

Link to download the file

viewerAttrs
object

File viewer parameters (detailed description)

mediaUrl
object

Links to media file (detailed description)

isTranscribable
boolean

Is the file transcribable

isVideoNote
boolean

Is the file a video note

isVoiceNote
boolean

Is the file a voice note

Object image

Name
type

Description

height
integer

Height of the image

width
integer

Width of the image

Object viewerAttrs

Name
type

Description

viewer
string

Viewer identifier

viewerType
string

Type of viewer

src
string

Source file for the viewer

viewerResized
string

Source of the reduced version of the file

objectId
string

Identifier of the object in the viewer

viewerGroupBy
string

Identifier of the viewer group

imChatId
integer

Identifier of the chat for the viewer

title
string

Title in the viewer

actions
string

List of actions in the viewer in JSON string format

Object mediaUrl

Name
type

Description

preview
object

Set of links to file previews by size (detailed description)

Object mediaUrl.preview

Name
type

Description

250
string

Link to preview with a width of 250 px

Object FILE_MODELS

Name
type

Description

upload{id}
object

File model object, where id — identifier of the upload file (detailed description)

Object FILE_MODELS.upload{id}

Name
type

Description

id
integer

Identifier of the file on Drive

name
string

Name of the file

createTime
object

Date of file creation

updateTime
object

Date of file update

deleteTime
string

Date of file deletion, can be null

code
string

File type code

xmlId
string

External identifier, can be null

storageId
integer

Identifier of the storage

realObjectId
integer

Identifier of the real object

parentId
integer

Identifier of the parent folder

deletedType
integer

Deletion type

createdBy
string

Identifier of the creator

updatedBy
string

Identifier of the updater

deletedBy
string

Identifier of the deleter

uniqueCode
string

Unique code of the file

typeFile
integer

Numeric code of the file type

globalContentVersion
integer

Global content version

fileId
integer

Identifier of the related file

size
integer

Size of the file in bytes

etag
string

ETag of the file

links
object

Links for working with the file (detailed description)

Name
type

Description

download
string

Link to download the file

showInGrid
string

Link to show the file in the grid

preview
string

Link to preview the file

Error Handling

HTTP Status: 400

{
            "error": "CHAT_ID_EMPTY",
            "error_description": "Chat ID can't be empty"
        }
        

Name
type

Description

error
string

String error code. It consists of digits, Latin letters, and underscores. It may arrive empty — in that case only error_description shows the reason

error_description
string

Error message for the developer. Do not show it to the end user without processing

Possible Error Codes

Status

Code

Description

Value

400

CHAT_ID_EMPTY

Chat ID can't be empty

Possible reasons:

  • one of the required parameters CHAT_ID or DIALOG_ID is not provided
  • empty CHAT_ID is passed

400

DIALOG_ID_EMPTY

Dialog ID can't be empty

Empty or invalid DIALOG_ID is passed

400

FILES_ERROR

List of files is not specified

One of the required parameters FILE_ID or UPLOAD_ID is not provided

400

SAVE_ERROR

Error during saving file to chat

Possible reasons:

  • FILE_ID or UPLOAD_ID is passed empty
  • non-existent file identifiers are passed

403

ACCESS_ERROR

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
Error Message

Description

500

INTERNAL_SERVER_ERROR
Internal server error

An internal server error has occurred. Retry the call, and if the error persists, contact the server administrator or Bitrix24 technical support

500

ERROR_UNEXPECTED_ANSWER
Server returned an unexpected response

The server returned an unexpected response. Retry the call, and if the error persists, contact the server administrator or Bitrix24 technical support

503

QUERY_LIMIT_EXCEEDED
Too many requests

The request intensity limit has been exceeded

429

OPERATION_TIME_LIMIT
Method is blocked due to operation time limit

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

401

NO_AUTH_FOUND
Wrong authorization data

The request contains no authorization data: neither an access token nor a webhook code was passed

401

INVALID_REQUEST
Https required

Methods are called over the HTTPS protocol only

401

OVERLOAD_LIMIT
REST API is blocked due to overload

The REST API is blocked due to overload. This is a manual individual block. To have it lifted, contact Bitrix24 technical support

401

ACCESS_DENIED
REST is available only on commercial plans

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 — REST is available only by subscription

401

INVALID_CREDENTIALS
Invalid request credentials

No active webhook with the specified user identifier and secret code was found

404

ERROR_METHOD_NOT_FOUND
Method not 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

401

insufficient_scope
The request requires higher privileges than provided by the webhook token

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 provided by the access token

401

expired_token
The access token provided has expired

The access token has expired

401

user_access_error
The user does not have access to the application

The application is installed, but the Bitrix24 administrator has granted access to it only to specific users

403

PORTAL_DELETED
Portal was deleted

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

Continue Learning