PATCH
https://api.instvia.com/api/v1/instances/dac3a956-4e8b-4d76-8caf-fed98dfc8b05/webhook
Atualizar webhook
Atualiza URL, lista de eventos ou status (`ACTIVE` / `DISABLED`). Não regenera o secret.
Parâmetros de path
| Nome | Exemplo |
|---|---|
instance |
dac3a956-4e8b-4d76-8caf-fed98dfc8b05 |
Request
Headers
{
"Accept": "application/json",
"Authorization": "Bearer sk_live_0123456789abcdef0123456789abcdef0123456789abcdef",
"Content-Type": "application/json"
}
Body (JSON)
{
"events": [
"message.received",
"message.sent",
"message.failed"
],
"status": "ACTIVE"
}
Exemplos de código
curl -sS -X PATCH "https://api.instvia.com/api/v1/instances/dac3a956-4e8b-4d76-8caf-fed98dfc8b05/webhook" \
-H "Accept: application/json" \
-H "Authorization: Bearer sk_live_0123456789abcdef0123456789abcdef0123456789abcdef" \
-H "Content-Type: application/json" \
-d '{
"events": [
"message.received",
"message.sent",
"message.failed"
],
"status": "ACTIVE"
}'
const response = await fetch('https://api.instvia.com/api/v1/instances/dac3a956-4e8b-4d76-8caf-fed98dfc8b05/webhook', {
method: 'PATCH',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: 'Bearer sk_live_0123456789abcdef0123456789abcdef0123456789abcdef',
},
body: JSON.stringify({"events":["message.received","message.sent","message.failed"],"status":"ACTIVE"}),
});
const data = await response.json();
console.log(data);
<?php
$payload = array (
'events' =>
array (
0 => 'message.received',
1 => 'message.sent',
2 => 'message.failed',
),
'status' => 'ACTIVE',
);
$ch = curl_init('https://api.instvia.com/api/v1/instances/dac3a956-4e8b-4d76-8caf-fed98dfc8b05/webhook');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_HTTPHEADER => [
'Accept: application/json',
'Authorization: Bearer sk_live_0123456789abcdef0123456789abcdef0123456789abcdef',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode($payload),
]);
$body = curl_exec($ch);
curl_close($ch);
\$data = json_decode($body, true);
Response 200
{
"success": true,
"data": {
"id": "c3d4e5f6-a7b8-9012-cdef-123456789012",
"url": "https://erp.exemplo.com/hooks/instvia",
"events": [
"message.received",
"message.sent",
"message.failed"
],
"status": "ACTIVE"
}
}
Response 401
{
"success": false,
"error": {
"code": "UNAUTHENTICATED",
"message": "Invalid API key."
}
}