Set WhatsApp Profile Picture
This endpoint will let you set the profile picture of your WhatsApp account to the provided value.
Parameters
These parameters should be sent as JSON payload in the request body.
Field | Description | Example value |
---|---|---|
url | The URL of the image you want to set as profile picture | https://2chat.co/img/2chat-logo.png |
tip
To remove the profile picture, set url
to null
.
Invocation
Make a POST
request to https://api.p.2chat.io/open/whatsapp/set-profile-picture/<number>
where <number>
is the phone number that you have connected to 2Chat.
- cURL
- Python
- NodeJS
- PHP
curl --location --request POST 'https://api.p.2chat.io/open/whatsapp/set-profile-picture/+595981048477' \
--header 'X-User-API-Key: your_api_key_here' \
--header 'Content-Type: application/json' \
--data-raw '{
"url": "https://2chat.co/img/2chat-logo.png"
}'
import requests
import json
url = "https://api.p.2chat.io/open/whatsapp/set-profile-picture/+595981048477"
payload = json.dumps({
"url": "https://2chat.co/img/2chat-logo.png"
})
headers = {
'X-User-API-Key': 'your_api_key_here',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var axios = require('axios');
var data = JSON.stringify({
"url": "https://2chat.co/img/2chat-logo.png"
});
var config = {
method: 'post',
url: 'https://api.p.2chat.io/open/whatsapp/set-profile-picture/+595981048477',
headers: {
'X-User-API-Key': 'your_api_key_here',
'Content-Type': 'application/json'
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.p.2chat.io/open/whatsapp/set-profile-picture/+595981048477',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"url": "https://2chat.co/img/2chat-logo.png"
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-User-API-Key: your_api_key_here'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Response
The API will return whether it succeded or not to queue the request for processing
{
"success": true,
"batched": true
}