# Backup Chief webhooks

import {Head} from "zudoku/components";

<Head>
  <title>Webhooks | Backup Chief</title>
</Head>

Backup Chief sends a webhook when backups of a job start failing or recover, a scheduled backup does not start, a run finishes, a server goes offline, an agent update fails, or a download is ready. Use them to page someone when backups break, feed run results into a monitoring tool, or keep another system's list of servers and jobs current without polling the API.

Deliveries are signed, retried, and logged the same way in every Chief Tools product. Read [Receive webhooks](/developers/webhooks) first for verification, responses, retries, and duplicates. This page covers what is specific to Backup Chief.

## Set up an endpoint

Add endpoints under **Settings › Webhooks** in Backup Chief, then send a test event from the endpoint's page. Deliveries come with the `User-Agent` `BackupChief-Webhooks/1.0`.

To set up endpoints from code, use the [webhooks API](/api/backupchief/webhooks) with a token that has the `backupchief:webhooks:write` [scope](/developers/backupchief/scopes#webhooks):

```http
POST /api/v1/webhooks/endpoints HTTP/1.1
Host: backup.chief.app
Authorization: Bearer $TOKEN
Content-Type: application/json

{"url": "https://example.com/webhooks/chief", "description": "Backup alerts", "events": ["backup.failing", "backup.recovered", "backup.missed", "backup.resumed"]}
```

The response includes the endpoint's `secret`. Store it right away. Backup Chief only returns it when the endpoint is created and when you [rotate its secret](/api/backupchief/webhooks#rotate-a-webhook-endpoints-secret). Then [send a test event](/api/backupchief/webhooks#send-a-test-event) to check your receiver. The same API lists event types, events, and deliveries with each attempt's request and response, and resends them.

When an endpoint keeps failing, team members who want webhook notifications get an email. After 5 days of failures Backup Chief disables the endpoint and emails them again.

## Events

Each event's `data.object` is a [`Server`](/api/backupchief/~schemas#server), [`BackupJob`](/api/backupchief/~schemas#backupjob), [`BackupRun`](/api/backupchief/~schemas#backuprun), or [`Download`](/api/backupchief/~schemas#download), as the API returns it when the event happens. Some events add fields next to `object` in `data`.

Each event type below links to its page in the [API reference](/api/backupchief/webhook-events), with the request headers and every field of the payload. The OpenAPI document also lists the events under `webhooks`, so you can generate types for your receiver from it.

### Backup alerts

These events follow the same rules as Backup Chief's alert emails. A job that keeps failing sends `backup.failing` once, not once per run.

| Type | Sent when | Extra `data` fields |
|---|---|---|
| [`backup.failing`](/api/backupchief/webhook-events#backup-failing) | The latest backup of a job failed, finished partially, or was skipped, and the job was not already failing. | `run_id`: the run that failed |
| [`backup.recovered`](/api/backupchief/webhook-events#backup-recovered) | A backup of a failing job completes. | `run_id`: the run that completed, `failing_since`: when the first failed backup finished |
| [`backup.missed`](/api/backupchief/webhook-events#backup-missed) | A scheduled backup has not started 30 minutes after its time. | |
| [`backup.resumed`](/api/backupchief/webhook-events#backup-resumed) | Scheduled backups start on time again after one was missed. | `missed_since`: when Backup Chief noticed the missed backup |

A cancelled backup does not change whether a job is failing. A job on an offline server sends no `backup.missed`, because `server.offline` already covers it. Pausing a job ends its missed backup alert without `backup.resumed`, and revoking a server ends its offline alert without `server.online`.

### Maintenance alerts

Backup Chief tracks each kind of maintenance on its own. A failing full integrity check does not stop the cleanup of old recovery points from counting as healthy.

| Type | Sent when | Extra `data` fields |
|---|---|---|
| [`maintenance.failing`](/api/backupchief/webhook-events#maintenance-failing) | The latest run of one kind of maintenance failed or finished partially, and that kind was not already failing. | `run_id`, `run_kind` |
| [`maintenance.recovered`](/api/backupchief/webhook-events#maintenance-recovered) | A run of that kind completes again. | `run_id`, `run_kind`, `failing_since` |

`run_kind` is a [`BackupRunKind`](/api/backupchief/~schemas#backuprunkind), such as `check_data` for the full integrity check or `prune` for freeing up storage space.

### Runs

| Type | Sent when |
|---|---|
| [`run.finished`](/api/backupchief/webhook-events#run-finished) | The agent reports the result of a backup or maintenance run. |

`run.finished` comes for every run, whatever its result. Read `status` and `result_code` on the run to decide what to do, and `kind` to tell backups from maintenance. A run with the status `unresolved` can report again once its outcome is known, so you may receive a second `run.finished` for the same run. Keep the latest.

A run that never reports a result sends no `run.finished`, for example when someone revokes its server while it runs. [List runs](/api/backupchief/runs#list-runs) to find those.

### Availability

| Type | Sent when | Extra `data` fields |
|---|---|---|
| [`server.offline`](/api/backupchief/webhook-events#server-offline) | An enrolled server's agent has not checked in for 15 minutes. | |
| [`server.online`](/api/backupchief/webhook-events#server-online) | An offline server's agent checks in again. | `offline_since`: when Backup Chief noticed the server went offline |

### Servers

| Type | Sent when |
|---|---|
| [`server.created`](/api/backupchief/webhook-events#server-created) | A server is added. It waits for its agent, with `status` set to `pending`. |
| [`server.enrolled`](/api/backupchief/webhook-events#server-enrolled) | A server's agent enrolls, also when the agent enrolls again with a new enrollment token. |
| [`server.updated`](/api/backupchief/webhook-events#server-updated) | A server is renamed, or its automatic agent updates are turned on or off. |
| [`server.revoked`](/api/backupchief/webhook-events#server-revoked) | A server's agent is revoked. Its backup jobs, runs, and recovery points stay. |
| [`server.deleted`](/api/backupchief/webhook-events#server-deleted) | A server that never enrolled is deleted. `object` is the server as it was right before. |

`enrollment` never appears in webhooks, so enrollment tokens do not leave Backup Chief this way.

### Agent updates

| Type | Sent when | Extra `data` fields |
|---|---|---|
| [`server.agent_update_started`](/api/backupchief/webhook-events#server-agent-update-started) | A person, the API, or the automatic rollout requests an agent update, also when someone retries a failed one. | `command_id`: the update |
| [`server.agent_update_succeeded`](/api/backupchief/webhook-events#server-agent-update-succeeded) | The agent reports the version it was updated to. | `command_id` |
| [`server.agent_update_failed`](/api/backupchief/webhook-events#server-agent-update-failed) | The agent reports that it could not install the update, or did not pick it up within 3 hours. Sent once per attempt. | `command_id`, `result`: why it failed |
| [`agent_rollout.paused`](/api/backupchief/webhook-events#agent-rollout-paused) | The automatic rollout of an agent release paused for your team after too many failed updates. | `failures`: the failed updates since the rollout was last resumed |

Every update that starts ends with `server.agent_update_succeeded` or `server.agent_update_failed`. `object.agent.update` on the server shows the latest update with its `target_version` and `status`. Use `command_id` to match the events of one update.

`result` is an [`AgentUpdateResult`](/api/backupchief/~schemas#agentupdateresult):

- `preflight_failed`: the package repository lacks the target or the current version. The rollout tries again after 6 hours, and this does not count towards pausing it.
- `installation_failed`: the package manager could not install the target version.
- `readiness_failed_rolled_back`: the new agent did not start correctly, and the previous version is back.
- `rollback_failed`: the new agent did not start correctly, and restoring the previous version failed too. The server needs attention.
- `target_not_newer`: the installed agent was already as new as the target.
- `expired`: the agent did not pick the update up within 3 hours, usually because the server was offline. This does not count towards pausing the rollout, so one offline server cannot pause it for your team. The rollout tries the server again once it is back.
- `cancelled`: the server was revoked or re-enrolled before the update finished. This does not count towards pausing the rollout either.

Handle unknown results like a failed update. A server that installs the target version after its update failed, for example by hand, still sends `server.agent_update_succeeded` once the agent reports it.

`agent_rollout.paused` has the release as `data.object`, with its `version`, `url`, and `published_at`. Servers that already updated keep the new version. Resuming the rollout in Backup Chief sends no event.

### Backup jobs

| Type | Sent when | Extra `data` fields |
|---|---|---|
| [`job.created`](/api/backupchief/webhook-events#job-created) | A backup job is created. It stays `pending` until its storage is set up and someone saves its recovery document. | |
| [`job.updated`](/api/backupchief/webhook-events#job-updated) | A job's settings change, such as its name, source, schedule, or retention. | |
| [`job.paused`](/api/backupchief/webhook-events#job-paused) | A job is paused. It runs no backups or maintenance until it is resumed. | |
| [`job.resumed`](/api/backupchief/webhook-events#job-resumed) | A paused job is resumed. | |
| [`job.deleted`](/api/backupchief/webhook-events#job-deleted) | A job and its history are deleted. `object` is the job as it was right before. | `backups_deleted` |

When `backups_deleted` is `false`, the backups stay in your storage, and restic can still restore them with the job's recovery document. When it is `true`, Backup Chief deleted them from storage first. The event then arrives after that deletion finished, which can take a while after the delete request.

### Downloads

| Type | Sent when |
|---|---|
| [`download.ready`](/api/backupchief/webhook-events#download-ready) | A download is prepared. [Create a download URL](/api/backupchief/downloads#create-a-download-url) to fetch it before `expires_at`. |
| [`download.failed`](/api/backupchief/webhook-events#download-failed) | A download could not be prepared. `failure_code` and `failure_message` on the download say why. |

A cancelled or expired download sends no event.

## Examples

### Backups started failing

```json
{
  "id": "event_01m7jq2k8c3xq7d9fz1w5g6ht",
  "type": "backup.failing",
  "timestamp": "2026-11-16T02:04:11.208Z",
  "api_version": "v1",
  "data": {
    "object": {
      "id": "job_01j8q8zk2f4m6n7p9r1s3t5v7x",
      "name": "Website files",
      "status": "active",
      "server": {"id": "server_01j8q8zk2f4m6n7p9r1s3t5v7x", "name": "Web server"},
      ...
    },
    "run_id": "run_01m7jq1w9b1n5e8r2t6y4u7i0o"
  }
}
```

[Get the run](/api/backupchief/runs#get-a-run) with `run_id` to show why it failed. `summary` describes the result, and [the run log](/api/backupchief/runs#get-the-log-of-a-run) has the agent's output.

### A run finished

```json
{
  "id": "event_01m7jq3r5d2r8hk3c6zj9t1x4w",
  "type": "run.finished",
  "timestamp": "2026-11-16T02:04:11.402Z",
  "api_version": "v1",
  "data": {
    "object": {
      "id": "run_01m7jq1w9b1n5e8r2t6y4u7i0o",
      "kind": "backup",
      "trigger": "scheduled",
      "status": "partial",
      "result_code": "unreadable_files",
      "job": {"id": "job_01j8q8zk2f4m6n7p9r1s3t5v7x", "name": "Website files"},
      "started_at": "2026-11-16T02:00:03Z",
      "finished_at": "2026-11-16T02:04:09Z",
      ...
    }
  }
}
```

The full object has every field of the [`BackupRun`](/api/backupchief/~schemas#backuprun) schema. `status`, `kind`, and `result_code` can gain new values. Treat a value you do not recognize as unknown instead of failing.

## Common integrations

- **Paging.** Subscribe to `backup.failing`, `backup.missed`, `maintenance.failing`, `server.offline`, and `agent_rollout.paused`. Close the page on `backup.recovered`, `backup.resumed`, `maintenance.recovered`, and `server.online`.
- **Backup monitoring.** Subscribe to `run.finished` and record each backup's `status` and `finished_at` per job. Alert in your own system when a job has no complete backup for longer than you accept.
- **Inventory sync.** Subscribe to the server and backup job events, and store the object from `data.object`. Use [List servers](/api/backupchief/servers#list-servers) and [List backup jobs](/api/backupchief/backup-jobs#list-backup-jobs) once to load what exists, and again to catch up after your receiver was down for longer than the retries last.

Events are kept for 30 days. For anything older, read the current state from the API.
