Skip to content

GetAvatar#

Test Postman Apidog

The method returns a user or a group chat avatar.

Request#

To get avatar, you have to execute a request at:

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

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

Request parameters#

Parameter Type Mandatory Description
chatId string Yes User or group chat Id

Request body example#

To get your avatar - specify your number in chatId ("{your number}@c.us").

Get user avatar:

{
    "chatId": "11001234567@c.us"
}

Get group chat avatar:

{
    "chatId": "11001234567-1581234048@g.us"
}

Response#

Response parameters#

Parameter Type Description
urlAvatar string Link to a user or a group chat avatar. The parameter takes an empty value if the avatar is not set or the number has privacy settings that restrict access to the avatar
available boolean A flag that indicates the availability of the correspondent's avatar or group chat.
1. The parameter takes the value true if the avatar is available for viewing. However, if the correspondent does not have an avatar set, the urlAvatar field will be empty.
2. The parameter takes the value false if the correspondent has chat privacy settings enabled and the avatar is not available.

Response body example#

{
      "urlAvatar": "https://pps.whatsapp.net/v/link/to/the/image",
      "available": true
}

GetAvatar errors#

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

HTTP code Error identifier Description
200 {
"urlAvatar": "",
"available": false
}
The number has privacy settings that restrict access to the avatar
200 {
"urlAvatar": "",
"available": true
}
Avatar is not set
or there is no WhatsApp account on the number
400 Bad Request
Validation failed
Validation error

Request examples#

import requests

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

payload = "{\r\n    \"chatId\": \"11001234567@c.us\"\r\n}"
headers = {
  'Content-Type': 'application/json'
}

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

print(response.text.encode('utf8'))
curl --location '{{apiUrl}}/waInstance{{idInstance}}/getAvatar/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "chatId": "11001234567@c.us"
}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
    .append({{apiUrl}})
    .append("/waInstance").append({{idInstance}})
    .append("/getAvatar/")
    .append({{apiTokenInstance}});

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

var jsonBody = "{\"chatId\": \"11001234567@c.us\"}";

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("/getAvatar/")
    .append({{apiTokenInstance}});

var response = Unirest.post(requestUrl.toString())
    .header("Content-Type", "application/json")
    .body("{\"chatId\": \"11001234567@c.us\"}")
    .asString();

System.out.println(response);
Sub GetAvatar()
    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}}/GetAvatar/{{apiTokenInstance}}"

    ' chatId - is the number to send the message to (@c.us for private chats, @g.us for group chats)
    RequestBody = "{""chatId"":""71234567890@c.us""}"

    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