Get Group Subject
Retrieve the subject (name) of a WhatsApp group
Get Group Subject
Retrieve the current subject (often referred to as the name) of a WhatsApp group.
Endpoint
GET /{sessionId}/groups/{groupId}/subject
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,
"subject": "Project Phoenix Team",
"error": null
}
Examples
curl -X GET "https://api.wasend.dev/{sessionId}/groups/{groupId}/subject" \
-H "Authorization: Bearer YOUR_API_KEY"
import { WasendClient } from '@wasend/core';
// Assuming a response structure for this endpoint
interface GetGroupSubjectResponse {
success: boolean;
subject?: string;
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 getGroupSubject exists in the SDK for this endpoint
const result: GetGroupSubjectResponse = await client.getGroupSubject(sessionId, groupId);
if (result.success && result.subject) {
console.log('Group subject:', result.subject);
} else {
console.error('Failed to get group subject:', 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 getGroupSubject exists
client.getGroupSubject(sessionId, groupId)
.then(result => {
if (result.success && result.subject) {
console.log('Group subject:', result.subject);
} else {
console.error('Failed to get group subject:', 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_subject exists and returns an object
result = client.get_group_subject(
session_id=session_id,
group_id=group_id
)
if result.success and result.subject:
print(f"Group subject: {result.subject}")
else:
print(f"Failed to get group subject: {result.error}")
package main
import (
"fmt"
"log"
"github.com/wasenddev/wasend-sdk-go/wasendcore"
)
func StringPtr(s string) *string { return &s }
// Assuming a response structure for this endpoint
type GetGroupSubjectResponse struct {
Success bool `json:"success"`
Subject *string `json:"subject,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 GetGroupSubject exists in the SDK for this endpoint
// and it unmarshals into GetGroupSubjectResponse. For example purposes only.
// This is a placeholder for an actual SDK call or direct HTTP request and unmarshalling.
fmt.Println("Go example needs actual HTTP call or SDK support for this custom endpoint structure.")
// result, err := client.GetGroupSubject(sessionId, groupId)
// if err != nil {
// log.Fatalf("Error getting group subject: %v", err)
// }
// if result.Success && result.Subject != nil {
// fmt.Printf("Group subject: %s\n", *result.Subject)
// } else if result.Error != nil {
// fmt.Printf("Failed to get group subject: %s\n", *result.Error)
// }
}
using Wasend.Core; // Assuming Wasend.Core for WasendClient and WasendConfig
using System;
using System.Threading.Tasks;
using System.Text.Json.Serialization;
// Assuming custom response structure for this endpoint
public class GetGroupSubjectApiResponse
{
[JsonPropertyName("success")]
public bool Success { get; set; }
[JsonPropertyName("subject")]
public string Subject { 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 GetGroupSubject exists or a generic HTTP call is made
// and deserialized into GetGroupSubjectApiResponse.
// This is a placeholder for an actual SDK call or direct HTTP request and deserialization.
Console.WriteLine(".NET example needs actual HTTP call and deserialization or SDK support for this custom endpoint structure.");
// var result = client.GetGroupSubject(sessionId, groupId); // Hypothetical synchronous call
// if (result.Success)
// {
// Console.WriteLine($"Group subject: {result.Subject}");
// }
// else
// {
// Console.WriteLine($"Failed to get group subject: {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 + "/subject"))
.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}/subject";
$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}/subject")
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)/subject")!
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/{}/subject", 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 |
subject | string | The current subject (name) of the group. Null if error. |
error | string | Optional. Error message if success is false . |
Error Codes
Code | Description |
---|---|
400 | Bad Request - Invalid parameters |
401 | Unauthorized - Invalid or missing API key |
403 | Forbidden - Not authorized to get subject |
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 subject.
- The subject is also commonly referred to as the group name.
- The subject may be empty if not set, though WhatsApp usually requires a subject for groups.
- The subject has a maximum length (typically 25 characters on WhatsApp, though the API may not enforce this on retrieval).
- The subject is visible to all group members.
- The subject can be changed by group admins using the Set Group Subject endpoint.