Atualiza um webhook de uma instância
curl --request PATCH \
--url https://api.zapsterapi.com/v1/wa/instances/{instance_id}/webhooks/{webhook_id} \
--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/{webhook_id}"
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.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
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/{webhook_id}', 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/{webhook_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
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/{webhook_id}"
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("PATCH", 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.patch("https://api.zapsterapi.com/v1/wa/instances/{instance_id}/webhooks/{webhook_id}")
.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/{webhook_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.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"
}Instâncias
Atualizando Webhooks
PATCH
/
wa
/
instances
/
{instance_id}
/
webhooks
/
{webhook_id}
Atualiza um webhook de uma instância
curl --request PATCH \
--url https://api.zapsterapi.com/v1/wa/instances/{instance_id}/webhooks/{webhook_id} \
--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/{webhook_id}"
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.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
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/{webhook_id}', 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/{webhook_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
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/{webhook_id}"
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("PATCH", 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.patch("https://api.zapsterapi.com/v1/wa/instances/{instance_id}/webhooks/{webhook_id}")
.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/{webhook_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.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"
}Este endpoint permite atualizar um webhook existente para uma instância específica.
⚠️ Importante: Alteração de Nome ou URL
Modificar o nome ou a URL de um webhook existente impactará todas as instâncias que utilizam esse webhook. Isso significa que qualquer instância vinculada será automaticamente atualizada para refletir as mudanças. Se precisar utilizar um novo nome ou uma URL diferente sem afetar instâncias existentes, recomendamos criar um novo webhook em vez de modificar um já em uso. Dessa forma, o novo webhook será vinculado apenas aos recursos desejados, evitando impactos inesperados em outras configurações.🔍 Considerações
- Todos os parâmetros são opcionais, sendo possível atualizar apenas os campos desejados.
- Se a URL do webhook for alterada, a API pode exigir uma nova validação.
- O webhook pode ser desativado definindo
enabledcomofalse.
Autorizações
Parâmetros de caminho
Corpo
application/json
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, o instance.restriction_lifted e os eventos call.accepted, call.missed, call.received e call.rejected existem apenas em instâncias não oficiais e são recusados em instâncias WABA.
Opções disponíveis:
call.accepted, call.missed, call.received, call.rejected, 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 Exemplo:
["message.received"]
Resposta
201 - application/json
Webhook registrado com sucesso.
Resposta ao registrar um webhook.