Saltar al contenido
LinkdashLinkdash
Español
Esc
↑↓navegar↵abrir⌘Jvista previa
En esta página

Webhooks

Endpoints HTTPS para link.visit, link.download y link.play, entregados por Svix.

Endpoints HTTPS. Solo HTTPS. No se permiten localhost ni IPs privadas. Hasta 10 por cuenta.

Eventos: link.visit, link.download, link.play. El secreto es whsec_… y se muestra una sola vez al crearlo o rotarlo. Guárdalo. Nunca lo pongas en el cuerpo 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 y get solo devuelven 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 es la variante que recibió el visitante (main para links de una sola variante).

Headers en cada entrega (los reintentos de Svix reutilizan el mismo id):

  • svix-id
  • svix-timestamp (segundos unix)
  • svix-signature (v1,<base64 hmac>)

Contenido firmado: {id}.{timestamp}.{raw body} con HMAC-SHA256. Formato del secreto: whsec_ + base64.

Verificación

Las entregas las envía Svix y siguen la especificación Standard Webhooks. Verifícalas con el paquete svix (el mismo que usan Clerk y 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;
}

¿Te ha resultado útil esta página?