Webhooks
Testar um endpoint de webhook
Envia um evento ping assinado para o URL do endpoint, com os mesmos cabeçalhos e regras de repetição das entregas reais.
POST https://api.diska.ai/v1/webhook-endpoints/{endpoint_id}/test
Âmbito: webhooks:manage
Funciona mesmo com o endpoint desactivado, e uma falha no teste não conta para a desactivação automática.
Parâmetros
No caminho
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
endpoint_id | string | Sim | Identificador do endpoint. |
Exemplos
curl -X POST "https://api.diska.ai/v1/webhook-endpoints/<endpoint_id>/test" \
-H "Authorization: Bearer $DISKA_API_KEY"
import os
import requests
response = requests.post(
"https://api.diska.ai/v1/webhook-endpoints/<endpoint_id>/test",
headers={"Authorization": f"Bearer {os.environ['DISKA_API_KEY']}"},
timeout=30,
)
response.raise_for_status()
print(response.json())
// Node.js 18 ou superior, num ficheiro .mjs
const response = await fetch('https://api.diska.ai/v1/webhook-endpoints/<endpoint_id>/test', {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.DISKA_API_KEY}` }
})
if (!response.ok) throw new Error(`${response.status} ${await response.text()}`)
console.log(await response.json())
<?php
$ch = curl_init('https://api.diska.ai/v1/webhook-endpoints/<endpoint_id>/test');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('DISKA_API_KEY')],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);
if ($status >= 400) {
throw new RuntimeException("HTTP $status: $body");
}
print_r(json_decode($body, true));
Experimentar
Envie o pedido a partir desta página, com a sua chave. A chave fica só nesta página: não é guardada e só é enviada para api.diska.ai. Use uma chave de teste com os âmbitos mínimos.
POST
https://api.diska.ai/v1/webhook-endpoints/{endpoint_id}/testComeça por dsk_. Fica só neste separador do browser.
path
Introduza uma chave API (dsk_…).
Resposta 200
| Campo | Tipo | Descrição |
|---|---|---|
status | string | delivered, failed ou blocked (o URL passou a apontar para um endereço não permitido). |
attempts | integer | Tentativas feitas. |
http_status | integer | null | Código HTTP que o seu receptor devolveu. |
error | string | Motivo da falha, só quando status não é delivered. |
{
"status": "delivered",
"attempts": 1,
"http_status": 200
}
Erros
| Código | Quando |
|---|---|
404 | Endpoint não encontrado. |
Os erros comuns a todos os endpoints (401, 403, 422, 429 e 5xx) estão em Erros.

