Set a group's profile picture
Agent Skill
Automate this endpoint with an AI agent using the 2chat-whatsapp-groups skill:
npx skills add 2ChatCo/agent-skills -s 2chat-whatsapp-groups
With this endpoint, you will be able to set a profile picture for a given group.
API costโ
1API credit
Each call to this endpoint deducts 1 API credit from your plan's API credit pool.
Parametersโ
You will need to obtain the UUID of the WhatsApp group that you want to use. In this example, we will use WAG45b0f301-9203-4660-8b57-b51a6c2742a5 as the UUID.
These parameters should be sent as a JSON payload in the request body.
| Field | Description | Example values |
|---|---|---|
from_number | Your WhatsApp number that you connected to 2Chat | +12123334444 |
url | A publicly accessible URL pointing to the image you want to set as group's picture | https://2chat.co/img/2chat-logo.png |
Invocationโ
The group UUID is part of the path in the URL. For this example, we are using WAG45b0f301-9203-4660-8b57-b51a6c2742a5 as the UUID.
tip
You can obtain the UUID of the group you want to target using the List Groups endpoint
- cURL
- Python
- JavaScript
- PHP
curl -X POST --location 'https://api.p.2chat.io/open/whatsapp/group/WAG45b0f301-9203-4660-8b57-b51a6c2742a5/set-picture' \
--header 'Content-Type: application/json' \
--header 'X-User-API-Key: your_api_key_here' \
--data '{
"from_number": "+12123334444",
"url": "https://2chat.co/img/2chat-logo.png"
}'
import requests
import json
url = "https://api.p.2chat.io/open/whatsapp/group/WAG45b0f301-9203-4660-8b57-b51a6c2742a5/set-picture"
payload = json.dumps({
"from_number": "+12123334444",
"url": "https://2chat.co/img/2chat-logo.png"
})
headers = {
'Content-Type': 'application/json',
'X-User-API-Key': 'your_api_key_here'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
const axios = require('axios');
let data = JSON.stringify({
"from_number": "+12123334444",
"url": "https://2chat.co/img/2chat-logo.png"
});
let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://api.p.2chat.io/open/whatsapp/group/WAG45b0f301-9203-4660-8b57-b51a6c2742a5/set-picture',
headers: {
'Content-Type': 'application/json',
'X-User-API-Key': 'your_api_key_here'
},
data : data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.p.2chat.io/open/whatsapp/group/WAG45b0f301-9203-4660-8b57-b51a6c2742a5/set-picture',
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 => '{
"from_number": "+12123334444",
"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โ
{
"success": true,
}