# Webhook events

Every event your app's webhook endpoints receive, with its headers and an example body.

Source: https://clipmux.com/docs/reference/webhooks

Each app's endpoints receive its videos' events as a `POST` with a JSON body. Any 2xx is success; redirects are not followed. Delivery is at least once and unordered, and retries back off for 24 hours; after that, catch up with `GET /v1/assets?updated_since=`.

## Headers [#headers]

| Header | Description |
| --- | --- |
| `X-Webhook-Event` | string |
| `X-Webhook-Id` | string |
| `X-Webhook-Timestamp` | string |
| `X-Webhook-Signature` | sha256= and the hex HMAC-SHA256 of "\{timestamp\}.\{raw body\}", keyed with the endpoint secret (whsec_…, prefix included). |

## Verify a delivery [#verify-a-delivery]

1. Read the raw body before any JSON parsing.
2. Compute HMAC-SHA256 of `{X-Webhook-Timestamp}.{raw body}` with the endpoint secret (`whsec_…`, prefix included) as the key, and compare its hex with `X-Webhook-Signature` after `sha256=`, in constant time.
3. Reject a timestamp more than 300 seconds from your clock.
4. Dedupe on `X-Webhook-Id`, then re-fetch the asset before acting on it.

With the Node SDK, `clipmux.webhooks.verify` does all four. A receiver in any language can test itself against the [webhook test vectors](https://github.com/visheshgubrani/clipmux/blob/main/internal/webhooks/testdata/vectors.json): the same secret, clock, body and headers must give each case its `valid` and `reason`.

## The event body [#the-event-body]

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes | The event ID (evt_...), the same as X-Webhook-Id. Dedupe on it. |
| `type` | "video.asset.ready", "video.asset.updated", "video.asset.errored", "video.asset.reencode_failed", "video.asset.deleted", "video.asset.track.ready", "video.asset.track.errored", "video.asset.track.deleted" | yes |  |
| `created_at` | string (date-time) | yes |  |
| `data` | Asset | yes | The asset when the event was made. Re-fetch it before acting. |
| `job` | object | no | The job behind the event, for re-encodes. |
| `track` | object | no | The track, for track events. |

## `video.asset.ready` [#videoassetready]

The video is ready to play: its first encode is done and published. Delivery is at least once and unordered: verify `X-Webhook-Signature` over the raw body, reject a timestamp more than 300 s off, dedupe on `X-Webhook-Id`, and re-fetch the asset before acting on it. Retries back off for 24 hours.

```json
{
  "id": "evt_01j2ef9545dh466aggzfdgtejb",
  "type": "video.asset.ready",
  "created_at": "2026-11-18T09:34:12Z",
  "data": {
    "id": "ast_01jhsze3w2mhtbzr5qv1w5xy68",
    "app_id": "app_01j6hrm8vmt8f27hd13py42rdc",
    "status": "ready",
    "version": 4,
    "passthrough": "lesson_42",
    "title": "Lesson 42: Sorting",
    "base_url": "https://media.example.com",
    "playback_ids": [
      {
        "id": "pid_01j88d4vyy93fwe7p3aqr8kcqz",
        "policy": "signed",
        "playable": true,
        "status": "active"
      }
    ],
    "duration_seconds": 1830.4,
    "tracks": [
      {
        "id": "trk_01j0qtsj1vyp4dyn7fsdkb9t8q",
        "kind": "subtitles",
        "source": "generated",
        "status": "ready",
        "language": "en",
        "name": "English"
      },
      {
        "id": "trk_01jbz1ke29rzfnpwz5grhd401k",
        "kind": "chapters",
        "source": "generated",
        "status": "ready"
      }
    ],
    "created_at": "2026-11-18T09:30:00Z",
    "updated_at": "2026-11-18T09:34:12Z"
  }
}
```

## `video.asset.updated` [#videoassetupdated]

The asset changed after it was ready: a re-encode finished, its title changed, a playback ID was published, or it moved storage. Re-fetch and keep the highest `version`. Delivery is at least once and unordered: verify `X-Webhook-Signature` over the raw body, reject a timestamp more than 300 s off, dedupe on `X-Webhook-Id`, and re-fetch the asset before acting on it. Retries back off for 24 hours.

```json
{
  "id": "evt_01j2ef9545dh466aggzfdgtejb",
  "type": "video.asset.updated",
  "created_at": "2026-11-18T09:34:12Z",
  "data": {
    "id": "ast_01jhsze3w2mhtbzr5qv1w5xy68",
    "app_id": "app_01j6hrm8vmt8f27hd13py42rdc",
    "status": "ready",
    "version": 4,
    "passthrough": "lesson_42",
    "title": "Lesson 42: Sorting",
    "base_url": "https://media.example.com",
    "playback_ids": [
      {
        "id": "pid_01j88d4vyy93fwe7p3aqr8kcqz",
        "policy": "signed",
        "playable": true,
        "status": "active"
      }
    ],
    "duration_seconds": 1830.4,
    "tracks": [
      {
        "id": "trk_01j0qtsj1vyp4dyn7fsdkb9t8q",
        "kind": "subtitles",
        "source": "generated",
        "status": "ready",
        "language": "en",
        "name": "English"
      },
      {
        "id": "trk_01jbz1ke29rzfnpwz5grhd401k",
        "kind": "chapters",
        "source": "generated",
        "status": "ready"
      }
    ],
    "created_at": "2026-11-18T09:30:00Z",
    "updated_at": "2026-11-18T09:34:12Z"
  }
}
```

## `video.asset.errored` [#videoasseterrored]

The video can't be played: the upload, import or first encode failed. `data.error_code` says why. Delivery is at least once and unordered: verify `X-Webhook-Signature` over the raw body, reject a timestamp more than 300 s off, dedupe on `X-Webhook-Id`, and re-fetch the asset before acting on it. Retries back off for 24 hours.

```json
{
  "id": "evt_01j2ef9545dh466aggzfdgtejb",
  "type": "video.asset.errored",
  "created_at": "2026-11-18T09:34:12Z",
  "data": {
    "id": "ast_01jhsze3w2mhtbzr5qv1w5xy68",
    "app_id": "app_01j6hrm8vmt8f27hd13py42rdc",
    "status": "errored",
    "version": 2,
    "passthrough": "lesson_42",
    "title": "Lesson 42: Sorting",
    "base_url": "https://media.example.com",
    "playback_ids": [
      {
        "id": "pid_01j88d4vyy93fwe7p3aqr8kcqz",
        "policy": "signed",
        "playable": true,
        "status": "active"
      }
    ],
    "duration_seconds": null,
    "tracks": [],
    "created_at": "2026-11-18T09:30:00Z",
    "updated_at": "2026-11-18T09:30:00Z",
    "error_code": "unsupported_source"
  }
}
```

## `video.asset.reencode_failed` [#videoassetreencode_failed]

A re-encode failed. The video keeps playing its previous output; `job.error_code` says why. Delivery is at least once and unordered: verify `X-Webhook-Signature` over the raw body, reject a timestamp more than 300 s off, dedupe on `X-Webhook-Id`, and re-fetch the asset before acting on it. Retries back off for 24 hours.

```json
{
  "id": "evt_01j2ef9545dh466aggzfdgtejb",
  "type": "video.asset.reencode_failed",
  "created_at": "2026-11-18T09:34:12Z",
  "data": {
    "id": "ast_01jhsze3w2mhtbzr5qv1w5xy68",
    "app_id": "app_01j6hrm8vmt8f27hd13py42rdc",
    "status": "ready",
    "version": 4,
    "passthrough": "lesson_42",
    "title": "Lesson 42: Sorting",
    "base_url": "https://media.example.com",
    "playback_ids": [
      {
        "id": "pid_01j88d4vyy93fwe7p3aqr8kcqz",
        "policy": "signed",
        "playable": true,
        "status": "active"
      }
    ],
    "duration_seconds": 1830.4,
    "tracks": [
      {
        "id": "trk_01j0qtsj1vyp4dyn7fsdkb9t8q",
        "kind": "subtitles",
        "source": "generated",
        "status": "ready",
        "language": "en",
        "name": "English"
      },
      {
        "id": "trk_01jbz1ke29rzfnpwz5grhd401k",
        "kind": "chapters",
        "source": "generated",
        "status": "ready"
      }
    ],
    "created_at": "2026-11-18T09:30:00Z",
    "updated_at": "2026-11-18T09:34:12Z"
  },
  "job": {
    "id": "job_01jq68ea3qk8sxe3rv83fez7sf",
    "kind": "reencode",
    "error_code": "transcode_failed"
  }
}
```

## `video.asset.deleted` [#videoassetdeleted]

The video was deleted, and its playback has stopped. Delivery is at least once and unordered: verify `X-Webhook-Signature` over the raw body, reject a timestamp more than 300 s off, dedupe on `X-Webhook-Id`, and re-fetch the asset before acting on it. Retries back off for 24 hours.

```json
{
  "id": "evt_01j2ef9545dh466aggzfdgtejb",
  "type": "video.asset.deleted",
  "created_at": "2026-11-18T09:34:12Z",
  "data": {
    "id": "ast_01jhsze3w2mhtbzr5qv1w5xy68",
    "app_id": "app_01j6hrm8vmt8f27hd13py42rdc",
    "status": "deleted",
    "version": 4,
    "passthrough": "lesson_42",
    "title": "Lesson 42: Sorting",
    "base_url": "https://media.example.com",
    "playback_ids": [
      {
        "id": "pid_01j88d4vyy93fwe7p3aqr8kcqz",
        "policy": "signed",
        "playable": true,
        "status": "active"
      }
    ],
    "duration_seconds": 1830.4,
    "tracks": [
      {
        "id": "trk_01j0qtsj1vyp4dyn7fsdkb9t8q",
        "kind": "subtitles",
        "source": "generated",
        "status": "ready",
        "language": "en",
        "name": "English"
      },
      {
        "id": "trk_01jbz1ke29rzfnpwz5grhd401k",
        "kind": "chapters",
        "source": "generated",
        "status": "ready"
      }
    ],
    "created_at": "2026-11-18T09:30:00Z",
    "updated_at": "2026-11-18T09:34:12Z"
  }
}
```

## `video.asset.track.ready` [#videoassettrackready]

A subtitles or chapters track is ready. `track` names it. Delivery is at least once and unordered: verify `X-Webhook-Signature` over the raw body, reject a timestamp more than 300 s off, dedupe on `X-Webhook-Id`, and re-fetch the asset before acting on it. Retries back off for 24 hours.

```json
{
  "id": "evt_01j2ef9545dh466aggzfdgtejb",
  "type": "video.asset.track.ready",
  "created_at": "2026-11-18T09:34:12Z",
  "data": {
    "id": "ast_01jhsze3w2mhtbzr5qv1w5xy68",
    "app_id": "app_01j6hrm8vmt8f27hd13py42rdc",
    "status": "ready",
    "version": 4,
    "passthrough": "lesson_42",
    "title": "Lesson 42: Sorting",
    "base_url": "https://media.example.com",
    "playback_ids": [
      {
        "id": "pid_01j88d4vyy93fwe7p3aqr8kcqz",
        "policy": "signed",
        "playable": true,
        "status": "active"
      }
    ],
    "duration_seconds": 1830.4,
    "tracks": [
      {
        "id": "trk_01j0qtsj1vyp4dyn7fsdkb9t8q",
        "kind": "subtitles",
        "source": "generated",
        "status": "ready",
        "language": "en",
        "name": "English"
      },
      {
        "id": "trk_01jbz1ke29rzfnpwz5grhd401k",
        "kind": "chapters",
        "source": "generated",
        "status": "ready"
      }
    ],
    "created_at": "2026-11-18T09:30:00Z",
    "updated_at": "2026-11-18T09:34:12Z"
  },
  "track": {
    "id": "trk_01j0qtsj1vyp4dyn7fsdkb9t8q",
    "kind": "subtitles"
  }
}
```

## `video.asset.track.errored` [#videoassettrackerrored]

A track couldn't be made. `track.error_code` says why, for example `no_audio`. Delivery is at least once and unordered: verify `X-Webhook-Signature` over the raw body, reject a timestamp more than 300 s off, dedupe on `X-Webhook-Id`, and re-fetch the asset before acting on it. Retries back off for 24 hours.

```json
{
  "id": "evt_01j2ef9545dh466aggzfdgtejb",
  "type": "video.asset.track.errored",
  "created_at": "2026-11-18T09:34:12Z",
  "data": {
    "id": "ast_01jhsze3w2mhtbzr5qv1w5xy68",
    "app_id": "app_01j6hrm8vmt8f27hd13py42rdc",
    "status": "ready",
    "version": 4,
    "passthrough": "lesson_42",
    "title": "Lesson 42: Sorting",
    "base_url": "https://media.example.com",
    "playback_ids": [
      {
        "id": "pid_01j88d4vyy93fwe7p3aqr8kcqz",
        "policy": "signed",
        "playable": true,
        "status": "active"
      }
    ],
    "duration_seconds": 1830.4,
    "tracks": [
      {
        "id": "trk_01j0qtsj1vyp4dyn7fsdkb9t8q",
        "kind": "subtitles",
        "source": "generated",
        "status": "ready",
        "language": "en",
        "name": "English"
      },
      {
        "id": "trk_01jbz1ke29rzfnpwz5grhd401k",
        "kind": "chapters",
        "source": "generated",
        "status": "ready"
      }
    ],
    "created_at": "2026-11-18T09:30:00Z",
    "updated_at": "2026-11-18T09:34:12Z"
  },
  "track": {
    "id": "trk_01j0qtsj1vyp4dyn7fsdkb9t8q",
    "kind": "subtitles",
    "error_code": "no_audio"
  }
}
```

## `video.asset.track.deleted` [#videoassettrackdeleted]

A track was deleted. Delivery is at least once and unordered: verify `X-Webhook-Signature` over the raw body, reject a timestamp more than 300 s off, dedupe on `X-Webhook-Id`, and re-fetch the asset before acting on it. Retries back off for 24 hours.

```json
{
  "id": "evt_01j2ef9545dh466aggzfdgtejb",
  "type": "video.asset.track.deleted",
  "created_at": "2026-11-18T09:34:12Z",
  "data": {
    "id": "ast_01jhsze3w2mhtbzr5qv1w5xy68",
    "app_id": "app_01j6hrm8vmt8f27hd13py42rdc",
    "status": "ready",
    "version": 4,
    "passthrough": "lesson_42",
    "title": "Lesson 42: Sorting",
    "base_url": "https://media.example.com",
    "playback_ids": [
      {
        "id": "pid_01j88d4vyy93fwe7p3aqr8kcqz",
        "policy": "signed",
        "playable": true,
        "status": "active"
      }
    ],
    "duration_seconds": 1830.4,
    "tracks": [
      {
        "id": "trk_01j0qtsj1vyp4dyn7fsdkb9t8q",
        "kind": "subtitles",
        "source": "generated",
        "status": "ready",
        "language": "en",
        "name": "English"
      },
      {
        "id": "trk_01jbz1ke29rzfnpwz5grhd401k",
        "kind": "chapters",
        "source": "generated",
        "status": "ready"
      }
    ],
    "created_at": "2026-11-18T09:30:00Z",
    "updated_at": "2026-11-18T09:34:12Z"
  },
  "track": {
    "id": "trk_01j0qtsj1vyp4dyn7fsdkb9t8q",
    "kind": "subtitles"
  }
}
```
