Wasend

Demote Group Participants

Demote admin participants to regular members in a WhatsApp group

Demote Group Participants

Demote admin participants to regular members in a specific WhatsApp group.

Endpoint

POST /{sessionId}/groups/{groupId}/participants/demote

Headers

NameTypeRequiredDescription
AuthorizationstringYesBearer token for authentication
Content-TypestringYesapplication/json

Path Parameters

ParameterTypeRequiredDescription
sessionIdstringYesThe session ID
groupIdstringYesThe group ID

Request Body

FieldTypeRequiredDescription
participantsstring[]YesList of participant phone numbers to demote
notifybooleanNoWhether to notify participants (default: true)

Response

{
  "success": true,
  "data": {
    "demoted": [
      {
        "id": "string", // Participant JID
        "reason": "string" // e.g., "SUCCESS"
      }
    ],
    "failed": [
      {
        "id": "string", // Participant JID
        "reason": "string" // e.g., "NOT_ADMIN", "NOT_FOUND"
      }
    ]
  }
}

Examples

curl -X POST "https://api.wasend.dev/{sessionId}/groups/{groupId}/participants/demote" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "participants": [
      "+1234567890",
      "+0987654321"
    ],
    "notify": true
  }'
import { WasendClient, ParticipantsRequest } from '@wasend/core';

const client = new WasendClient({
  apiKey: 'YOUR_API_KEY',
  baseUrl: 'https://api.wasend.dev'
});

const sessionId = "yourSessionId";
const groupId = "yourGroupId";

// Demote participants from admin
const request: ParticipantsRequest = {
  participants: [
    "+1234567890",
    "+0987654321"
  ],
  notify: true // Optional, defaults to true
};
const result = await client.demoteGroupParticipants(sessionId, groupId, request);

console.log('API Response:', result);
const { WasendClient } = require('@wasend/core');

const client = new WasendClient({
  apiKey: 'YOUR_API_KEY',
  baseUrl: 'https://api.wasend.dev'
});

const sessionId = "yourSessionId";
const groupId = "yourGroupId";

// Demote participants from admin
const result = await client.demoteGroupParticipants(sessionId, groupId, {
  participants: [
    "+1234567890",
    "+0987654321"
  ],
  notify: true // Optional, defaults to true
});

console.log('API Response:', result);
from wasend import WasendClient

client = WasendClient(
    api_key='YOUR_API_KEY',
    base_url='https://api.wasend.dev'
)

session_id = "yourSessionId"
group_id = "yourGroupId"

# Demote participants from admin
result = client.demote_group_participants(
    session_id=session_id,
    group_id=group_id,
    request={
        'participants': [
            "+1234567890",
            "+0987654321"
        ],
        'notify': True  # Optional, defaults to 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"),
	})

	sessionId := "yourSessionId"
	groupId := "yourGroupId"

	// Demote participants from admin
	result, err := client.DemoteGroupParticipants(sessionId, groupId, &wasendcore.ParticipantsRequest{
		Participants: []string{
			"+1234567890",
			"+0987654321",
		},
		Notify: BoolPtr(true), // Optional, defaults to 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);

string sessionId = "yourSessionId";
string groupId = "yourGroupId";

// Demote participants from admin
var request = new ParticipantsRequest
{
    Participants = new List<string> { "+1234567890", "+0987654321" },
    Notify = true // Optional, defaults to true
};
var result = client.DemoteGroupParticipants(sessionId, groupId, request);

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); // Optional, defaults to true

        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create("https://api.wasend.dev/" + sessionId + "/groups/" + groupId + "/participants/demote"))
                .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/demote";

$data = [
    'participants' => [
        '+1234567890',
        '+0987654321'
    ],
    'notify' => true // Optional, defaults to 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/demote")

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true # For HTTPS

request_obj = Net::HTTP::Post.new(uri.request_uri)
request_obj['Authorization'] = 'Bearer YOUR_API_KEY'
request_obj['Content-Type'] = 'application/json'
request_obj.body = {
  participants: [
    "+1234567890",
    "+0987654321"
  ],
  notify: true # Optional, defaults to true
}.to_json

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)/participants/demote")!

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 // Optional, defaults to 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/demote", 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 // Optional, defaults to true
        }))
        .send()
        .await?
        .text()
        .await?;

    println!("Response: {}", response);
    Ok(())
}

Response Fields

FieldTypeDescription
successbooleanWhether the operation was successful overall
dataobjectObject containing lists of demoted and failed participants
data.demotedarrayList of successfully demoted Participant Status objects
data.failedarrayList of Participant Status objects that could not be demoted

Participant Status Object

FieldTypeDescription
idstringParticipant's JID
reasonstringReason for success or failure (e.g., "SUCCESS", "NOT_ADMIN")

Error Codes

CodeDescription
400Bad Request - Invalid parameters
401Unauthorized - Invalid or missing API key
403Forbidden - Not authorized to demote participants
404Not Found - Session or group not found
429Too many requests - Rate limit exceeded
500Internal server error

Notes

  • Only group admins can demote other admins.
  • You cannot demote the group owner.
  • You can demote multiple participants in a single request.
  • Demoted participants (if notify is true) will be notified of their new role.
  • Demoted participants will lose admin privileges.
  • The group must have at least one admin remaining after demotion.
  • Phone numbers must be in international format (e.g. +1234567890).