Skip to content

SendFileByUpload Test#

For the SendFileByUpload method, we recommend to use the host

The method is aimed for sending a file uploaded by form (form-data). The message will be added to the send queue, in the response you will receive a link to the downloaded file. The rate at which messages are sent from the queue is managed by Message sending delay parameter.

The link is valid for 15 days.

The link can be reused using the SendFileByUrl method.

Video, audio and image files available for viewing and listening to are sent as in native-mode WhatsApp. Documents are sent in the same way as in native-mode WhatsApp. Outgoing file type and send method is determined by the file extension. Description is only added to images and video.

The maximum size of outgoing files is 100 MB.

Sending multiple files with one request is not possible. 1 file is sent with only 1 message. The ability to send multiple files at the same time is created only on the side of the WhatsApp application.

There are no restrictions on image resolutions. However, when sending images through the API with a resolution exceeding 3000x3000 pixels, thumbnails will not be generated.

List of file extensions, that could be successfully sent and received via the API


To send a file, you have to execute a request at:


For mediaUrl, idInstance and apiTokenInstance request parameters, refer to Before you start section.

Request parameters#

Parameter Type Mandatory Description
chatId string Yes Chat Id
file file Yes Outgoing file
fileName string No File name. Must contain file extension. Requires UTF-8 encoding without BOM. For example: test.jpg
caption string No File caption. Caption added to video, images. The maximum field length is 20000 characters.
quotedMessageId string No Quoted message Id. If present, the message will be sent quoting the specified chat message.

Time to send a file

Sending files occurs in several stages:

  1. Receive the file
  2. Uploading a file to the WhatsApp server
  3. Request to send a file to WhatsApp

The time to send a file depends on the file size, the speed of receiving the file and WhatsApp processing the file. Depending on these factors, the time to send a file can vary from 1 to 20 seconds.

Request body example#

Request examples

import requests

url = "{{mediaUrl}}/waInstance{{idInstance}}/sendFileByUpload/{{apiTokenInstance}}"

payload = {'chatId': '',
'caption': 'Описание'}
files = [
  ('file', ('window.jpg', open('C:/window.jpg','rb'),'image/jpeg'))
headers= {}

response = requests.request("POST", url, headers = headers, data = payload, files = files)

curl --location '{{mediaUrl}}/waInstance{{idInstance}}/sendFileByUpload/{{apiTokenInstance}}' \
--form 'chatId=""' \
--form 'file=@"/Users/you/files/file.jpeg"' \
--form 'fileName="file.jpg"'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();

var headers = new HttpHeaders();

var form = new LinkedMultiValueMap<>();
    form.add("chatId", "");
    form.add("file", new FileSystemResource(new File("/Users/you/files/file.jpeg")));
    form.add("fileName", file.jpg);
    form.add("caption", "Описание");
    form.add("quotedMessageId", "BAE5F4886F6F2D05");

var requestEntity = new HttpEntity<>(form, headers);

var response =, HttpMethod.POST, requestEntity, String.class);
var file = new File("/Users/user/Desktop/fileExample.jpeg");
var requestUrl = new StringBuilder();

var form = new HashMap<String, Object>();
    form.put("chatId", dto.getChatId());
    form.put("file", dto.getFile());
    form.put("fileName", dto.getFileName());
    form.put("caption", dto.getCaption());
    form.put("quotedMessageId", dto.getQuotedMessageId());

var response =

program sendFileByUpload;


  System.Classes, System.Net.HttpClient, System.Net.Mime, System.Net.URLClient, System.Net.HttpClientComponent;

  HttpClient: TNetHTTPClient;
  Response: IHTTPResponse;
  FormData: TMultipartFormData;

  MEDIA_URL := '';
  ID_INSTANCE := '110100001';
  API_TOKEN_INSTANCE := 'd75b3a66374942c5b3c019c698abc2067e151558acbd451234';

  EndpointURL := MEDIA_URL +'/waInstance' + ID_INSTANCE + '/sendFileByUpload/' + API_TOKEN_INSTANCE;

  HttpClient := TNetHTTPClient.Create(nil);

  FormData := TMultipartFormData.Create();
  FormData.AddField('chatId', '');
  FormData.AddField('caption', 'test');
  FormData.AddFile('file', 'C:\tmp\bp.png');

    Response := HTTPClient.Post(EndpointURL, FormData, nil);

    if Response.StatusCode = 200 then
      Writeln('[Response]: ' + Response.ContentAsString)
      Writeln('[ERROR ' + IntToStr(Response.StatusCode) + ']:' + Response.StatusText + '' + Response.ContentAsString);

    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);




Response parameters#

Parameter Type Description
idMessage string Sent message Id
urlFile string Link to file (link expires 15 days)

Response body example#

    "idMessage": "3EB0C767D097B7C7C030",
    "urlFile": ""

SendFileByUpload errors#

For a list of errors common to all methods, refer to Common errors section

HTTP code Error ID Description
400 file should not be empty The user submitted an empty file. The uploaded file must not be empty.
413 request entity too large Occurs when sending files in 1C processing (version Possible solution: Change 1C version.