> ## Documentation Index
> Fetch the complete documentation index at: https://docs.enablementstudio.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Webhooks

> Receive signed HMAC-SHA256 HTTPS callbacks when asynchronous kit drafts finish or fail.

Pro accounts can register up to **5** HTTPS webhook endpoints in **Settings → API keys** (`/settings/api#webhooks`) to receive real-time notifications when background `/api/v1/runs` jobs complete or fail.

## Endpoint requirements

* **HTTPS required:** URLs must start with `https://`, include a public hostname, and be `500` characters or fewer.
* **SSRF protection:** Embedded credentials (`user:pass@`), loopback addresses, private network ranges, and cloud metadata hosts are rejected at registration time.
* **Signing secret:** Each endpoint receives a unique `whsec_...` secret revealed once upon creation so your receiver can verify payload authenticity.

## Subscribed events

| Event | Trigger | `data` fields |
| - | - | - |
| `run.completed` | An asynchronous kit run finishes (`done`) | `run_id`, `product`, `status`, `location`, `url` |
| `run.failed` | An asynchronous kit run fails (`failed`) | `run_id`, `product`, `status`, `error` |

Every delivery sends a `POST` request with `Content-Type: application/json; charset=utf-8` and these headers:

* `X-Enablement-Event` — Event name (`run.completed` or `run.failed`)
* `X-Enablement-Delivery` — Unique delivery identifier (`deliv_...`)
* `X-Enablement-Signature` — Signature header formatted as `t=<unix_seconds>,v1=<hex_hmac_sha256>`

### Example payload

```json theme={null}
{
  "id": "deliv_9f2a1c4b8e7d6a5c3b1f0e2d",
  "event": "run.completed",
  "created_at": "2026-11-30T12:00:00Z",
  "data": {
    "run_id": "run_01J...",
    "product": "role",
    "status": "done",
    "location": "/kit/42",
    "url": "https://enablementstudio.ai/kit/42"
  }
}
```

## Verifying signatures

Compute the HMAC-SHA256 digest using your endpoint's `whsec_...` secret over the UTF-8 signed string `{timestamp}.{raw_body}` (without re-formatting or re-serializing JSON), reject timestamps older than `300` seconds (`5` minutes), and compare hex signatures in constant time.

```python Python theme={null}
import hashlib
import hmac
import time


def verify_enablement_webhook(
    raw_body: bytes,
    signature_header: str,
    secret: str,
    *,
    tolerance_seconds: int = 300,
) -> bool:
    parts = dict(
        item.strip().split("=", 1)
        for item in signature_header.split(",")
        if "=" in item
    )
    timestamp = int(parts.get("t", "0") or "0")
    v1_hex = parts.get("v1", "").lower()
    if not timestamp or not v1_hex:
        return False
    if abs(int(time.time()) - timestamp) > tolerance_seconds:
        return False
    signed = f"{timestamp}.".encode("utf-8") + raw_body
    expected = hmac.new(secret.encode("utf-8"), signed, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, v1_hex)
```

```typescript TypeScript (Node.js) theme={null}
import crypto from "node:crypto";

export function verifyEnablementWebhook(
  rawBody: Buffer,
  signatureHeader: string,
  secret: string,
  toleranceSeconds = 300,
): boolean {
  const parts = Object.fromEntries(
    signatureHeader
      .split(",")
      .map((s) => s.trim().split("=", 2))
      .filter((pair): pair is [string, string] => pair.length === 2),
  );
  const ts = Number(parts.t);
  const v1 = (parts.v1 ?? "").toLowerCase();
  if (!Number.isInteger(ts) || !/^[0-9a-f]{64}$/.test(v1)) {
    return false;
  }
  if (Math.abs(Math.floor(Date.now() / 1000) - ts) > toleranceSeconds) {
    return false;
  }
  const signed = Buffer.concat([Buffer.from(`${ts}.`, "utf8"), rawBody]);
  const expected = crypto.createHmac("sha256", secret).update(signed).digest("hex");
  return crypto.timingSafeEqual(Buffer.from(expected, "hex"), Buffer.from(v1, "hex"));
}
```

> [!TIP]
>
> You can temporarily **Pause** a webhook endpoint in **Settings → API keys** without rotating its `whsec_...` secret, or **Delete** it to stop deliveries permanently.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.