Learn how to add or remove participants “automatically” to WhatsApp groups. Boost your brand and take your sales to the next level.
Following our WhatsApp group tips articles series with Wassenger’s API, today we are going to show you how you can boost your sales by adding or removing participants to groups and help you categorize your customers into different groups to keep your company up-to-date and optimized.
🤩 🤖 Wassenger is a complete API solution for WhatsApp. Sign up for a 7-day free trial and get started in minutes!
Requirements
- Have a WhatsApp number already linked to the platform and online.
- Get your number unique ID given in Wassenger from here.
- Group WhatsApp ID (WID) that you can find in two ways:
How to obtain the Group WhatsApp ID
You can obtain the Group WhatsApp ID by using one of these methods:
- Web: go to number’s settings > Groups > Copy the Group WID.
- API: query the available groups in your number using this endpoint.
API endpoint
We will use the following API endpoint to manage the group participants:
Add participants
Prepare the request
Target API URL using the POST method to add participants
https://api.wassenger.com/v1/devices/{deviceId}/groups/{groupId}/participants
Required HTTPS headers > Obtain your API key here
Content-Type: application/json
Token: $API_TOKEN
Use body in JSON format
{
"participants": [
{
"phone": "+12345678900",
"admin": true
},
{
"phone": "+12345678901",
"admin": false
}
]
}
Add participants using code
Explore how to use the code in your browser without installing any software.
Also, you can find different languages you can test on Replit.com:
# Examples requires to have installed requests Python package.
# Install it by running: pip install requests
import requests
url = "https://api.wassenger.com/v1/devices/61b37a069cba0c15d6/groups/1203630298136@g.us/participants"
payload = { "participants": [
{
"phone": "+12345678909",
"admin": True
},
{
"phone": "+12345678901",
"admin": False
}
] }
headers = {
"Content-Type": "application/json",
"Token": "API_TOKEN_GOES_HERE"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.wassenger.com/v1/devices/61b37a069cba0c15d6C/groups/12036302981363@g.us/participants',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode([
'participants' => [
[
'phone' => '+12345678909',
'admin' => null,
],
[
'phone' => '+12345678901',
'admin' => null,
],
],
]),
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Token: API_TOKEN_GOES_HERE',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo 'cURL Error #:' . $err;
} else {
echo $response;
}
// Examples requires to have installed pecl_http package, a simple and elegant HTTP client for PHP.
// Install it by running: pecl install pecl_http
// More information: https://pecl.php.net/package/pecl_http/3.2.0
<?php
$client = new http\Client();
$request = new http\Client\Request();
$body = new http\Message\Body();
$body->append(
json_encode([
'participants' => [
[
'phone' => '+12345678901',
'admin' => null,
],
[
'phone' => '+12345678902',
'admin' => null,
],
],
])
);
$request->setRequestUrl(
'https://api.wassenger.com/v1/devices/61b37a069cba0c15d6c/groups/12036302981363@g.us/participants'
);
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'Content-Type' => 'application/json',
'Token' => 'API_TOKEN_GOES_HERE',
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
package main
import(
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url:= "https://api.wassenger.com/v1/devices/61b37a069cba0c15d6c/groups/120363029813@g.us/participants"
payload:= strings.NewReader("{\"participants\":[{\"phone\":\"+12345678901\", \"admin\":true}, {\"phone\":\"+12345678902\", \"admin\":false}]}")
req, _:= http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Token", "API_TOKEN_GOES_HERE")
res, _:= http.DefaultClient.Do(req)
defer res.Body.Close()
body, _:= io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
// This code requires you to have installed RestSharp package.
// Documentation: https://restsharp.dev
// Installation: https://www.nuget.org/packages/RestSharp
var client = new RestClient("https://api.wassenger.com/v1/devices/61b37a069cba0c15d6c/groups/1203630298136@g.us/participants");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Token", "API_TOKEN_GOES_HERE");
request.AddParameter("application/json", "{\"participants\":[{\"phone\":\"+12345678901\", \"admin\":true}, {\"phone\":\"+12345678902\", \"admin\":false}]}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
require 'uri' require 'net/http'
url = URI("https://api.wassenger.com/v1/devices/61b37a069cba0c15d6c/groups/12036302981363@g.us/participants")
http = Net::HTTP.new(url.host, url.port) http.use_ssl = true
request = Net::HTTP::Post.new(url) request["Content-Type"] = 'application/json' request["Token"] = 'API_TOKEN_GOES_HERE' request.body = "{\"participants\":[{\"phone\":\"+12345678901\",\"admin\":true},{\"phone\":\"+12345678902\",\"admin\":false}]}"
response = http.request(request) puts response.read_body
// This code requires you to have installed Unirest package.
// Documentation: https://kong.github.io/unirest-java/#requests
// Installation: http://kong.github.io/unirest-java/
HttpResponse<String> response = Unirest.post("https://api.wassenger.com/v1/devices/61b37a069cba0c15d6c897/groups/1203630298136@g.us/participants")
.header("Content-Type", "application/json")
.header("Token", "API_TOKEN_GOES_HERE")
.body("{\"participants\":[{\"phone\":\"+12345678901\", \"admin\":true}, {\"phone\":\"+12345678902\", \"admin\":false}]}")
.asString();
🤩 🤖 Wassenger is a complete communication platform and API solution for WhatsApp. Explore more than 100+ API use cases and automate anything on WhatsApp by signing up for a free trial and getting started in minutes**!**
Remove participants
Prepare the request
Target API URL using the DELETE method to remove participants
https://api.wassenger.com/v1/devices/{deviceId}/groups/{groupId}/participants
Required HTTPS headers > Obtain your API key here
Content-Type: application/json
Token: $API_TOKEN
Use body in JSON format
['+12345678900', '+12345678901'];
Explore how to use the code in your browser without installing any software.
Also, you can find different languages you can test on Replit.com:
# Examples requires to have installed requests Python package.
# Install it by running: pip install requests
import requests
url = "https://api.wassenger.com/v1/devices/61b37a069cba0c15d6c/groups/12036302981363@g.us/participants"
payload = ["+12345678901", "+12345678902"]
headers = {
"Content-Type": "application/json",
"Token": "API_TOKEN_GOES_HERE"
}
response = requests.delete(url, json=payload, headers=headers)
print(response.json())
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.wassenger.com/v1/devices/61b37a069cba0c15d6c/groups/1203630298136@g.us/participants",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_POSTFIELDS => json_encode([
'+12345678901',
'+12345678902'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Token: API_TOKEN_GOES_HERE"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if($err) {
echo "cURL Error #:".$err;
} else {
echo $response;
package main
import(
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url:= "https://api.wassenger.com/v1/devices/61b37a069cba0c15d6c89/groups/1203630298136@g.us/participants"
payload:= strings.NewReader("[\"+12345678901\", \"+12345678902\"]")
req, _:= http.NewRequest("DELETE", url, payload)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Token", "API_TOKEN_GOES_HERE")
res, _:= http.DefaultClient.Do(req)
defer res.Body.Close()
body, _:= io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
// This code requires you to have installed RestSharp package.
// Documentation: https://restsharp.dev
// Installation: https://www.nuget.org/packages/RestSharp
var client = new RestClient("https://api.wassenger.com/v1/devices/61b37a069cba0c15d6c/groups/12036302981363@g.us/participants");
var request = new RestRequest(Method.DELETE);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Token", "API_TOKEN_GOES_HERE");
request.AddParameter("application/json", "[\"+12345678901\", \"+12345678902\"]", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
require 'uri' require 'net/http'
url = URI("https://api.wassenger.com/v1/devices/61b37a069cba0c15d6c8/groups/12036302981363@g.us/participants")
http = Net::HTTP.new(url.host, url.port) http.use_ssl = true
request = Net::HTTP::Delete.new(url) request["Content-Type"] = 'application/json' request["Token"] = 'API_TOKEN_GOES_HERE' request.body = "[\"+12345678901\",\"+12345678902\"]"
response = http.request(request) puts response.read_body
// This code requires you to have installed Unirest package.
// Documentation: https://kong.github.io/unirest-java/#requests
// Installation: http://kong.github.io/unirest-java/
HttpResponse<String> response = Unirest.delete("https://api.wassenger.com/v1/devices/61b37a069cba0c15d6c/groups/12036302981363@g.us/participants")
.header("Content-Type", "application/json")
.header("Token", "API_TOKEN_GOES_HERE")
.body("[\"+12345678901\", \"+12345678902\"]")
.asString();
🖥️ Looking for a code example? Go to the API live tester and get ready-to-use code examples in 15+ programming languages, including Python, JavaScript, PHP, C#, Java, Ruby, Go, Powershell, cURL and more.
Live API testing
You can live-test and play with the API directly from your browser.
Once you are done testing, get the auto-generated code example in your preferred programming language and you will be ready to go.
🤩 🤖 Wassenger is a complete communication platform and API solution for WhatsApp. Explore more than 100+ API use cases and automate anything on WhatsApp by signing up for a free trial and getting started in minutes**!**
FAQ
How can I manage contacts in a group?
You just have to send multiple API requests, one per target group.
For instance, if you want to update 10 groups, you should send 10 independent HTTPS requests to the API and one per method (POST, PATCH or DELETE).
There is no option to manage different groups in a single API request.
How many contacts I can manage at once?
To prevent processing issues or errors, it is not recommended to manage more than 10 participants at a time per API request (add, delete, promote or demote).
Further useful resources
For more details about the endpoint API, please check our documentation. You will find all the details about the accepted request params, possible success or error responses and ready-to-use code examples in multiple programming languages.







