Skip to content

GetAvatar#

The method returns a user or a group chat avatar.

Request#

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

POST https://api.greenapi.com/waInstance{{idInstance}}/getAvatar/{{apiTokenInstance}}

For 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
reason string Reason why avatar has not been checked. Present when the check has not been successful, possible variants:
bad request data - Invalid phone number format. Telephone number must be 11 or 12 digits. Or chat Id
get avatar timeout limit exceeded - The timeout for a response to check avatar availabiity has been exceeded

Response body example#

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

GetAvatar errors#

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

HTTP code Error Id Description
200 bad request data Invalid phone number format. Telephone number must be 11 or 12 digits. Or chat Id
200 get avatar timeout limit exceeded The timeout for a response to check avatar availabiity has been exceeded

Request examples#

import requests

url = "https://api.greenapi.com/waInstance{{idInstance}}/getAvatar/{{apiTokenInstance}}"

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

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

print(response.text.encode('utf8'))
curl --location 'https://api.green-api.com/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("https://api.greenapi.com")
    .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("https://api.greenapi.com")
    .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);