SetProfilePicture#
Beta version
The functionality is in beta. Features may change and may also work unstably.
The method changes the profile picture of the authorized Instagram account. A request without a file removes the profile picture.
The method uses the limits on the number of requests per second.
Request#
To set the profile picture, you have to execute a request at:
{{apiUrl}}/waInstance{{idInstance}}/setProfilePicture/{{apiTokenInstance}}
For apiUrl, idInstance and apiTokenInstance request parameters, refer to the Before you start section.
The request body is passed in the multipart/form-data format.
Request parameters#
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
file | file | No | An image file in the JPEG or PNG format, with a side of at least 320 px. If the parameter is not passed or the file is empty, the current profile picture of the account is removed |
Response#
Response parameters#
| Field | Type | Description |
|---|---|---|
setProfilePicture | boolean | The flag of the picture being changed or removed |
urlAvatar | string | The link to the new profile picture. An empty string if the picture is removed or Instagram has not returned the link |
reason | string | The reason of the failure when setProfilePicture: false. An empty string on success |
Response body example#
The profile picture is set:
{
"setProfilePicture": true,
"urlAvatar": "https://instagram.ftse3-2.fna.fbcdn.net/v/t51.2885-19/503715707_17847415224494060_4153097218612589587_n.jpg",
"reason": ""
}
The profile picture is not set - a side of the image is smaller than 320 px:
{
"setProfilePicture": false,
"urlAvatar": "",
"reason": "profile picture: resolution 200x200 is below 320px"
}
A file that fails the check (the format is neither JPEG nor PNG, a side is smaller than 320 px) and a refusal of Instagram are returned with the 200 response, setProfilePicture: false and the reason in the reason field, for example profile picture: JPEG or PNG required, got gif. The exception is a WebP file: the method responds to it with the 400 error.
SetProfilePicture errors#
For a list of errors common to all methods, refer to the Common errors section
| HTTP code | Error ID | Description |
|---|---|---|
| 400 | Unsupported media type | The file is in the WebP format. The profile picture is accepted only in the JPEG or PNG format |
| 413 | 'file' is larger than the upload limit | The file size exceeds the allowed limit |
Request examples#
import requests
url = "{{apiUrl}}/waInstance{{idInstance}}/setProfilePicture/{{apiTokenInstance}}"
files = [
('file', ('avatar.jpg', open('avatar.jpg', 'rb'), 'image/jpeg'))
]
response = requests.post(url, files=files)
print(response.text.encode('utf8'))
curl --location '{{apiUrl}}/waInstance{{idInstance}}/setProfilePicture/{{apiTokenInstance}}' \
--form 'file=@"avatar.jpg"'
Remove the profile picture:
curl --location --request POST '{{apiUrl}}/waInstance{{idInstance}}/setProfilePicture/{{apiTokenInstance}}'