Criar grupo
curl --request POST \
--url https://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_token}/create-group \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"autoInvite": true,
"groupName": "Grupo Z-API",
"phones": [
"5544999999999",
"5544888888888"
]
}
'import requests
url = "https://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_token}/create-group"
payload = {
"autoInvite": True,
"groupName": "Grupo Z-API",
"phones": ["5544999999999", "5544888888888"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
autoInvite: true,
groupName: 'Grupo Z-API',
phones: ['5544999999999', '5544888888888']
})
};
fetch('https://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_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://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_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' => 'Grupo Z-API',
'phones' => [
'5544999999999',
'5544888888888'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_token}/create-group"
payload := strings.NewReader("{\n \"autoInvite\": true,\n \"groupName\": \"Grupo Z-API\",\n \"phones\": [\n \"5544999999999\",\n \"5544888888888\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_token}/create-group")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"autoInvite\": true,\n \"groupName\": \"Grupo Z-API\",\n \"phones\": [\n \"5544999999999\",\n \"5544888888888\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_token}/create-group")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"autoInvite\": true,\n \"groupName\": \"Grupo Z-API\",\n \"phones\": [\n \"5544999999999\",\n \"5544888888888\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"phone": "120363019502650977-group",
"phonesNotAdded": [
"2111897971174599@lid",
"5544777777777"
],
"invitationLink": "https://chat.whatsapp.com/GONwbGGDkLe8BifUWwLgct"
}{
"error": "invalid path parameter"
}{
"error": "instance subscription is not active"
}{
"error": "internal server error"
}{
"error": "failed to reach the META_WHATSAPP channel"
}{
"error": "<string>"
}Criar e editar
Criar grupo
Cria um grupo com os participantes informados
POST
/
create-group
Criar grupo
curl --request POST \
--url https://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_token}/create-group \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"autoInvite": true,
"groupName": "Grupo Z-API",
"phones": [
"5544999999999",
"5544888888888"
]
}
'import requests
url = "https://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_token}/create-group"
payload = {
"autoInvite": True,
"groupName": "Grupo Z-API",
"phones": ["5544999999999", "5544888888888"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
autoInvite: true,
groupName: 'Grupo Z-API',
phones: ['5544999999999', '5544888888888']
})
};
fetch('https://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_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://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_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' => 'Grupo Z-API',
'phones' => [
'5544999999999',
'5544888888888'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_token}/create-group"
payload := strings.NewReader("{\n \"autoInvite\": true,\n \"groupName\": \"Grupo Z-API\",\n \"phones\": [\n \"5544999999999\",\n \"5544888888888\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_token}/create-group")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"autoInvite\": true,\n \"groupName\": \"Grupo Z-API\",\n \"phones\": [\n \"5544999999999\",\n \"5544888888888\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_token}/create-group")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"autoInvite\": true,\n \"groupName\": \"Grupo Z-API\",\n \"phones\": [\n \"5544999999999\",\n \"5544888888888\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"phone": "120363019502650977-group",
"phonesNotAdded": [
"2111897971174599@lid",
"5544777777777"
],
"invitationLink": "https://chat.whatsapp.com/GONwbGGDkLe8BifUWwLgct"
}{
"error": "invalid path parameter"
}{
"error": "instance subscription is not active"
}{
"error": "internal server error"
}{
"error": "failed to reach the META_WHATSAPP channel"
}{
"error": "<string>"
}Conceituação
Método que cria um grupo com seus participantes. Não é possível enviar a imagem na criação: adicione-a depois, com Atualizar imagem do grupo. Não informe o número conectado na lista de participantes. Como no WhatsApp Web, é preciso pelo menos um contato para criar o grupo. Use somente números de telefone. O identificador@lid não é compatível com a criação de grupos: se for enviado, o grupo é criado, mas o participante com @lid não é incluído e o identificador volta em phonesNotAdded.
No WhatsApp Oficial, ninguém é adicionado na criação: os números de
phones voltam em phonesNotAdded, porque a Meta não permite adicionar participantes manualmente, e a entrada é só pelo invitationLink. O grupo tem no máximo 8 participantes. Para exigir aprovação de entrada, envie requireAdminApproval true.Autorizações
Corpo
application/json