Creating groups
curl --request POST \
--url https://api.z-api.io/instances/{instanceId}/token/{token}/create-group \
--header 'Client-Token: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"autoInvite": true,
"groupName": "<string>",
"phones": [
{}
]
}
'import requests
url = "https://api.z-api.io/instances/{instanceId}/token/{token}/create-group"
payload = {
"autoInvite": True,
"groupName": "<string>",
"phones": [{}]
}
headers = {
"Client-Token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Client-Token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({autoInvite: true, groupName: '<string>', phones: [{}]})
};
fetch('https://api.z-api.io/instances/{instanceId}/token/{token}/create-group', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.z-api.io/instances/{instanceId}/token/{token}/create-group",
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([
'autoInvite' => true,
'groupName' => '<string>',
'phones' => [
[
]
]
]),
CURLOPT_HTTPHEADER => [
"Client-Token: <api-key>",
"Content-Type: application/json"
],
]);
$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.z-api.io/instances/{instanceId}/token/{token}/create-group"
payload := strings.NewReader("{\n \"autoInvite\": true,\n \"groupName\": \"<string>\",\n \"phones\": [\n {}\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Client-Token", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.z-api.io/instances/{instanceId}/token/{token}/create-group")
.header("Client-Token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"autoInvite\": true,\n \"groupName\": \"<string>\",\n \"phones\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.z-api.io/instances/{instanceId}/token/{token}/create-group")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Client-Token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"autoInvite\": true,\n \"groupName\": \"<string>\",\n \"phones\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_body{
"phone": "<string>",
"phonesNotAdded": [
{}
],
"invitationLink": "<string>"
}Groups
Creating groups
Creates a group with its respective participants
POST
/
instances
/
{instanceId}
/
token
/
{token}
/
create-group
Creating groups
curl --request POST \
--url https://api.z-api.io/instances/{instanceId}/token/{token}/create-group \
--header 'Client-Token: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"autoInvite": true,
"groupName": "<string>",
"phones": [
{}
]
}
'import requests
url = "https://api.z-api.io/instances/{instanceId}/token/{token}/create-group"
payload = {
"autoInvite": True,
"groupName": "<string>",
"phones": [{}]
}
headers = {
"Client-Token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Client-Token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({autoInvite: true, groupName: '<string>', phones: [{}]})
};
fetch('https://api.z-api.io/instances/{instanceId}/token/{token}/create-group', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.z-api.io/instances/{instanceId}/token/{token}/create-group",
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([
'autoInvite' => true,
'groupName' => '<string>',
'phones' => [
[
]
]
]),
CURLOPT_HTTPHEADER => [
"Client-Token: <api-key>",
"Content-Type: application/json"
],
]);
$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.z-api.io/instances/{instanceId}/token/{token}/create-group"
payload := strings.NewReader("{\n \"autoInvite\": true,\n \"groupName\": \"<string>\",\n \"phones\": [\n {}\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Client-Token", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.z-api.io/instances/{instanceId}/token/{token}/create-group")
.header("Client-Token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"autoInvite\": true,\n \"groupName\": \"<string>\",\n \"phones\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.z-api.io/instances/{instanceId}/token/{token}/create-group")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Client-Token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"autoInvite\": true,\n \"groupName\": \"<string>\",\n \"phones\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_body{
"phone": "<string>",
"phonesNotAdded": [
{}
],
"invitationLink": "<string>"
}Overview
This method is responsible for creating a group with its respective participants.It is not possible to add an image during creation, but you can add one afterwards using the update group image method.
You must not pass the connected number in the participants list. At least one contact is required to create a group, just like on WhatsApp Web.
When creating a new group, you must use phone numbers exclusively. The @lid identifier is not supported for group creation — if provided, the group will be created normally, but the participant with @lid will not be included and their identifier will be returned in the
phonesNotAdded field.Attributes
Header
string
required
Your instance ID. Available in the Z-API panel under Instances.
string
required
Your Z-API instance token.
Required
boolean
required
Defines whether a private invite will be sent to participants who cannot be added directly
string
required
Group name
array
required
List of participant phone numbers
Request Body
{
"autoInvite": true,
"groupName": "Z-API Group",
"phones": ["5544999999999", "5544888888888"]
}
Response
200
string
ID/Phone of the created group
array
List of identifiers that were not added to the group. A participant may appear here for two reasons:
- Use of @lid: identifiers in the
@lidformat are not supported for group creation. The group will be created normally, but the participant with @lid will be left out and their identifier will be listed here. - Permission issue (autoInvite): when a number cannot be added directly to the group and
autoInviteis enabled, a private invite is sent to them. Until the invite is accepted, the number is returned in this field.
string
Group invitation link
{
"phone": "120363019502650977-group",
"phonesNotAdded": [
"2111897971174599@lid",
"5544777777777"
],
"invitationLink": "https://chat.whatsapp.com/GONwbGGDkLe8BifUWwLgct"
}