A webhook sends a signed `POST` to your HTTPS endpoint whenever a session is created, from any source (the dashboard, the CLI, the API, and agents).

## Create a webhook

```bash
curl https://api.ellipsis.dev/v1/webhooks -H "Authorization: Bearer $ELLIPSIS_API_TOKEN" -H "Content-Type: application/json" -d '{"url": "https://example.com/hooks/ellipsis", "events": ["session.create"]}'
```

The response includes a `secret` that starts with `whsec_`. Save it: it's shown only once. To change it, delete the webhook and create a new one.

The URL must be public HTTPS on port 443 or 8443. An account can have up to 3 webhooks.

## Activate it

1. Send a test event with `POST /v1/webhooks/{id}/ping`. Your endpoint must answer with HTTP 200.
2. Open **Webhooks** and choose **Request activation**.

Ellipsis turns the webhook on after reviewing the request. Until then it receives only pings.

## Events

| Event | Sent when |
| --- | --- |
| `session.create` | A session is created |
| `webhook.ping` | You call the ping endpoint; always sent |

Every delivery has the same envelope. For `session.create`, `data.session` is the object `GET /v1/sessions/{id}` returns:

```json
{
  "id": "event_0f8e2c",
  "type": "session.create",
  "created_at": "2026-09-22T17:03:11.482913Z",
  "api_version": "v1",
  "data": {
    "session": {
      "id": "session_4b1d9a",
      "source": "api",
      "budget": {
        "limit": 500000,
        "source": "account"
      },
      "status": "queued",
      "error": null
    }
  }
}
```

This example is shortened; real IDs are longer, and `session` has every field.

## Verify signatures

Each request has 3 headers:

| Header | Value |
| --- | --- |
| `webhook-id` | The event ID; the same on every retry |
| `webhook-timestamp` | Unix seconds when this attempt was sent |
| `webhook-signature` | `v1,` followed by a base64 HMAC-SHA256 signature |

To verify, base64-decode your secret without its `whsec_` prefix, and sign `{webhook-id}.{webhook-timestamp}.{raw body}` with it. Use the raw request bytes, not re-serialized JSON:

```python
import base64
import hashlib
import hmac
import time

def verify(secret: str, headers: dict[str, str], body: bytes) -> bool:
    event_id = headers["webhook-id"]
    timestamp = headers["webhook-timestamp"]
    if abs(time.time() - int(timestamp)) > 300:
        return False
    key = base64.b64decode(secret.removeprefix("whsec_"))
    signed = f"{event_id}.{timestamp}.".encode() + body
    expected = base64.b64encode(hmac.new(key, signed, hashlib.sha256).digest()).decode()
    return any(
        hmac.compare_digest(expected, signature.removeprefix("v1,"))
        for signature in headers["webhook-signature"].split()
    )
```

```typescript
import { createHmac, timingSafeEqual } from 'node:crypto';

export function verify(secret: string, headers: Headers, body: string): boolean {
  const eventId = headers.get('webhook-id') ?? '';
  const timestamp = headers.get('webhook-timestamp') ?? '';
  if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false;
  const key = Buffer.from(secret.replace(/^whsec_/, ''), 'base64');
  const expected = createHmac('sha256', key)
    .update(`${eventId}.${timestamp}.${body}`)
    .digest('base64');
  return (headers.get('webhook-signature') ?? '').split(' ').some((signature) => {
    const value = Buffer.from(signature.replace(/^v1,/, ''));
    return value.length === expected.length && timingSafeEqual(value, Buffer.from(expected));
  });
}
```

These examples reject requests older than 5 minutes.

## Delivery

- Any 2xx response within 10 seconds counts as delivered. Pings need exactly 200.
- A failed delivery is retried after 1 minute and again after 10 minutes, then marked failed.
- Events can arrive out of order or more than once; use `webhook-id` to skip duplicates.
- `GET /v1/webhooks/deliveries` lists the last 7 days of deliveries, and `GET /v1/webhooks/deliveries/{id}` shows one with its payload and attempts.
