Get Group Settings
Retrieve the current settings of a WhatsApp group
Get Group Settings
Retrieve the current configuration settings of a WhatsApp group, such as whether only admins can send messages or edit group info.
Endpoint
GET /{sessionId}/groups/{groupId}/settings
Headers
Name | Type | Required | Description |
---|---|---|---|
Authorization | string | Yes | Bearer token for authentication |
Path Parameters
Parameter | Type | Required | Description |
---|---|---|---|
sessionId | string | Yes | The session ID |
groupId | string | Yes | The group ID |
Response
{
"success": true,
"settings": {
"infoAdminOnly": true, // Corresponds to 'restrict' in some contexts
"messagesAdminOnly": false, // Corresponds to 'announce' in some contexts
"ephemeralDuration": 0,
"noFrequentlyForwarded": true
},
"error": null
}
Examples
curl -X GET "https://api.wasend.dev/{sessionId}/groups/{groupId}/settings" \
-H "Authorization: Bearer YOUR_API_KEY"
import { WasendClient } from '@wasend/core';
// Assuming a response structure like the one documented in this file for this specific endpoint.
// API.md has getGroupInfoAdminOnly and getGroupMessagesAdminOnly which return SettingsSecurityChangeInfo.
// This /settings endpoint seems custom.
interface GroupSettings {
infoAdminOnly: boolean;
messagesAdminOnly: boolean;
ephemeralDuration: number;
noFrequentlyForwarded: boolean;
}
interface GetGroupSettingsResponse {
success: boolean;
settings?: GroupSettings;
error?: string;
}
const client = new WasendClient({
apiKey: 'YOUR_API_KEY',
baseUrl: 'https://api.wasend.dev'
});
const sessionId = "yourSessionId";
const groupId = "yourGroupId";
async function run() {
try {
// Assuming a method getGroupSettings exists in the SDK for this endpoint
const result: GetGroupSettingsResponse = await client.getGroupSettings(sessionId, groupId);
if (result.success && result.settings) {
console.log('Group settings:', result.settings);
console.log('Info Admin Only:', result.settings.infoAdminOnly);
console.log('Messages Admin Only:', result.settings.messagesAdminOnly);
} else {
console.error('Failed to get group settings:', result.error);
}
} catch (error) {
console.error('Error:', error);
}
}
run();
const { WasendClient } = require('@wasend/core');
const client = new WasendClient({
apiKey: 'YOUR_API_KEY',
baseUrl: 'https://api.wasend.dev'
});
const sessionId = "yourSessionId";
const groupId = "yourGroupId";
// Assuming a method getGroupSettings exists
client.getGroupSettings(sessionId, groupId)
.then(result => {
if (result.success && result.settings) {
console.log('Group settings:', result.settings);
} else {
console.error('Failed to get group settings:', result.error);
}
})
.catch(error => {
console.error('Error:', error);
});
from wasend import WasendClient
client = WasendClient(
api_key='YOUR_API_KEY',
base_url='https://api.wasend.dev'
)
session_id = "yourSessionId"
group_id = "yourGroupId"
# Assuming a method get_group_settings exists
result = client.get_group_settings(
session_id=session_id,
group_id=group_id
)
if result.success and result.settings:
print(f"Group settings: {result.settings}")
print(f"Info Admin Only: {result.settings.get('infoAdminOnly')}")
else:
print(f"Failed to get group settings: {result.error}")
package main
import (
"fmt"
"log"
"github.com/wasenddev/wasend-sdk-go/wasendcore"
)
func StringPtr(s string) *string { return &s }
// Assuming custom response structure for this endpoint
type GroupSettings struct {
InfoAdminOnly bool `json:"infoAdminOnly"`
MessagesAdminOnly bool `json:"messagesAdminOnly"`
EphemeralDuration int `json:"ephemeralDuration"`
NoFrequentlyForwarded bool `json:"noFrequentlyForwarded"`
}
type GetGroupSettingsResponse struct {
Success bool `json:"success"`
Settings *GroupSettings `json:"settings,omitempty"`
Error *string `json:"error,omitempty"`
}
func main() {
client := wasendcore.NewWasendClient(&wasendcore.WasendConfig{
ApiKey: StringPtr("YOUR_API_KEY"),
BaseUrl: StringPtr("https://api.wasend.dev"),
})
sessionId := "yourSessionId"
groupId := "yourGroupId"
// Assuming a method GetGroupSettings exists in the SDK
// and it unmarshals into a GetGroupSettingsResponse struct.
// For simplicity, this example does not show the actual HTTP call and unmarshalling code for Go.
// Instead, it refers to a hypothetical SDK method.
// result, err := client.GetGroupSettings(sessionId, groupId)
// if err != nil {
// log.Fatalf("Error getting group settings: %v", err)
// }
// if result.Success && result.Settings != nil {
// fmt.Printf("Group settings: %+v\n", result.Settings)
// } else if result.Error != nil {
// fmt.Printf("Failed to get group settings: %s\n", *result.Error)
// }
// Placeholder for direct HTTP call if SDK method is not available for this custom structure
fmt.Println("Go example needs actual HTTP call or SDK support for this custom endpoint structure.")
}
using Wasend.Core; // Assuming Wasend.Core for WasendClient and WasendConfig
using System;
using System.Threading.Tasks;
using System.Text.Json.Serialization; // For custom response mapping if needed
// Assuming custom response structure for this endpoint
public class GroupSettingsResponseData
{
[JsonPropertyName("infoAdminOnly")]
public bool InfoAdminOnly { get; set; }
[JsonPropertyName("messagesAdminOnly")]
public bool MessagesAdminOnly { get; set; }
[JsonPropertyName("ephemeralDuration")]
public int EphemeralDuration { get; set; }
[JsonPropertyName("noFrequentlyForwarded")]
public bool NoFrequentlyForwarded { get; set; }
}
public class GetGroupSettingsApiResponse
{
[JsonPropertyName("success")]
public bool Success { get; set; }
[JsonPropertyName("settings")]
public GroupSettingsResponseData Settings { get; set; }
[JsonPropertyName("error")]
public string Error { get; set; }
}
public class Example
{
public static async Task Main(string[] args)
{
var config = new WasendConfig
{
ApiKey = "YOUR_API_KEY"
};
var client = new WasendClient(config);
string sessionId = "yourSessionId";
string groupId = "yourGroupId";
// Assuming a method GetGroupSettings exists or a generic HTTP call is made
// and deserialized into GetGroupSettingsApiResponse.
// For this example, direct SDK call is hypothetical.
// var result = client.GetGroupSettings(sessionId, groupId);
// Placeholder for actual SDK call or direct HTTP call
Console.WriteLine(".NET example needs actual HTTP call and deserialization or SDK support for this custom endpoint structure.");
// if (result.Success && result.Settings != null)
// {
// Console.WriteLine($"Group settings InfoAdminOnly: {result.Settings.InfoAdminOnly}");
// }
// else
// {
// Console.WriteLine($"Failed to get group settings: {result.Error}");
// }
}
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient httpClient = HttpClient.newHttpClient();
String sessionId = "yourSessionId";
String groupId = "yourGroupId";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.wasend.dev/" + sessionId + "/groups/" + groupId + "/settings"))
.header("Authorization", "Bearer YOUR_API_KEY")
.GET()
.build();
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println("Response: " + response.body());
}
}
<?php
$sessionId = 'yourSessionId';
$groupId = 'yourGroupId';
$url = "https://api.wasend.dev/{$sessionId}/groups/{$groupId}/settings";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_API_KEY'
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
require 'net/http';
require 'uri';
require 'json';
session_id = 'yourSessionId'
group_id = 'yourGroupId'
uri = URI("https://api.wasend.dev/#{session_id}/groups/#{group_id}/settings")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true # For HTTPS
request_obj = Net::HTTP::Get.new(uri.request_uri)
request_obj['Authorization'] = 'Bearer YOUR_API_KEY'
response = http.request(request_obj)
puts "Response: #{response.body}"
import Foundation
let sessionId = "yourSessionId"
let groupId = "yourGroupId"
let url = URL(string: "https://api.wasend.dev/\(sessionId)/groups/\(groupId)/settings")!
var request = URLRequest(url: url)
request.httpMethod = "GET"
request.setValue("Bearer YOUR_API_KEY", forHTTPHeaderField: "Authorization")
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data, let responseString = String(data: data, encoding: .utf8) {
print("Response: \(responseString)")
}
}
task.resume()
use reqwest::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
let session_id = "yourSessionId";
let group_id = "yourGroupId";
let url = format!("https://api.wasend.dev/{}/groups/{}/settings", session_id, group_id);
let response_text = client
.get(&url)
.header("Authorization", "Bearer YOUR_API_KEY")
.send()
.await?
.text()
.await?;
println!("Response: {}", response_text);
Ok(())
}
Response Fields
Field | Type | Description |
---|---|---|
success | boolean | Whether the operation was successful |
settings | object | The group settings object. Null if error. |
error | string | Optional. Error message if success is false . |
Settings Object Fields
Field | Type | Description |
---|---|---|
infoAdminOnly | boolean | true if only admins can edit group info (name, description, picture). Alias: restrict . |
messagesAdminOnly | boolean | true if only admins can send messages. Alias: announce . |
ephemeralDuration | number | Disappearing message duration in seconds (0 means disabled). |
noFrequentlyForwarded | boolean | true if frequently forwarded messages are blocked/restricted in the group. |
Error Codes
Code | Description |
---|---|
400 | Bad Request - Invalid parameters |
401 | Unauthorized - Invalid or missing API key |
403 | Forbidden - Not authorized to get settings |
404 | Not Found - Session or group not found |
429 | Too many requests - Rate limit exceeded |
500 | Internal server error |
Notes
- You must be a member of the group to get its settings.
- The
infoAdminOnly
setting controls who can change the group subject, description, and icon. - The
messagesAdminOnly
setting controls who can send messages to the group. ephemeralDuration
refers to the disappearing messages setting. A value of0
typically means messages do not disappear.- These settings generally reflect what is configurable within WhatsApp group settings.
- Only group admins can typically change these settings using the Update Group Settings endpoint.