Skip to content

DownloadFile#

Test Postman

The method is intended for downloading received and sent files.

Links to files can be obtained through:

The method uses limits on the request rate per second.

The file storage period is 24 hours.

Request#

POST
{{apiUrl}}/waInstance{{idInstance}}/downloadFile/{{apiTokenInstance}}

To get the apiUrl, idInstance and apiTokenInstance request parameters, refer to the Before you start section.

Request parameters#

Parameter Type Required Description
chatId string Yes Identifier of the personal or group chat
idMessage string Yes Message identifier

Request body example#

{
    "chatId": "10000000",
    "idMessage": "1763115112345"
}

Response#

Response fields#

Parameter Type Description
downloadUrl string Link to the file from the message

Response body example#

{
    "downloadUrl": "https://4100.api.green-api.com/download/4100/a6679d42-2f7f-4121-acfe-1f993dfcf123.png"
}

Errors#

For the list of errors common to all methods, see the Common errors section

HTTP code Error identifier Description
400 Bad Request
Validation failed
Validation error
400 File message encrypted url not found by chatId 10000000 and idMessage 1763115112345 There is no file in the message

Code examples#

import requests
import json

url = "{{apiUrl}}/waInstance{{idInstance}}/downloadFile/{{apiTokenInstance}}"

payload = json.dumps({
  "chatId": "10000000",
  "idMessage": "1763115112345"
})
headers = {
  'Content-Type': 'application/json'
}

response = requests.post(url, json=payload)

print(response.text)
curl --location -g --request POST '{{apiUrl}}/waInstance{{idInstance}}/downloadFile/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "chatId": "10000000",
    "idMessage": "1763115112345"
}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
    .append({{apiUrl}})
    .append("/waInstance").append({{idInstance}})
    .append("/downloadFile/")
    .append({{apiTokenInstance}});

var headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);

var jsonBody = "{\"chatId\": \"10000000\",\"idMessage\": \"1763115112345\"}";

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

var response = restTemplate.exchange(requestUrl.toString(), HttpMethod.POST, requestEntity, String.class);
System.out.println(response);
var requestUrl = new StringBuilder();
requestUrl
    .append({{apiUrl}})
    .append("/waInstance").append({{idInstance}})
    .append("/downloadFile/")
    .append({{apiTokenInstance}});

var response = Unirest.post(requestUrl.toString())
    .header("Content-Type", "application/json")
    .body("{\"chatId\": \"10000000\",\"idMessage\": \"1763115112345\"}")
    .asString();

System.out.println(response);
Sub DownloadFile()
    Dim url As String
    Dim RequestBody As String
    Dim http As Object
    Dim response As String

    ' The apiUrl, idInstance and apiTokenInstance values are available in console, double brackets must be removed
    url = "{{apiUrl}}/waInstance{{idInstance}}/downloadFile/{{apiTokenInstance}}"

    ' chatId - personal or group chat identifier whose message history you want to receive, count - number of messages to receive, default value 100
    RequestBody = "{""chatId"":""10000000"",""idMessage"":""1763115112345""}"

    Set http = CreateObject("MSXML2.XMLHTTP")

    With http
        .Open "POST", url, False
        .setRequestHeader "Content-Type", "application/json"
        .send RequestBody
    End With

    response = http.responseText

    Debug.Print response

    ' Outputting the answer to the desired cell
    Range("A1").Value = response

    Set http = Nothing
End Sub