Webhooks
HTTPS-Endpunkte für link.visit, link.download und link.play, zugestellt über Svix.
HTTPS-Endpunkte. Nur HTTPS. Kein localhost und keine privaten IPs. Bis zu 10 pro Account.
Events: link.visit, link.download, link.play. Das Secret hat das Format whsec_… und wird beim Erstellen bzw. Rotieren nur einmal angezeigt. Bewahre es gut auf. Pack es niemals in den JSON-Body.
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 und get geben nur secretHint zurück (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 ist die Variante, die die besuchende Person bekommen hat (main bei Links mit nur einer Variante).
Header bei jeder Zustellung (Svix-Retries verwenden dieselbe ID erneut):
svix-idsvix-timestamp(Unix-Sekunden)svix-signature(v1,<base64 hmac>)
Signierter Inhalt: {id}.{timestamp}.{raw body} per HMAC-SHA256. Secret-Format: whsec_ + Base64.
Verifizieren
Zustellungen werden über Svix verschickt und folgen der Standard Webhooks-Spezifikation. Verifiziere sie mit dem Paket svix (wie bei Clerk und 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;
}
