Set Group Picture
Set or update the profile picture of a WhatsApp group
Set Group Picture
Set or update the profile picture (avatar/icon) of a WhatsApp group.
Endpoint
PUT /{sessionId}/groups/{groupId}/picture
Headers
Name | Type | Required | Description |
---|---|---|---|
Authorization | string | Yes | Bearer token for authentication |
Content-Type | string | Yes | application/json |
Path Parameters
Parameter | Type | Required | Description |
---|---|---|---|
sessionId | string | Yes | The session ID |
groupId | string | Yes | The group ID |
Request Body
Refer to ProfilePictureRequest
in API.md
.
Field | Type | Required | Description |
---|---|---|---|
url | string | Yes | URL of the image to set as the group picture. Must be a publicly accessible URL. |
Response
Returns a ProfilePictureResponse
object. Refer to API.md
.
{
"success": true,
"url": "https://example.com/path/to/new_group_picture.jpg",
"message": "Group picture updated successfully."
}
Examples
curl -X PUT "https://api.wasend.dev/YOUR_SESSION_ID/groups/YOUR_GROUP_ID/picture" \\
-H "Authorization: Bearer YOUR_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{
"url": "https://example.com/path/to/your/image.jpg"
}'
import { WasendClient, WasendConfig, ProfilePictureRequest, ProfilePictureResponse } from '@wasend/core'; // Adjust imports
const config = new WasendConfig({ apiKey: 'YOUR_API_KEY' });
const client = new WasendClient(config);
const sessionId = 'YOUR_SESSION_ID';
const groupId = 'YOUR_GROUP_ID';
async function setGroupPictureExample() {
const requestBody: ProfilePictureRequest = {
url: "https://example.com/path/to/your/image.jpg"
};
try {
const response: ProfilePictureResponse = await client.setGroupPicture(sessionId, groupId, requestBody);
if (response.success) {
console.log('Successfully set group picture. New URL (if provided by response):', response.url);
console.log(response.message);
} else {
console.error('Failed to set group picture:', response.error);
}
} catch (error) {
console.error('Error setting group picture:', error);
}
}
setGroupPictureExample();
const { WasendClient, WasendConfig } = require('@wasend/core'); // Adjust imports
const config = new WasendConfig({ apiKey: 'YOUR_API_KEY' });
const client = new WasendClient(config);
const sessionId = 'YOUR_SESSION_ID';
const groupId = 'YOUR_GROUP_ID';
async function setGroupPictureExample() {
const requestBody = {
url: "https://example.com/path/to/your/image.jpg"
};
try {
const response = await client.setGroupPicture(sessionId, groupId, requestBody);
if (response.success) {
console.log('Successfully set group picture. New URL:', response.url);
console.log(response.message);
} else {
console.error('Failed to set group picture:', response.error);
}
} catch (error) {
console.error('Error setting group picture:', error);
}
}
setGroupPictureExample();
from wasend_sdk import WasendClient, WasendConfig # Adjust imports
config = WasendConfig(api_key='YOUR_API_KEY')
client = WasendClient(config)
session_id = 'YOUR_SESSION_ID'
group_id = 'YOUR_GROUP_ID'
request_body = {
'url': "https://example.com/path/to/your/image.jpg"
}
try:
response = client.set_group_picture(session_id=session_id, group_id=group_id, request=request_body)
if response.success:
print(f"Successfully set group picture. New URL: {response.url}")
print(response.message)
else:
print(f"Failed to set group picture: {response.error}")
except Exception as e:
print(f"Error setting group picture: {e}")
package main
import (
"fmt"
"log"
"github.com/wasenddev/wasend-sdk-go/wasendcore" // Correct import path
)
func main() {
config := &wasendcore.WasendConfig{
ApiKey: "YOUR_API_KEY",
}
client := wasendcore.NewWasendClient(config)
sessionId := "YOUR_SESSION_ID"
groupId := "YOUR_GROUP_ID"
requestBody := &wasendcore.ProfilePictureRequest{
Url: "https://example.com/path/to/your/image.jpg",
}
response, err := client.SetGroupPicture(sessionId, groupId, requestBody) // Assumes method exists
if err != nil {
log.Fatalf("Error setting group picture: %v", err)
}
if response.Success {
fmt.Printf("Successfully set group picture. New URL: %s\\n", response.Url)
fmt.Println(response.Message)
} else {
fmt.Printf("Failed to set group picture: %s\\n", response.Error)
}
}
using System;
using Wasend.Core; // Adjust imports for WasendConfig, ProfilePictureRequest, ProfilePictureResponse
public class SetGroupPictureExample
{
public static void Main(string[] args)
{
var config = new WasendConfig { ApiKey = "YOUR_API_KEY" };
var client = new WasendClient(config);
var sessionId = "YOUR_SESSION_ID";
var groupId = "YOUR_GROUP_ID";
var requestBody = new ProfilePictureRequest
{
Url = "https://example.com/path/to/your/image.jpg"
};
try
{
var response = client.SetGroupPicture(sessionId, groupId, requestBody);
if (response.Success)
{
Console.WriteLine($"Successfully set group picture. New URL: {response.Url}");
Console.WriteLine(response.Message);
}
else
{
Console.WriteLine($"Failed to set group picture: {response.Error}");
}
}
catch (Exception ex)
{
Console.WriteLine($"Error setting group picture: {ex.Message}");
}
}
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpRequest.BodyPublishers;
public class SetGroupPictureHttp {
public static void main(String[] args) {
String sessionId = "YOUR_SESSION_ID";
String groupId = "YOUR_GROUP_ID";
String apiKey = "YOUR_API_KEY";
String baseUrl = "https://api.wasend.dev";
String imageUrl = "https://example.com/path/to/your/image.jpg";
String requestPayload = String.format("{\"url\": \"%s\"}", imageUrl);
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(baseUrl + "/" + sessionId + "/groups/" + groupId + "/picture"))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.PUT(BodyPublishers.ofString(requestPayload))
.build();
try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println("Response status: " + response.statusCode());
System.out.println("Response body: " + response.body());
// Parse JSON response
} catch (Exception e) {
e.printStackTrace();
}
}
}
<?php
$sessionId = 'YOUR_SESSION_ID';
$groupId = 'YOUR_GROUP_ID';
$apiKey = 'YOUR_API_KEY';
$baseUrl = 'https://api.wasend.dev';
$imageUrl = 'https://example.com/path/to/your/image.jpg';
$payload = json_encode(['url' => $imageUrl]);
$ch = curl_init($baseUrl . '/' . $sessionId . '/groups/' . $groupId . '/picture');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json'
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "HTTP status: " . $httpCode . "\\n";
echo "Response: " . $response . "\\n";
// Parse JSON response
?>
require 'net/http'
require 'uri'
require 'json'
session_id = 'YOUR_SESSION_ID'
group_id = 'YOUR_GROUP_ID'
api_key = 'YOUR_API_KEY'
base_url = 'https://api.wasend.dev'
image_url = 'https://example.com/path/to/your/image.jpg'
uri = URI("#{base_url}/#{session_id}/groups/#{group_id}/picture")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = (uri.scheme == 'https')
request = Net::HTTP::Put.new(uri.path, {
'Authorization' => "Bearer #{api_key}",
'Content-Type' => 'application/json'
})
request.body = { url: image_url }.to_json
response_data = http.request(request)
puts "Response status: #{response_data.code}"
puts "Response body: #{response_data.body}"
# Parse JSON response
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
let sessionId = "YOUR_SESSION_ID"
let groupId = "YOUR_GROUP_ID"
let apiKey = "YOUR_API_KEY"
let baseUrl = "https://api.wasend.dev"
let imageUrl = "https://example.com/path/to/your/image.jpg"
guard let url = URL(string: "\(baseUrl)/\(sessionId)/groups/\(groupId)/picture") else {
print("Invalid URL")
exit(1)
}
var request = URLRequest(url: url)
request.httpMethod = "PUT"
request.setValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let payload: [String: Any] = ["url": imageUrl]
do {
request.httpBody = try JSONSerialization.data(withJSONObject: payload, options: [])
} catch {
print("Error serializing JSON: \(error)")
exit(1)
}
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let error = error {
print("Error: \(error)")
return
}
guard let httpResponse = response as? HTTPURLResponse else {
print("Invalid response")
return
}
print("Response status code: \(httpResponse.statusCode)")
if let data = data, let responseBody = String(data: data, encoding: .utf8) {
print("Response body: \(responseBody)")
// Parse JSON response
}
#if os(macOS) || os(Linux)
CFRunLoopStop(CFRunLoopGetCurrent())
#endif
}
task.resume()
#if os(macOS) || os(Linux)
CFRunLoopRun()
#endif
use reqwest::Client;
use serde_json::json;
use tokio;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let session_id = "YOUR_SESSION_ID";
let group_id = "YOUR_GROUP_ID";
let api_key = "YOUR_API_KEY";
let base_url = "https://api.wasend.dev";
let image_url = "https://example.com/path/to/your/image.jpg";
let client = Client::new();
let payload = json!({
"url": image_url
});
let response = client.put(format!("{}/{}/groups/{}/picture", base_url, session_id, group_id))
.bearer_auth(api_key)
.json(&payload)
.send()
.await?;
println!("Status: {}", response.status());
let body = response.text().await?;
println!("Body: {}", body);
// Parse JSON response
Ok(())
}
Response Fields
Field | Type | Description |
---|---|---|
success | boolean | Whether the operation was successful. |
url | string | The URL of the new group picture, if successfully set and returned. |
message | string | A confirmation message. |
error | string | Optional. Error message if the request fails. |
Error Codes
Code | Description |
---|---|
400 | Bad Request - Invalid parameters (e.g., missing url , invalid URL format). |
401 | Unauthorized - Invalid or missing API key. |
403 | Forbidden - User is not an admin or group settings prevent changes. |
404 | Not Found - Session or group not found. |
422 | Unprocessable Entity - Image URL is invalid, inaccessible, or wrong format. |
429 | Too Many Requests - Rate limit exceeded. |
500 | Internal Server Error. |
Notes
- Only group administrators can usually change the group picture, unless group settings (
infoAdminOnly
) allow all participants. - The image provided via the
url
must be publicly accessible (e.g., not behind a login or firewall). - Supported image formats typically include JPEG and PNG. The API might have size or dimension restrictions.
- All group members will be notified of the picture change if successful.
- If you want to remove the group picture, use the Delete Group Picture endpoint.