﻿---
sidebar_position: 5
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Send file
 Send disk file to chat



`Function SendFile(Val URL, Val ChatID, Val FileID, Val Description = "", Val Token = "") Export`

  | Parameter | CLI option | Type | Required | Description |
  |-|-|-|-|-|
  | URL | --url | String | &#x2714; | URL of webhook or a Bitrix24 domain, when token used |
  | ChatID | --chat | String, Number | &#x2714; | Chat ID |
  | FileID | --fileid | String, Number | &#x2714; | File ID from UploadFileToFolder method |
  | Description | --description | String | &#x2716; | File description |
  | Token | --token | String | &#x2716; | Access token, when app auth method used |

  
  Returns:  Map Of KeyAndValue - serialized JSON of answer from Bitrix24 API

<br/>

:::tip
Method at API documentation: [im.disk.file.commit](https://dev.1c-bitrix.ru/learning/course/index.php?COURSE_ID=93&LESSON_ID=11485)
:::
<br/>



```bsl title="1C:Enterprise/OneScript code example"
    URL         = "https://b24-ar17wx.bitrix24.by/rest/1/ps5...";
    ChatID      = "1726";
    File        = "https://api.athenaeum.digital/test_data/document.docx"; // Binary Data, URL or path to file
    Description = "Very important file";

    Directory = OPI_Bitrix24.GetChatFilesFolder(URL, ChatID);
    FolderID  = Directory["result"]["ID"];

    UploadedFile = OPI_Bitrix24.UploadFileToFolder(URL, "Imortant doc.docx", File, FolderID);
    FileID       = UploadedFile["result"]["ID"];

    Result = OPI_Bitrix24.SendFile(URL, ChatID, FileID, Description);

    URL    = "b24-ar17wx.bitrix24.by";
    Token  = "70f46a67006e9f06006b12e400000001000...";
    ChatID = "1728";

    Directory = OPI_Bitrix24.GetChatFilesFolder(URL, ChatID, Token);
    FolderID  = Directory["result"]["ID"];

    UploadedFile = OPI_Bitrix24.UploadFileToFolder(URL, "Imortant doc.docx", File, FolderID, Token);
    FileID       = UploadedFile["result"]["ID"];

    Result = OPI_Bitrix24.SendFile(URL, ChatID, FileID, Description, Token);
```
 

 <Tabs>
  
    <TabItem value="bash" label="Bash" default>
        ```bash
            oint bitrix24 SendFile \
             --url "b24-ar17wx.bitrix24.by" \
             --chat 1744 \
             --fileid 23894 \
             --description "Very important file" \
             --token "***"
        ```
    </TabItem>
  
    <TabItem value="bat" label="CMD/Bat" default>
        ```batch
            oint bitrix24 SendFile ^
             --url "b24-ar17wx.bitrix24.by" ^
             --chat 1744 ^
             --fileid 23894 ^
             --description "Very important file" ^
             --token "***"
        ```
    </TabItem>
</Tabs>


```json title="Result"
{
 "result": {
  "FILES": {
   "upload12614": {
    "id": 12614,
    "chatId": 988,
    "date": {},
    "type": "file",
    "name": "Imortant doc.docx",
    "extension": "docx",
    "size": 24071,
    "image": false,
    "status": "done",
    "progress": 100,
    "authorId": 1,
    "authorName": "Антон Титовец",
    "urlPreview": "",
    "urlShow": "/bitrix/services/main/ajax.php?action=disk.api.file.download&SITE_ID=s1&humanRE=1&fileId=12614&fileName=Imortant%20doc.docx",
    "urlDownload": "/bitrix/services/main/ajax.php?action=disk.api.file.download&SITE_ID=s1&humanRE=1&fileId=12614&fileName=Imortant%20doc.docx",
    "viewerAttrs": {
     "viewer": null,
     "viewerType": "cloud-document",
     "src": "/bitrix/services/main/ajax.php?action=disk.api.file.download&SITE_ID=s1&humanRE=1&fileId=12614&fileName=Imortant%20doc.docx",
     "viewerTypeClass": "BX.Messenger.Integration.Viewer.OnlyOfficeChatItem",
     "viewerSeparateItem": true,
     "viewerExtension": "im.integration.viewer",
     "objectId": "12614",
     "imChatId": 988,
     "title": "Imortant doc.docx",
     "actions": "[{\"type\":\"download\"},{\"type\":\"copyToMe\",\"text\":\"Сохранить на Битрикс24 Диск\",\"action\":\"BXIM.disk.saveToDiskAction\",\"params\":{\"fileId\":\"12614\"},\"extension\":\"disk.viewer.actions\",\"buttonIconClass\":\"ui-btn-icon-cloud\"}]"
    }
   }
  },
  "DISK_ID": [
   "12614"
  ],
  "FILE_MODELS": {
   "upload12614": {
    "id": 12614,
    "name": "Imortant doc.docx",
    "createTime": {},
    "updateTime": {},
    "deleteTime": null,
    "code": null,
    "xmlId": null,
    "storageId": 6,
    "realObjectId": 12614,
    "parentId": 12610,
    "deletedType": 0,
    "createdBy": "1",
    "updatedBy": "1",
    "deletedBy": "0",
    "typeFile": 4,
    "globalContentVersion": 2,
    "fileId": 8688,
    "size": 24071,
    "etag": "46a4f72f7b8b92b6f5f2892c05e7faa7",
    "links": {
     "download": "/bitrix/services/main/ajax.php?action=disk.file.download&SITE_ID=s1&fileId=12614",
     "showInGrid": "/bitrix/tools/disk/focus.php?objectId=12614&action=showObjectInGrid&ncc=1"
    }
   }
  },
  "MESSAGE_ID": 17762
 },
 "time": {
  "start": 1728454913.41449,
  "finish": 1728454913.53076,
  "duration": 0.116268157958984,
  "processing": 0.0841860771179199,
  "date_start": "2024-10-09T09:21:53+03:00",
  "date_finish": "2024-10-09T09:21:53+03:00",
  "operating_reset_at": 1728455513,
  "operating": 0
 }
}
```
