Webhooks
Endpoints HTTPS para link.visit, link.download e link.play, entregues pela Svix.
Endpoints HTTPS. Apenas HTTPS. Sem localhost nem IPs privados. Até 10 por conta.
Eventos: link.visit, link.download, link.play. O segredo é whsec_…, mostrado uma única vez ao criar ou renovar. Guarde-o. Nunca o inclua no corpo JSON.
CLI
linkdash webhooks create --url https://example.com/hooks
linkdash webhooks list
linkdash webhooks get <id>
linkdash webhooks rotate <id>
linkdash webhooks delete <id>
list e get devolvem apenas secretHint (whsec_…xxxx).
HTTP
curl https://api.linkdash.dev/v1/webhooks \
-X POST \
-H "Authorization: Bearer ldash_..." \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com/hooks"}'
GET /webhooks, POST /webhooks, GET /webhooks/:id, DELETE /webhooks/:id, POST /webhooks/:id/rotate.
Payload
{
"type": "link.visit",
"timestamp": "2026-08-17T16:00:00.000Z",
"data": { "id": "deck", "kind": "file", "variant": "main", "country": "DE", "referrer": "…" }
}
data.variant é a variante que o visitante recebeu (main para ligações com uma única variante).
Cabeçalhos em cada entrega (as repetições do Svix reutilizam o mesmo id):
svix-idsvix-timestamp(segundos Unix)svix-signature(v1,<hmac base64>)
Conteúdo assinado: {id}.{timestamp}.{corpo bruto} com HMAC-SHA256. Formato do segredo: whsec_ + base64.
Verificar
As entregas são enviadas pela Svix e seguem a especificação Standard Webhooks. Verifique com o pacote svix (o mesmo usado pela Clerk e pela Resend).
npm i svix
import { Webhook, WebhookVerificationError } from "svix";
const wh = new Webhook(process.env.LINKDASH_WEBHOOK_SECRET); // whsec_… shown once
try {
const event = wh.verify(rawBody, {
"svix-id": headers["svix-id"],
"svix-timestamp": headers["svix-timestamp"],
"svix-signature": headers["svix-signature"],
});
// event.type is "link.visit" | "link.download" | "link.play"
} catch (err) {
if (err instanceof WebhookVerificationError) {
// 400 — do not process
}
throw err;
}
