curl --request POST \
--url https://api.zapsterapi.com/v1/wa/instances/{instance_id}/webhooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"events": [
"message.received"
],
"enabled": true,
"name": "Meu Webhook",
"test_mode": false,
"test_url": null,
"url": "https://webhook.example.com/receive",
"webhook_id": "2nenz69l0xbf0m3uu9tfo"
}
'import requests
url = "https://api.zapsterapi.com/v1/wa/instances/{instance_id}/webhooks"
payload = {
"events": ["message.received"],
"enabled": True,
"name": "Meu Webhook",
"test_mode": False,
"test_url": None,
"url": "https://webhook.example.com/receive",
"webhook_id": "2nenz69l0xbf0m3uu9tfo"
}
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({
events: ['message.received'],
enabled: true,
name: 'Meu Webhook',
test_mode: false,
test_url: null,
url: 'https://webhook.example.com/receive',
webhook_id: '2nenz69l0xbf0m3uu9tfo'
})
};
fetch('https://api.zapsterapi.com/v1/wa/instances/{instance_id}/webhooks', 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.zapsterapi.com/v1/wa/instances/{instance_id}/webhooks",
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([
'events' => [
'message.received'
],
'enabled' => true,
'name' => 'Meu Webhook',
'test_mode' => false,
'test_url' => null,
'url' => 'https://webhook.example.com/receive',
'webhook_id' => '2nenz69l0xbf0m3uu9tfo'
]),
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://api.zapsterapi.com/v1/wa/instances/{instance_id}/webhooks"
payload := strings.NewReader("{\n \"events\": [\n \"message.received\"\n ],\n \"enabled\": true,\n \"name\": \"Meu Webhook\",\n \"test_mode\": false,\n \"test_url\": null,\n \"url\": \"https://webhook.example.com/receive\",\n \"webhook_id\": \"2nenz69l0xbf0m3uu9tfo\"\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://api.zapsterapi.com/v1/wa/instances/{instance_id}/webhooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"events\": [\n \"message.received\"\n ],\n \"enabled\": true,\n \"name\": \"Meu Webhook\",\n \"test_mode\": false,\n \"test_url\": null,\n \"url\": \"https://webhook.example.com/receive\",\n \"webhook_id\": \"2nenz69l0xbf0m3uu9tfo\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zapsterapi.com/v1/wa/instances/{instance_id}/webhooks")
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 \"events\": [\n \"message.received\"\n ],\n \"enabled\": true,\n \"name\": \"Meu Webhook\",\n \"test_mode\": false,\n \"test_url\": null,\n \"url\": \"https://webhook.example.com/receive\",\n \"webhook_id\": \"2nenz69l0xbf0m3uu9tfo\"\n}"
response = http.request(request)
puts response.read_body{
"created_at": "2025-03-12T23:12:19.448Z",
"enabled": true,
"events": [
"message.received"
],
"id": "3nsnz68l0xbf0m3uu9tfo",
"name": "Meu Webhook",
"test_mode": false,
"test_url": null,
"url": "https://webhook.mydomain.com"
}Criando Webhooks
curl --request POST \
--url https://api.zapsterapi.com/v1/wa/instances/{instance_id}/webhooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"events": [
"message.received"
],
"enabled": true,
"name": "Meu Webhook",
"test_mode": false,
"test_url": null,
"url": "https://webhook.example.com/receive",
"webhook_id": "2nenz69l0xbf0m3uu9tfo"
}
'import requests
url = "https://api.zapsterapi.com/v1/wa/instances/{instance_id}/webhooks"
payload = {
"events": ["message.received"],
"enabled": True,
"name": "Meu Webhook",
"test_mode": False,
"test_url": None,
"url": "https://webhook.example.com/receive",
"webhook_id": "2nenz69l0xbf0m3uu9tfo"
}
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({
events: ['message.received'],
enabled: true,
name: 'Meu Webhook',
test_mode: false,
test_url: null,
url: 'https://webhook.example.com/receive',
webhook_id: '2nenz69l0xbf0m3uu9tfo'
})
};
fetch('https://api.zapsterapi.com/v1/wa/instances/{instance_id}/webhooks', 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.zapsterapi.com/v1/wa/instances/{instance_id}/webhooks",
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([
'events' => [
'message.received'
],
'enabled' => true,
'name' => 'Meu Webhook',
'test_mode' => false,
'test_url' => null,
'url' => 'https://webhook.example.com/receive',
'webhook_id' => '2nenz69l0xbf0m3uu9tfo'
]),
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://api.zapsterapi.com/v1/wa/instances/{instance_id}/webhooks"
payload := strings.NewReader("{\n \"events\": [\n \"message.received\"\n ],\n \"enabled\": true,\n \"name\": \"Meu Webhook\",\n \"test_mode\": false,\n \"test_url\": null,\n \"url\": \"https://webhook.example.com/receive\",\n \"webhook_id\": \"2nenz69l0xbf0m3uu9tfo\"\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://api.zapsterapi.com/v1/wa/instances/{instance_id}/webhooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"events\": [\n \"message.received\"\n ],\n \"enabled\": true,\n \"name\": \"Meu Webhook\",\n \"test_mode\": false,\n \"test_url\": null,\n \"url\": \"https://webhook.example.com/receive\",\n \"webhook_id\": \"2nenz69l0xbf0m3uu9tfo\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zapsterapi.com/v1/wa/instances/{instance_id}/webhooks")
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 \"events\": [\n \"message.received\"\n ],\n \"enabled\": true,\n \"name\": \"Meu Webhook\",\n \"test_mode\": false,\n \"test_url\": null,\n \"url\": \"https://webhook.example.com/receive\",\n \"webhook_id\": \"2nenz69l0xbf0m3uu9tfo\"\n}"
response = http.request(request)
puts response.read_body{
"created_at": "2025-03-12T23:12:19.448Z",
"enabled": true,
"events": [
"message.received"
],
"id": "3nsnz68l0xbf0m3uu9tfo",
"name": "Meu Webhook",
"test_mode": false,
"test_url": null,
"url": "https://webhook.mydomain.com"
}url ou um webhook_id. Se nenhum dos dois for informado, a requisição falhará.
🔍 Considerações
- Pelo menos um evento deve ser especificado na criação do webhook.
- Se uma
urle umwebhook_idforem fornecidos ao mesmo tempo, owebhook_idserá priorizado. - O webhook pode ser desativado posteriormente usando a propriedade
enabled.
Autorizações
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Parâmetros de caminho
Identificador único da instância.
Corpo
Lista de eventos que acionam o webhook. Deve conter pelo menos um evento. O message.failed e o message.flow_reply existem apenas em instâncias com API oficial (WABA): assinar message.failed em uma instância não oficial é recusado com unsupported_webhook_event. Já o instance.restricted e o instance.restriction_lifted existem apenas em instâncias não oficiais e são recusados em instâncias WABA.
group.created, group.participants_added, group.participants_demoted, group.participants_promoted, group.participants_removed, group.updated, instance.connected, instance.disconnected, instance.forbidden, instance.mentioned, instance.qrcode, instance.restricted, instance.restriction_lifted, message.deleted, message.delivered, message.edited, message.failed, message.flow_reply, message.pinned, message.reaction, message.read, message.received, message.sent, message.unpinned, poll.created, poll.deleted, poll.updated, status.reply ["message.received"]
Define se o webhook está ativado. Padrão: true.
true
Nome do webhook configurado.
"Meu Webhook"
Indica se o webhook está em modo de teste. Padrão: false.
false
URL de teste para validar o webhook, se aplicável.
null
URL para onde os eventos do webhook serão enviados. Obrigatório caso webhook_id não seja fornecido.
"https://webhook.example.com/receive"
ID de um webhook existente para ser reutilizado. Obrigatório caso url não seja fornecida.
"2nenz69l0xbf0m3uu9tfo"
Resposta
Webhook registrado com sucesso.
Resposta ao registrar um webhook.
Data e hora de criação do webhook.
"2025-03-12T23:12:19.448Z"
Indica se o webhook está ativado.
true
Eventos configurados no webhook.
["message.received"]
Identificador único do webhook.
"3nsnz68l0xbf0m3uu9tfo"
Nome do webhook configurado.
"Meu Webhook"
Indica se o webhook está em modo de teste.
false
URL de teste configurada no webhook, se aplicável.
null
URL para onde os eventos do webhook serão enviados.
"https://webhook.mydomain.com"