Skip to content

Webhook Event Catalog & Schemas

Reference catalog of webhook event types, JSON payload structures, headers, and HMAC signature verification.

Webhook Event Catalog & Schemas

When lifecycle actions occur within your organization, Shaf dispatches signed HTTP POST requests to your registered webhook endpoints. Payloads adhere to deterministic JSON schemas with an HMAC-SHA256 signature for payload verification.


Delivery Headers

Every outgoing webhook request includes standard delivery headers:

Header Value Description
Content-Type application/json JSON payload encoding.
User-Agent Shaf-Webhook/2.0 Identifies the Shaf webhook dispatcher.
X-Shaf-Event e.g. link.clicked Event type constant.
X-Shaf-Delivery del_8f91c4a02e7b... Unique delivery attempt ID for deduplication.
X-Shaf-Signature sha256=9b2a7c... HMAC-SHA256 hex digest computed over the raw request body using your webhook secret.

Base Payload Envelope

All webhook dispatches share this outer envelope structure:

{
  "id": "evt_9823471029384",
  "event": "link.clicked",
  "createdAt": "2026-11-21T18:00:00.000Z",
  "organizationId": "org_91c4a02f",
  "data": {}
}

Event Catalog

Fires in real-time when an edge node successfully resolves and redirects a short link. Validated against LinkClickedWebhookSchema in shared/schemas/webhook.ts.

{
  "id": "evt_clk_8f12a9c0",
  "event": "link.clicked",
  "createdAt": "2026-11-21T18:00:00.000Z",
  "organizationId": "org_91c4a02f",
  "data": {
    "click": {
      "id": "clk_39dfa01e8b",
      "timestamp": "2026-11-21T18:00:00.000Z",
      "country": "US",
      "region": "CA",
      "city": "San Francisco",
      "device": "desktop",
      "browser": "Chrome",
      "os": "macOS",
      "referer": "https://news.ycombinator.com"
    },
    "link": {
      "id": "lnk_98fa01",
      "slug": "summer-promo"
    }
  }
}

Fires when a new short link is provisioned via the REST API, MCP agent, or console.

{
  "id": "evt_crt_71a02b3c",
  "event": "link.created",
  "createdAt": "2026-11-21T18:00:00.000Z",
  "organizationId": "org_91c4a02f",
  "data": {
    "id": "lnk_98fa01",
    "slug": "summer-promo",
    "url": "https://brand.com/products/summer",
    "domain": "link.brand.com",
    "title": "Summer Campaign 2026",
    "tags": ["promo", "summer"]
  }
}

Fires when a link is removed and purged from edge KV caching.

{
  "id": "evt_del_44b1c2d0",
  "event": "link.deleted",
  "createdAt": "2026-11-21T18:00:00.000Z",
  "organizationId": "org_91c4a02f",
  "data": {
    "id": "lnk_98fa01",
    "slug": "summer-promo",
    "domain": "link.brand.com"
  }
}

Fires when Cloudflare for SaaS Domain Control Validation succeeds and the custom domain TLS certificate becomes active.

{
  "id": "evt_dom_99c3a1b0",
  "event": "domain.verified",
  "createdAt": "2026-11-21T18:00:00.000Z",
  "organizationId": "org_91c4a02f",
  "data": {
    "id": "dom_7f8a92b1",
    "domain": "link.brand.com",
    "routingType": "cname",
    "sslStatus": "active"
  }
}

Fires when DNS verification times out or DCV challenge fails.

{
  "id": "evt_dom_err_11a0",
  "event": "domain.error",
  "createdAt": "2026-11-21T18:00:00.000Z",
  "organizationId": "org_91c4a02f",
  "data": {
    "id": "dom_7f8a92b1",
    "domain": "link.brand.com",
    "reason": "CNAME record not pointing to cname.shaf.app"
  }
}

Verifying Webhook Signatures

To ensure payloads originate from Shaf and have not been tampered with in transit, compute the HMAC-SHA256 signature over the raw request body bytes and compare it in constant time against X-Shaf-Signature.

import { createHmac, timingSafeEqual } from "node:crypto";

export function verifyShafWebhook(
  rawBody: string | Buffer,
  signatureHeader: string,
  webhookSecret: string,
): boolean {
  const hmac = createHmac("sha256", webhookSecret);
  hmac.update(rawBody);
  const expectedSignature = `sha256=${hmac.digest("hex")}`;

  if (signatureHeader.length !== expectedSignature.length) {
    return false;
  }

  return timingSafeEqual(
    Buffer.from(signatureHeader),
    Buffer.from(expectedSignature),
  );
}
import hmac
import hashlib

def verify_shaf_webhook(raw_body: bytes, signature_header: str, secret: str) -> bool:
    expected = "sha256=" + hmac.new(
        secret.encode("utf-8"),
        raw_body,
        hashlib.sha256
    ).hexdigest()

    return hmac.compare_digest(signature_header, expected)

Retry Policy & Delivery Schedule

If your endpoint returns an HTTP status outside the 2xx range or times out after 10 seconds, Shaf retries delivery up to 5 times using exponential backoff:

  1. Attempt 1: Immediate
  2. Attempt 2: +15 seconds
  3. Attempt 3: +2 minutes
  4. Attempt 4: +15 minutes
  5. Attempt 5: +1 hour

After 5 failed attempts, the event is marked dead and recorded in the audit log. Webhook endpoints with sustained 100% failure rates over 48 hours are automatically disabled.

Type to search…

↑↓ navigate↵ selectEsc close