Wasend

Create Group

Create a new WhatsApp group

Create Group

Create a new WhatsApp group with specified participants and settings.

Endpoint

POST /{sessionId}/groups

Headers

NameTypeRequiredDescription
AuthorizationstringYesBearer token for authentication
Content-TypestringYesapplication/json

Path Parameters

ParameterTypeRequiredDescription
sessionIdstringYesThe session ID

Request Body

FieldTypeRequiredDescription
namestringYesGroup name
participantsParticipant[]YesList of participants to add
descriptionstringNoGroup description
pictureUrlstringNoURL of group picture
tagsstring[]NoList of tags for the group

Participant Object (for Request)

FieldTypeRequiredDescription
idstringYesParticipant's phone number
isAdminbooleanNoWhether the participant is an admin

Response

{
  "jid": "string",
  "name": "string",
  "ownerJid": "string",
  "ownerPn": "string",
  "participants": [
    {
      "jid": "string",
      "phoneNumber": "string",
      "isAdmin": boolean,
      "displayName": "string"
    }
  ],
  "description": "string",
  "isAnnounce": boolean,
  "isLocked": boolean,
  "createdAt": "string",
  "settings": {
    "infoAdminOnly": boolean,
    "messagesAdminOnly": boolean
  }
}

Examples

curl -X POST "https://api.wasend.dev/{sessionId}/groups" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My Group",
    "description": "A group for testing",
    "participants": [
      {
        "id": "+1234567890",
        "isAdmin": true
      },
      {
        "id": "+0987654321",
        "isAdmin": false
      }
    ]
  }'
import { WasendClient, CreateGroupRequest, CreateGroupParticipant } from '@wasend/core';

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

const sessionId = "yourSessionId";

// Create a new group
const groupRequest: CreateGroupRequest = {
  name: 'My Group',
  description: 'A group for testing',
  participants: [
    { id: '+1234567890', isAdmin: true },
    { id: '+0987654321', isAdmin: false }
  ]
};
const group = await client.createGroup(sessionId, groupRequest);

console.log('Created group:', group.name);
const { WasendClient } = require('@wasend/core');

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

const sessionId = "yourSessionId";

// Create a new group
const group = await client.createGroup(sessionId, {
  name: 'My Group',
  description: 'A group for testing',
  participants: [
    { id: '+1234567890', isAdmin: true },
    { id: '+0987654321', isAdmin: false }
  ]
});

console.log('Created group:', group.name);
from wasend import WasendClient

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

session_id = "yourSessionId"

# Create a new group
group_request = {
    'name': 'My Group',
    'description': 'A group for testing',
    'participants': [
        {'id': '+1234567890', 'isAdmin': True},
        {'id': '+0987654321', 'isAdmin': False}
    ]
}
group = client.create_group(
    session_id=session_id,
    request=group_request
)

print(f"Created group: {group.name}")
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"

	// Create a new group
	group, err := client.CreateGroup(sessionId, &wasendcore.CreateGroupRequest{
		Name:        StringPtr("My Group"),
		Description: StringPtr("A group for testing"), // Optional: use StringPtr for optional fields
		Participants: []*wasendcore.CreateGroupParticipant{
			{Id: StringPtr("+1234567890"), IsAdmin: BoolPtr(true)},
			{Id: StringPtr("+0987654321"), IsAdmin: BoolPtr(false)}, // IsAdmin is optional, defaults to false
		},
		// PictureUrl: StringPtr("https://example.com/group.jpg"), // Optional
		// Tags:       []string{"test", "example"},             // Optional
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("Created group: %s\n", *group.Name)
}
using Wasend.Core;
using System.Collections.Generic;

var config = new WasendConfig
{
    ApiKey = "YOUR_API_KEY",
    // BaseUrl = "https://api.wasend.dev" // Optional, defaults to this
};
var client = new WasendClient(config);
string sessionId = "yourSessionId";

// Create a new group
var groupRequest = new CreateGroupRequest
{
    Name = "My Group",
    Description = "A group for testing", // Optional
    Participants = new List<CreateGroupParticipant>
    {
        new CreateGroupParticipant { Id = "+1234567890", IsAdmin = true },
        new CreateGroupParticipant { Id = "+0987654321", IsAdmin = false } // IsAdmin is optional, defaults to false
    },
    // PictureUrl = "https://example.com/group.jpg", // Optional
    // Tags = new List<string> { "test", "example" } // Optional
};
var group = client.CreateGroup(sessionId, groupRequest);

System.Console.WriteLine($"Created group: {group.Name}");
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";

        JSONObject requestBody = new JSONObject();
        requestBody.put("name", "My Group");
        requestBody.put("description", "A group for testing"); // Optional

        JSONArray participantsArray = new JSONArray();
        JSONObject participant1 = new JSONObject();
        participant1.put("id", "+1234567890");
        participant1.put("isAdmin", true);
        participantsArray.put(participant1);

        JSONObject participant2 = new JSONObject();
        participant2.put("id", "+0987654321");
        participant2.put("isAdmin", false); // isAdmin is optional, defaults to false
        participantsArray.put(participant2);

        requestBody.put("participants", participantsArray);
        // requestBody.put("pictureUrl", "https://example.com/group.jpg"); // Optional
        // JSONArray tagsArray = new JSONArray(); // Optional
        // tagsArray.put("test");
        // tagsArray.put("example");
        // requestBody.put("tags", tagsArray);

        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create("https://api.wasend.dev/" + sessionId + "/groups"))
                .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';
$url = "https://api.wasend.dev/{$sessionId}/groups";

$data = [
    'name' => 'My Group',
    'description' => 'A group for testing', // Optional
    'participants' => [
        [
            'id' => '+1234567890',
            'isAdmin' => true
        ],
        [
            'id' => '+0987654321',
            'isAdmin' => false // isAdmin is optional, defaults to false
        ]
    ],
    // 'pictureUrl' => 'https://example.com/group.jpg', // Optional
    // 'tags' => ['test', 'example'] // Optional
];

$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'
uri = URI("https://api.wasend.dev/#{session_id}/groups")

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 = {
  name: 'My Group',
  description: 'A group for testing', # Optional
  participants: [
    {
      id: '+1234567890',
      isAdmin: true
    },
    {
      id: '+0987654321',
      isAdmin: false # isAdmin is optional, defaults to false
    }
  ]
  # pictureUrl: 'https://example.com/group.jpg', # Optional
  # tags: ['test', 'example'] # Optional
}.to_json

response = http.request(request_obj)
puts "Response: #{response.body}"
import Foundation

let sessionId = "yourSessionId"
let url = URL(string: "https://api.wasend.dev/\(sessionId)/groups")!

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?] = [
    "name": "My Group",
    "description": "A group for testing", // Optional
    "participants": [
        ["id": "+1234567890", "isAdmin": true],
        ["id": "+0987654321", "isAdmin": false] // isAdmin is optional, defaults to false
    ],
    // "pictureUrl": "https://example.com/group.jpg", // Optional
    // "tags": ["test", "example"] // Optional
]

request.httpBody = try? JSONSerialization.data(withJSONObject: body.compactMapValues { $0 }, options: [])

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 url = format!("https://api.wasend.dev/{}/groups", session_id);

    let response = client
        .post(&url)
        .header("Authorization", "Bearer YOUR_API_KEY")
        .header("Content-Type", "application/json")
        .json(&json!({
            "name": "My Group",
            "description": "A group for testing", // Optional
            "participants": [
                {
                    "id": "+1234567890",
                    "isAdmin": true
                },
                {
                    "id": "+0987654321",
                    "isAdmin": false // isAdmin is optional, defaults to false
                }
            ]
            // "pictureUrl": "https://example.com/group.jpg", // Optional
            // "tags": ["test", "example"] // Optional
        }))
        .send()
        .await?
        .text()
        .await?;

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

Response Fields

FieldTypeDescription
jidstringUnique identifier for the group
namestringGroup name
ownerJidstringOwner's ID
ownerPnstringOwner's phone number
participantsParticipant[]List of group participants
descriptionstringGroup description
isAnnouncebooleanWhether the group is an announcement group
isLockedbooleanWhether the group is locked
createdAtstringCreation timestamp
settingsSettingsGroup settings

Participant Object (in Response)

FieldTypeDescription
jidstringParticipant's JID
phoneNumberstringParticipant's phone number
isAdminbooleanWhether the participant is an admin
displayNamestringParticipant's display name

Settings Object

FieldTypeDescription
infoAdminOnlybooleanWhether only admins can edit group info
messagesAdminOnlybooleanWhether only admins can send messages

Error Codes

CodeDescription
400Bad Request - Invalid parameters
401Unauthorized - Invalid API key
404Not Found - Session not found
429Too Many Requests - Rate limit exceeded
500Internal Server Error

Notes

  • Group names must be between 1 and 25 characters
  • Group descriptions must be between 0 and 75 characters
  • Maximum 256 participants per group
  • Picture URL must be a valid image URL
  • Tags must be unique and between 1 and 20 characters
  • Rate limit is 10 requests per minute
  • The API will validate all phone numbers
  • The API will check if participants exist
  • The API will verify your session is active
  • The API will validate all parameters
  • The response includes relevant group settings
  • The API will check group name availability
  • The API will validate picture URL format
  • The API will check participant limits