Webhooks: URLs, filtros e secret
curl --request GET \
--url https://api.wabox.me/instances/{instance_id}/token/{token}/webhooksconst options = {method: 'GET'};
fetch('https://api.wabox.me/instances/{instance_id}/token/{token}/webhooks', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.wabox.me/instances/{instance_id}/token/{token}/webhooks"
response = requests.get(url)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.wabox.me/instances/{instance_id}/token/{token}/webhooks",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.wabox.me/instances/{instance_id}/token/{token}/webhooks"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"received_url": "https://example.com/wabox/received",
"delivery_url": "https://example.com/wabox/delivery",
"message_status_url": "https://example.com/wabox/message-status",
"connected_url": "https://example.com/wabox/connected",
"disconnected_url": "https://example.com/wabox/disconnected",
"chat_presence_url": null,
"notify_sent_by_me": false,
"ignore_groups": false,
"ignore_private": false,
"ignore_text": false,
"ignore_image": false,
"ignore_video": false,
"ignore_audio": false,
"ignore_document": false,
"ignore_received_callback": false,
"ignore_delivery_callback": false,
"ignore_message_status_callback": false,
"ignore_connected_callback": false,
"ignore_disconnected_callback": false,
"ignore_chat_presence_callback": false,
"secret": "whsec_9f8e7d6c5b4a39281706f5e4d3c2b1a0"
}{
"error": {
"code": "instance_not_found",
"message": "Instance not found or invalid token"
}
}URLs de cada tipo de webhook (*_url, null = desativado), filtros (notify_sent_by_me, ignore_*) e o secret de assinatura. secret assina toda entrega: header X-Wabox-Signature: t=<unix em segundos>,v1=<hex> onde v1 = HMAC-SHA256(secret, "<t>.<corpo bruto>"). Valide recalculando sobre o corpo bruto da requisição e rejeite timestamps com mais de alguns minutos. secret é null quando as entregas não são assinadas.
GET
/
instances
/
{instance_id}
/
token
/
{token}
/
webhooks
Webhooks: URLs, filtros e secret
curl --request GET \
--url https://api.wabox.me/instances/{instance_id}/token/{token}/webhooksconst options = {method: 'GET'};
fetch('https://api.wabox.me/instances/{instance_id}/token/{token}/webhooks', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.wabox.me/instances/{instance_id}/token/{token}/webhooks"
response = requests.get(url)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.wabox.me/instances/{instance_id}/token/{token}/webhooks",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.wabox.me/instances/{instance_id}/token/{token}/webhooks"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"received_url": "https://example.com/wabox/received",
"delivery_url": "https://example.com/wabox/delivery",
"message_status_url": "https://example.com/wabox/message-status",
"connected_url": "https://example.com/wabox/connected",
"disconnected_url": "https://example.com/wabox/disconnected",
"chat_presence_url": null,
"notify_sent_by_me": false,
"ignore_groups": false,
"ignore_private": false,
"ignore_text": false,
"ignore_image": false,
"ignore_video": false,
"ignore_audio": false,
"ignore_document": false,
"ignore_received_callback": false,
"ignore_delivery_callback": false,
"ignore_message_status_callback": false,
"ignore_connected_callback": false,
"ignore_disconnected_callback": false,
"ignore_chat_presence_callback": false,
"secret": "whsec_9f8e7d6c5b4a39281706f5e4d3c2b1a0"
}{
"error": {
"code": "instance_not_found",
"message": "Instance not found or invalid token"
}
}