Revoke Group Invite Link
Revoke the current invite link of a WhatsApp group and generate a new one.
Revoke Group Invite Link
Revoke the current invite link for a WhatsApp group. This invalidates the old link and generates a new one.
Endpoint
POST /{sessionId}/groups/{groupId}/invite-link/revoke
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 |
Request Body
This endpoint does not require a request body.
Response
Returns an InviteLinkResponse
object. Refer to API.md
.
{
"success": true,
"inviteLink": "https://chat.whatsapp.com/NEW_INVITE_LINK_CODE",
"expiresAt": "2023-12-31T23:59:59Z"
}
Examples
curl -X POST "https://api.wasend.dev/YOUR_SESSION_ID/groups/YOUR_GROUP_ID/invite-link/revoke" \\
-H "Authorization: Bearer YOUR_API_KEY"
import { WasendClient, WasendConfig, InviteLinkResponse } from '@wasend/core'; // Adjust imports
const config = new WasendConfig({ apiKey: 'YOUR_API_KEY' });
const client = new WasendClient(config);
const sessionId = 'YOUR_SESSION_ID';
const groupId = 'YOUR_GROUP_ID';
async function revokeInviteLinkExample() {
try {
const response: InviteLinkResponse = await client.revokeGroupInviteLink(sessionId, groupId);
if (response.success) {
console.log('New invite link:', response.inviteLink);
console.log('Expires at:', response.expiresAt);
} else {
console.error('Failed to revoke invite link:', response.error);
}
} catch (error) {
console.error('Error revoking invite link:', error);
}
}
revokeInviteLinkExample();
const { WasendClient, WasendConfig } = require('@wasend/core'); // Adjust imports
const config = new WasendConfig({ apiKey: 'YOUR_API_KEY' });
const client = new WasendClient(config);
const sessionId = 'YOUR_SESSION_ID';
const groupId = 'YOUR_GROUP_ID';
async function revokeInviteLinkExample() {
try {
const response = await client.revokeGroupInviteLink(sessionId, groupId);
if (response.success) {
console.log('New invite link:', response.inviteLink);
console.log('Expires at:', response.expiresAt);
} else {
console.error('Failed to revoke invite link:', response.error);
}
} catch (error) {
console.error('Error revoking invite link:', error);
}
}
revokeInviteLinkExample();
from wasend_sdk import WasendClient, WasendConfig # Adjust imports
config = WasendConfig(api_key='YOUR_API_KEY')
client = WasendClient(config)
session_id = 'YOUR_SESSION_ID'
group_id = 'YOUR_GROUP_ID'
try:
response = client.revoke_group_invite_link(session_id=session_id, group_id=group_id)
if response.success:
print(f"New invite link: {response.invite_link}")
print(f"Expires at: {response.expires_at}")
else:
print(f"Failed to revoke invite link: {response.error}")
except Exception as e:
print(f"Error revoking invite link: {e}")
package main
import (
"fmt"
"log"
"github.com/wasenddev/wasend-sdk-go/wasendcore" // Correct import path
)
func main() {
config := &wasendcore.WasendConfig{
ApiKey: "YOUR_API_KEY",
}
client := wasendcore.NewWasendClient(config)
sessionId := "YOUR_SESSION_ID"
groupId := "YOUR_GROUP_ID"
response, err := client.RevokeGroupInviteLink(sessionId, groupId) // Assumes method exists
if err != nil {
log.Fatalf("Error revoking invite link: %v", err)
}
if response.Success {
fmt.Printf("New invite link: %s\\n", response.InviteLink)
fmt.Printf("Expires at: %s\\n", response.ExpiresAt)
} else {
fmt.Printf("Failed to revoke invite link: %s\\n", response.Error)
}
}
using System;
using Wasend.Core; // Adjust imports for WasendConfig and InviteLinkResponse
public class RevokeInviteLinkExample
{
public static void Main(string[] args) // Can be async if other async ops are needed
{
var config = new WasendConfig { ApiKey = "YOUR_API_KEY" };
var client = new WasendClient(config);
var sessionId = "YOUR_SESSION_ID";
var groupId = "YOUR_GROUP_ID";
try
{
// Assumes RevokeGroupInviteLink is a synchronous method in the .NET SDK
var response = client.RevokeGroupInviteLink(sessionId, groupId);
if (response.Success)
{
Console.WriteLine($"New invite link: {response.InviteLink}");
Console.WriteLine($"Expires at: {response.ExpiresAt}");
}
else
{
Console.WriteLine($"Failed to revoke invite link: {response.Error}");
}
}
catch (Exception ex)
{
Console.WriteLine($"Error revoking invite link: {ex.Message}");
}
}
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class RevokeInviteLinkHttp {
public static void main(String[] args) {
String sessionId = "YOUR_SESSION_ID";
String groupId = "YOUR_GROUP_ID";
String apiKey = "YOUR_API_KEY";
String baseUrl = "https://api.wasend.dev";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(baseUrl + "/" + sessionId + "/groups/" + groupId + "/invite-link/revoke"))
.header("Authorization", "Bearer " + apiKey)
.POST(HttpRequest.BodyPublishers.noBody())
.build();
try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println("Response status: " + response.statusCode());
System.out.println("Response body: " + response.body());
// Parse JSON to check success, new inviteLink, and expiresAt
} catch (Exception e) {
e.printStackTrace();
}
}
}
<?php
$sessionId = 'YOUR_SESSION_ID';
$groupId = 'YOUR_GROUP_ID';
$apiKey = 'YOUR_API_KEY';
$baseUrl = 'https://api.wasend.dev';
$ch = curl_init($baseUrl . '/' . $sessionId . '/groups/' . $groupId . '/invite-link/revoke');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $apiKey
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "HTTP status: " . $httpCode . "\\n";
echo "Response: " . $response . "\\n";
// Parse JSON response
?>
require 'net/http'
require 'uri'
require 'json'
session_id = 'YOUR_SESSION_ID'
group_id = 'YOUR_GROUP_ID'
api_key = 'YOUR_API_KEY'
base_url = 'https://api.wasend.dev'
uri = URI("#{base_url}/#{session_id}/groups/#{group_id}/invite-link/revoke")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = (uri.scheme == 'https')
request = Net::HTTP::Post.new(uri.path, {
'Authorization' => "Bearer #{api_key}"
})
response_data = http.request(request)
puts "Response status: #{response_data.code}"
puts "Response body: #{response_data.body}"
# Parse JSON response
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
let sessionId = "YOUR_SESSION_ID"
let groupId = "YOUR_GROUP_ID"
let apiKey = "YOUR_API_KEY"
let baseUrl = "https://api.wasend.dev"
guard let url = URL(string: "\(baseUrl)/\(sessionId)/groups/\(groupId)/invite-link/revoke") else {
print("Invalid URL")
exit(1)
}
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let error = error {
print("Error: \(error)")
return
}
guard let httpResponse = response as? HTTPURLResponse else {
print("Invalid response")
return
}
print("Response status code: \(httpResponse.statusCode)")
if let data = data, let responseBody = String(data: data, encoding: .utf8) {
print("Response body: \(responseBody)")
// Parse JSON response
}
#if os(macOS) || os(Linux)
CFRunLoopStop(CFRunLoopGetCurrent())
#endif
}
task.resume()
#if os(macOS) || os(Linux)
CFRunLoopRun()
#endif
use reqwest::Client;
use tokio;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let session_id = "YOUR_SESSION_ID";
let group_id = "YOUR_GROUP_ID";
let api_key = "YOUR_API_KEY";
let base_url = "https://api.wasend.dev";
let client = Client::new();
let response = client.post(format!("{}/{}/groups/{}/invite-link/revoke", base_url, session_id, group_id))
.bearer_auth(api_key)
.send()
.await?;
println!("Status: {}", response.status());
let body = response.text().await?;
println!("Body: {}", body);
// Parse JSON response
Ok(())
}
Response Fields
Field | Type | Description |
---|---|---|
success | boolean | Whether the operation was successful. |
inviteLink | string | The new group invite link. |
expiresAt | string | ISO 8601 timestamp for when the new invite link expires. |
error | string | Optional. Error message if the request fails. |
Error Codes
Code | Description |
---|---|
400 | Bad Request - Invalid parameters. |
401 | Unauthorized - Invalid or missing API key. |
403 | Forbidden - User is not an admin of the group. |
404 | Not Found - Session or group not found. |
429 | Too Many Requests - Rate limit exceeded. |
500 | Internal Server Error. |
Notes
- Only group administrators can revoke a group's invite link.
- Revoking an invite link invalidates the current one immediately.
- A new invite link is automatically generated and returned in the response.
- The
expiresAt
field indicates when the newly generated link will expire. Refer to WhatsApp's policy for actual expiration times (typically 7 days or configurable by WhatsApp). - The new invite link can be used by anyone with the link to request to join the group, subject to group settings.