Add Group Participants
Add new participants to a WhatsApp group
Add Group Participants
Add new participants to a specific WhatsApp group.
Endpoint
POST /{sessionId}/groups/{groupId}/participants/add
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
Field | Type | Required | Description |
---|---|---|---|
participants | string[] | Yes | List of participant IDs (phone numbers) |
notify | boolean | No | Whether to notify participants (default: true) |
Response
{
"success": true,
"data": {
"added": [
{
"id": "string", // Participant JID
"reason": "string" // e.g., "SUCCESS"
}
],
"failed": [
{
"id": "string", // Participant JID
"reason": "string" // e.g., "NOT_FOUND", "ALREADY_IN_GROUP"
}
]
}
}
Examples
curl -X POST "https://api.wasend.dev/{sessionId}/groups/{groupId}/participants/add" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"participants": [
"+1234567890",
"+0987654321"
],
"notify": true
}'
import { WasendClient } from '@wasend/core';
const client = new WasendClient({
apiKey: 'YOUR_API_KEY',
baseUrl: 'https://api.wasend.dev'
});
// Add participants to group
const result = await client.addGroupParticipants(sessionId, groupId, {
participants: [
"+1234567890",
"+0987654321"
],
notify: true
});
console.log('API Response:', result);
const { WasendClient } = require('@wasend/core');
const client = new WasendClient({
apiKey: 'YOUR_API_KEY',
baseUrl: 'https://api.wasend.dev'
});
// Add participants to group
const result = await client.addGroupParticipants(sessionId, groupId, {
participants: [
"+1234567890",
"+0987654321"
],
notify: true
});
console.log('API Response:', result);
from wasend import WasendClient
client = WasendClient(
api_key='YOUR_API_KEY',
base_url='https://api.wasend.dev'
)
# Add participants to group
result = client.add_group_participants(
session_id=sessionId,
group_id=groupId,
participants=[
"+1234567890",
"+0987654321"
],
notify=True
)
print(result)
package main
import (
"fmt"
"log"
"github.com/wasenddev/wasend-sdk-go/wasendcore"
)
func StringPtr(s string) *string { return &s }
func BoolPtr(b bool) *bool { return &b }
func main() {
client := wasendcore.NewWasendClient(&wasendcore.WasendConfig{
ApiKey: StringPtr("YOUR_API_KEY"),
BaseUrl: StringPtr("https://api.wasend.dev"),
})
// Add participants to group
result, err := client.AddGroupParticipants(sessionId, groupId, &wasendcore.ParticipantsRequest{
Participants: []string{
"+1234567890",
"+0987654321",
},
Notify: BoolPtr(true),
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("API Response: %+v\n", result)
}
using Wasend.Core;
using System.Collections.Generic;
var config = new WasendConfig
{
ApiKey = "YOUR_API_KEY"
};
var client = new WasendClient(config);
// Add participants to group
var result = client.AddGroupParticipants(sessionId, groupId, new ParticipantsRequest
{
Participants = new List<string> { "+1234567890", "+0987654321" },
Notify = true
});
System.Console.WriteLine($"API Response: {result}");
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import org.json.JSONObject;
import org.json.JSONArray;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient httpClient = HttpClient.newHttpClient();
String sessionId = "yourSessionId";
String groupId = "yourGroupId";
JSONObject requestBody = new JSONObject();
JSONArray participantsArray = new JSONArray();
participantsArray.put("+1234567890");
participantsArray.put("+0987654321");
requestBody.put("participants", participantsArray);
requestBody.put("notify", true);
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.wasend.dev/" + sessionId + "/groups/" + groupId + "/participants/add"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(requestBody.toString()))
.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}/participants/add";
$data = [
'participants' => [
'+1234567890',
'+0987654321'
],
'notify' => true
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json'
]);
$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}/participants/add")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true # For HTTPS
request = Net::HTTP::Post.new(uri.request_uri)
request['Authorization'] = 'Bearer YOUR_API_KEY'
request['Content-Type'] = 'application/json'
request.body = {
participants: [
"+1234567890",
"+0987654321"
],
notify: true
}.to_json
response = http.request(request)
puts "Response: #{response.body}"
import Foundation
let sessionId = "yourSessionId"
let groupId = "yourGroupId"
let url = URL(string: "https://api.wasend.dev/\(sessionId)/groups/\(groupId)/participants/add")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer YOUR_API_KEY", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let body: [String: Any] = [
"participants": [
"+1234567890",
"+0987654321"
],
"notify": true
]
request.httpBody = try? JSONSerialization.data(withJSONObject: body)
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;
use serde_json::json;
#[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/{}/participants/add", session_id, group_id);
let response = client
.post(&url)
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "application/json")
.json(&json!({
"participants": [
"+1234567890",
"+0987654321"
],
"notify": true
}))
.send()
.await?
.text()
.await?;
println!("Response: {}", response);
Ok(())
}
Response Fields
Field | Type | Description |
---|---|---|
success | boolean | Whether the operation was successful |
data | object | Object containing lists of added and failed participants |
data.added | array | List of successfully added participants |
data.failed | array | List of participants that could not be added |
Added/Failed Participant Object
Field | Type | Description |
---|---|---|
id | string | Participant's JID |
reason | string | Reason for success or failure (e.g., "SUCCESS", "ALREADY_IN_GROUP") |
Error Codes
Code | Description |
---|---|
400 | Bad Request - Invalid parameters |
401 | Unauthorized - Invalid or missing API key |
403 | Forbidden - Not authorized to add participants |
404 | Not Found - Session or group not found |
429 | Too many requests - Rate limit exceeded |
500 | Internal server error |
Notes
- Only group admins can add new participants
- Phone numbers must be in international format
- You can add multiple participants in a single request
- The group must not be full (maximum 1024 participants)
- Some participants may not be added if they have blocked the group or have privacy settings preventing them from being added