Join Group
Join a WhatsApp group using an invite code or link
Join Group
Join a WhatsApp group using an invite code or link. This endpoint allows you to join groups that you have been invited to.
Endpoint
POST /{sessionId}/groups/join
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 |
Request Body
Refer to JoinGroupRequest
in API.md
.
Field | Type | Required | Description |
---|---|---|---|
inviteCode | string | Yes* | The group invite code (e.g., "ABC123XYZ") |
inviteLink | string | Yes* | The group invite link (e.g., "https://chat.whatsapp.com/ABC123XYZ") |
*Either inviteCode
or inviteLink
must be provided.
Response
Returns a Group
object on success. See API.md
for Group
structure.
{
"success": true,
"group": {
"id": "GROUP_ID@g.us",
"name": "Awesome Group Name",
"description": "This is a great group for discussions.",
"ownerJid": "OWNER_JID@s.whatsapp.net",
"participantsCount": 25,
"createdAt": "2023-10-26T10:00:00Z",
"settings": {
"infoAdminOnly": false,
"messagesAdminOnly": false
},
"participants": [
{
"id": "PARTICIPANT_ID_1@s.whatsapp.net",
"isAdmin": true,
"isSuperAdmin": false
},
{
"id": "PARTICIPANT_ID_2@s.whatsapp.net",
"isAdmin": false,
"isSuperAdmin": false
}
]
}
}
Examples
# Join using invite code
curl -X POST "https://api.wasend.dev/YOUR_SESSION_ID/groups/join" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"inviteCode": "GROUP_INVITE_CODE"
}'
# Join using invite link
curl -X POST "https://api.wasend.dev/YOUR_SESSION_ID/groups/join" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"inviteLink": "https://chat.whatsapp.com/GROUP_INVITE_LINK"
}'
import { WasendClient, WasendConfig, JoinGroupRequest } from '@wasend/core'; // Assuming types are exported
const config = new WasendConfig({ apiKey: 'YOUR_API_KEY' });
const client = new WasendClient(config);
const sessionId = 'YOUR_SESSION_ID';
async function joinGroupExample() {
try {
// Join using invite code
const joinRequestCode: JoinGroupRequest = {
inviteCode: 'GROUP_INVITE_CODE'
};
const groupResponseCode = await client.joinGroup(sessionId, joinRequestCode);
if (groupResponseCode.success && groupResponseCode.group) {
console.log('Successfully joined group (by code):', groupResponseCode.group.name);
} else {
console.error('Failed to join group (by code):', groupResponseCode.error);
}
// Join using invite link
const joinRequestLink: JoinGroupRequest = {
inviteLink: 'https://chat.whatsapp.com/GROUP_INVITE_LINK'
};
const groupResponseLink = await client.joinGroup(sessionId, joinRequestLink);
if (groupResponseLink.success && groupResponseLink.group) {
console.log('Successfully joined group (by link):', groupResponseLink.group.name);
} else {
console.error('Failed to join group (by link):', groupResponseLink.error);
}
} catch (error) {
console.error('Error joining group:', error);
}
}
joinGroupExample();
const { WasendClient, WasendConfig } = require('@wasend/core'); // Adjust import as per your SDK structure
const config = new WasendConfig({ apiKey: 'YOUR_API_KEY' });
const client = new WasendClient(config);
const sessionId = 'YOUR_SESSION_ID';
async function joinGroupExample() {
try {
// Join using invite code
const groupResponseCode = await client.joinGroup(sessionId, {
inviteCode: 'GROUP_INVITE_CODE'
});
if (groupResponseCode.success && groupResponseCode.group) {
console.log('Successfully joined group (by code):', groupResponseCode.group.name);
} else {
console.error('Failed to join group (by code):', groupResponseCode.error);
}
// Join using invite link
const groupResponseLink = await client.joinGroup(sessionId, {
inviteLink: 'https://chat.whatsapp.com/GROUP_INVITE_LINK'
});
if (groupResponseLink.success && groupResponseLink.group) {
console.log('Successfully joined group (by link):', groupResponseLink.group.name);
} else {
console.error('Failed to join group (by link):', groupResponseLink.error);
}
} catch (error) {
console.error('Error joining group:', error);
}
}
joinGroupExample();
from wasend_sdk import WasendClient, WasendConfig # Assuming WasendConfig and specific request types
# Configure the client
config = WasendConfig(api_key='YOUR_API_KEY')
client = WasendClient(config)
session_id = 'YOUR_SESSION_ID'
try:
# Join using invite code
group_response_code = client.join_group(
session_id=session_id,
request={'inviteCode': 'GROUP_INVITE_CODE'} # Assuming JoinGroupRequest maps to a dict or specific object
)
if group_response_code.success and group_response_code.group:
print(f"Successfully joined group (by code): {group_response_code.group.name}")
else:
print(f"Failed to join group (by code): {group_response_code.error}")
# Join using invite link
group_response_link = client.join_group(
session_id=session_id,
request={'inviteLink': 'https://chat.whatsapp.com/GROUP_INVITE_LINK'}
)
if group_response_link.success and group_response_link.group:
print(f"Successfully joined group (by link): {group_response_link.group.name}")
else:
print(f"Failed to join group (by link): {group_response_link.error}")
except Exception as e:
print(f"Error joining group: {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",
// BaseUrl: "https://api.wasend.dev", // Optional if default is correct
}
client := wasendcore.NewWasendClient(config)
sessionId := "YOUR_SESSION_ID"
// Join using invite code
joinRequestCode := &wasendcore.JoinGroupRequest{
InviteCode: wasendcore.StringPtr("GROUP_INVITE_CODE"),
}
groupResponseCode, err := client.JoinGroup(sessionId, joinRequestCode)
if err != nil {
log.Fatalf("Error joining group (by code): %v", err)
}
if groupResponseCode.Success && groupResponseCode.Group != nil {
fmt.Printf("Successfully joined group (by code): %s\n", groupResponseCode.Group.Name)
} else {
fmt.Printf("Failed to join group (by code): %s\n", groupResponseCode.Error)
}
// Join using invite link
joinRequestLink := &wasendcore.JoinGroupRequest{
InviteLink: wasendcore.StringPtr("https://chat.whatsapp.com/GROUP_INVITE_LINK"),
}
groupResponseLink, err := client.JoinGroup(sessionId, joinRequestLink)
if err != nil {
log.Fatalf("Error joining group (by link): %v", err)
}
if groupResponseLink.Success && groupResponseLink.Group != nil {
fmt.Printf("Successfully joined group (by link): %s\n", groupResponseLink.Group.Name)
} else {
fmt.Printf("Failed to join group (by link): %s\n", groupResponseLink.Error)
}
}
using System;
using System.Threading.Tasks;
using Wasend.Core; // Assuming Wasend.Core for WasendConfig and specific request/response
// Add import for JoinGroupRequest and GroupResponse/Group if they are in a specific namespace
public class JoinGroupExample
{
public static async Task Main(string[] args)
{
var config = new WasendConfig { ApiKey = "YOUR_API_KEY" };
var client = new WasendClient(config);
var sessionId = "YOUR_SESSION_ID";
try
{
// Join using invite code
var joinRequestCode = new JoinGroupRequest
{
InviteCode = "GROUP_INVITE_CODE"
};
var groupResponseCode = client.JoinGroup(sessionId, joinRequestCode); // Synchronous call
if (groupResponseCode.Success && groupResponseCode.Group != null)
{
Console.WriteLine($"Successfully joined group (by code): {groupResponseCode.Group.Name}");
}
else
{
Console.WriteLine($"Failed to join group (by code): {groupResponseCode.Error}");
}
// Join using invite link
var joinRequestLink = new JoinGroupRequest
{
InviteLink = "https://chat.whatsapp.com/GROUP_INVITE_LINK"
};
var groupResponseLink = client.JoinGroup(sessionId, joinRequestLink); // Synchronous call
if (groupResponseLink.Success && groupResponseLink.Group != null)
{
Console.WriteLine($"Successfully joined group (by link): {groupResponseLink.Group.Name}");
}
else
{
Console.WriteLine($"Failed to join group (by link): {groupResponseLink.Error}");
}
}
catch (Exception ex)
{
Console.WriteLine($"Error joining group: {ex.Message}");
}
}
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpRequest.BodyPublishers;
public class JoinGroupHttp {
public static void main(String[] args) {
String sessionId = "YOUR_SESSION_ID";
String apiKey = "YOUR_API_KEY";
String baseUrl = "https://api.wasend.dev"; // Adjust if different
HttpClient client = HttpClient.newHttpClient();
// Join using invite code
String inviteCodePayload = "{\\"inviteCode\\": \\"GROUP_INVITE_CODE\\"}";
HttpRequest requestInviteCode = HttpRequest.newBuilder()
.uri(URI.create(baseUrl + "/" + sessionId + "/groups/join"))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(BodyPublishers.ofString(inviteCodePayload))
.build();
try {
HttpResponse<String> response = client.send(requestInviteCode, HttpResponse.BodyHandlers.ofString());
System.out.println("Join by code response status: " + response.statusCode());
System.out.println("Join by code response body: " + response.body());
} catch (Exception e) {
e.printStackTrace();
}
// Join using invite link
String inviteLinkPayload = "{\\"inviteLink\\": \\"https://chat.whatsapp.com/GROUP_INVITE_LINK\\"}";
HttpRequest requestInviteLink = HttpRequest.newBuilder()
.uri(URI.create(baseUrl + "/" + sessionId + "/groups/join"))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(BodyPublishers.ofString(inviteLinkPayload))
.build();
try {
HttpResponse<String> response = client.send(requestInviteLink, HttpResponse.BodyHandlers.ofString());
System.out.println("Join by link response status: " + response.statusCode());
System.out.println("Join by link response body: " + response.body());
} catch (Exception e) {
e.printStackTrace();
}
}
}
<?php
$sessionId = 'YOUR_SESSION_ID';
$apiKey = 'YOUR_API_KEY';
$baseUrl = 'https://api.wasend.dev'; // Adjust if different
// Join using invite code
$inviteCodePayload = json_encode(['inviteCode' => 'GROUP_INVITE_CODE']);
$chCode = curl_init($baseUrl . '/' . $sessionId . '/groups/join');
curl_setopt($chCode, CURLOPT_RETURNTRANSFER, true);
curl_setopt($chCode, CURLOPT_POST, true);
curl_setopt($chCode, CURLOPT_POSTFIELDS, $inviteCodePayload);
curl_setopt($chCode, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json'
]);
$responseCode = curl_exec($chCode);
$httpCodeResponse = curl_getinfo($chCode, CURLINFO_HTTP_CODE);
curl_close($chCode);
echo "Join by code HTTP status: " . $httpCodeResponse . "\n";
echo "Join by code response: " . $responseCode . "\n";
// Join using invite link
$inviteLinkPayload = json_encode(['inviteLink' => 'https://chat.whatsapp.com/GROUP_INVITE_LINK']);
$chLink = curl_init($baseUrl . '/' . $sessionId . '/groups/join');
curl_setopt($chLink, CURLOPT_RETURNTRANSFER, true);
curl_setopt($chLink, CURLOPT_POST, true);
curl_setopt($chLink, CURLOPT_POSTFIELDS, $inviteLinkPayload);
curl_setopt($chLink, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json'
]);
$responseLink = curl_exec($chLink);
$httpLinkResponse = curl_getinfo($chLink, CURLINFO_HTTP_CODE);
curl_close($chLink);
echo "Join by link HTTP status: " . $httpLinkResponse . "\n";
echo "Join by link response: " . $responseLink . "\n";
?>
require 'net/http'
require 'uri'
require 'json'
session_id = 'YOUR_SESSION_ID'
api_key = 'YOUR_API_KEY'
base_url = 'https://api.wasend.dev' # Adjust if different
# Join using invite code
uri_code = URI("#{base_url}/#{session_id}/groups/join")
http_code = Net::HTTP.new(uri_code.host, uri_code.port)
http_code.use_ssl = (uri_code.scheme == 'https')
request_code = Net::HTTP::Post.new(uri_code.path, {
'Authorization' => "Bearer #{api_key}",
'Content-Type' => 'application/json'
})
request_code.body = { inviteCode: 'GROUP_INVITE_CODE' }.to_json
response_code = http_code.request(request_code)
puts "Join by code response status: #{response_code.code}"
puts "Join by code response body: #{response_code.body}"
# Join using invite link
uri_link = URI("#{base_url}/#{session_id}/groups/join")
http_link = Net::HTTP.new(uri_link.host, uri_link.port)
http_link.use_ssl = (uri_link.scheme == 'https')
request_link = Net::HTTP::Post.new(uri_link.path, {
'Authorization' => "Bearer #{api_key}",
'Content-Type' => 'application/json'
})
request_link.body = { inviteLink: 'https://chat.whatsapp.com/GROUP_INVITE_LINK' }.to_json
response_link = http_link.request(request_link)
puts "Join by link response status: #{response_link.code}"
puts "Join by link response body: #{response_link.body}"
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
let sessionId = "YOUR_SESSION_ID"
let apiKey = "YOUR_API_KEY"
let baseUrl = "https://api.wasend.dev" // Adjust if different
func joinGroup(invitePayload: [String: String]) {
guard let url = URL(string: "\(baseUrl)/\(sessionId)/groups/join") else {
print("Invalid URL")
return
}
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
do {
request.httpBody = try JSONSerialization.data(withJSONObject: invitePayload, options: [])
} catch {
print("Error serializing JSON: \(error)")
return
}
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)")
}
}
task.resume()
}
// Join using invite code
joinGroup(invitePayload: ["inviteCode": "GROUP_INVITE_CODE"])
// Join using invite link
joinGroup(invitePayload: ["inviteLink": "https://chat.whatsapp.com/GROUP_INVITE_LINK"])
// Keep the program running for async tasks in a command-line tool
RunLoop.main.run(until: Date(timeIntervalSinceNow: 5))
use std::collections::HashMap;
use reqwest::Client;
use serde_json::json;
use tokio;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let session_id = "YOUR_SESSION_ID";
let api_key = "YOUR_API_KEY";
let base_url = "https://api.wasend.dev"; // Adjust if different
let client = Client::new();
// Join using invite code
let mut payload_code = HashMap::new();
payload_code.insert("inviteCode", "GROUP_INVITE_CODE");
let response_code = client.post(format!("{}/{}/groups/join", base_url, session_id))
.bearer_auth(api_key)
.json(&payload_code)
.send()
.await?;
println!("Join by code status: {}", response_code.status());
let body_code = response_code.text().await?;
println!("Join by code body: {}", body_code);
// Join using invite link
let mut payload_link = HashMap::new();
payload_link.insert("inviteLink", "https://chat.whatsapp.com/GROUP_INVITE_LINK");
let response_link = client.post(format!("{}/{}/groups/join", base_url, session_id))
.bearer_auth(api_key)
.json(&payload_link)
.send()
.await?;
println!("Join by link status: {}", response_link.status());
let body_link = response_link.text().await?;
println!("Join by link body: {}", body_link);
Ok(())
}
Response Fields
Refer to the Group
object structure in API.md
.
Field | Type | Description |
---|---|---|
success | boolean | Indicates if the operation was successful. |
group | object | The Group object containing details of the joined group. |
error | string | Optional. Error message if the request fails. |
Group Object Fields (Partial)
Field | Type | Description |
---|---|---|
id | string | Unique identifier for the group (e.g., GROUP_ID@g.us ). |
name | string | Name of the group. |
description | string | Description of the group. |
ownerJid | string | JID of the group owner. |
participantsCount | number | Number of participants in the group. |
createdAt | string | ISO 8601 timestamp of when the group was created. |
settings | object | Group settings (e.g., infoAdminOnly , messagesAdminOnly ). |
participants | array | List of GroupParticipant objects. |
... and other fields as defined in Group type in API.md . |
Error Codes
Code | Description |
---|---|
400 | Bad Request - Invalid inviteCode or inviteLink . |
401 | Unauthorized - Invalid API key. |
403 | Forbidden - Not allowed to join the group (e.g., banned). |
404 | Not Found - Session or group (via invite) not found. |
409 | Conflict - Already a member of the group. |
429 | Too Many Requests - Rate limit exceeded. |
500 | Internal Server Error. |
Notes
- Either
inviteCode
orinviteLink
must be provided - Invite codes are case-sensitive
- Invite links must be valid WhatsApp group links
- The response includes the full group information
- You must have permission to join the group
- The group must not be locked
- You cannot join if you're already a member
- Rate limit is 10 requests per minute
- The API will validate the invite code/link format
- The response includes all group participants
- All phone numbers are in international format
- The API will check if the group exists
- The API will validate your session status
- The response includes group settings
- The API will check group size limits