---
title: "Webhooks and events"
description: "Get Vigiora events as they happen, by live stream or signed webhooks — endpoints, event types, signature checks, retries and resuming."
url: https://vigiora.com/docs/developers/webhooks-and-events
updated: 2026-11-25T11:37:01.000Z
---

# Webhooks and events

> Get Vigiora events as they happen, by live stream or signed webhooks — endpoints, event types, signature checks, retries and resuming.

API v1 can tell your systems what happens on the server, so you don't have to poll. There are three ways to get events, all from the same event bus:

| Need | Use |
| --- | --- |
| A live feed in a script or dashboard | The **event stream** (Server-Sent Events). |
| Vigiora calls your server when something happens | **Webhooks** with signed deliveries. |
| Catch up on what you missed | The **event log** (last 7 days). |

All three need an API key with the `events:read` scope (webhooks have their own scopes, see below). See [Authentication and scopes](https://vigiora.com/docs/developers/api-authentication).

## Events

Every event has the same envelope:

```json
{
  "id": "01JBXK6P3ZQ8R4V2M7N9T5W1YA",
  "type": "alert.created",
  "time": "2026-10-31T09:30:00Z",
  "camera_id": 3,
  "data": { }
}
```

`id` is a 26-character ULID, ordered by time. `camera_id` is `null` for events that belong to no camera. `data` is small (ids, labels, short text) and never holds secrets. Ignore fields and event types you don't know: new ones can appear within v1.

| Type | When | Extra scope needed |
| --- | --- | --- |
| `alert.created` | An alert fired. From 1.6.13, `data.has_snapshot` says whether it has a snapshot. | `alerts:read` |
| `alert.acknowledged` | An alert was acknowledged. | `alerts:read` |
| `guardian.event` | A Guardian rule matched. From 1.6.13, `data` also has `has_frame`, `has_clip`, `detections`, `detector_checked`, `person_present_seconds` and `person_present` (`true`, `false`, or `null` when no detector could tell), so you don't need to fetch the entry. | `guardian:read` |
| `motion.started`, `motion.ended` | Real motion from motion detection (from 1.6.13): `started` on the first motion, `ended` after 30 seconds without any. `data` has `started_at`, `last_motion_at` and `duration_seconds`. | `cameras:read` |
| `presence.changed` | The object detector says a `label` (`person`) came into (`present: true`) or left (`false`) the camera's view (from 1.6.13). `reason` is `detector`, or `detector_silent` when the detector stopped reporting while someone was in view. | `cameras:read` |
| `camera.online`, `camera.offline` | A camera's health changed (from 1.6.8): `offline` when a recording camera stops writing video, or a camera that doesn't record stops answering on its stream port; `online` when it recovers. A camera going between online and `standby` (not recording, nobody watching) sends nothing. `data.status` is `live`, `standby` or `idle`. | `cameras:read` |
| `camera.moved`, `ptz.moved` | A camera was moved to a new address, or a PTZ camera moved. | `cameras:read` |
| `recording.started`, `recording.stopped` | Recording began or ended on a camera. | `recordings:read` |
| `clip.ready`, `clip.failed` | A clip export finished or failed. | `recordings:read` |
| `settings.changed` | Server settings changed. | `settings:read` |
| `webhook.disabled` | A webhook was switched off after repeated failures. | `webhooks:read` |
| `network.camera_found` | Automatic discovery found a device that looks like a camera and isn't one yet (from 1.6.8). Sent once as a possible camera and once when it is ready for the setup wizard. `data` has `mac`, `ip`, `vendor`, `confidence`, `wizard_ready`, `reasons`, `onvif`, `rtsp_open`, `open_ports`, `first_seen`, `hint` and `hint_code`. | `network:read` (admins, operators) |
| `device.state_changed` | A Home Assistant device shared with Vigiora through the [bridge](https://vigiora.com/docs/home-assistant/bridge) changed (from 1.6.13). `data` has `thing_id`, `entity_id`, `name`, `source`, `capability`, `state`, `ha_state`, `previous_ha_state` and `area`. Sensor values are sent at most every 10 seconds. | `devices:read` (admins, operators) |
| `alert_rule.created`, `alert_rule.updated`, `alert_rule.deleted` | An alert rule was created, changed or deleted through API v1 (from 1.6.10). `data.kind` is `guardian` (with `data.alert_rule_id`) or `label` (with `data.label_alert_rule_id` and `data.label`); `data.fields` names the changed fields, never their values. | `alerts:read` |

Besides `events:read`, you only receive events whose family your key may read. You only get events about cameras you may view; `clip.*` events go to the clip's owner (and admins), and events with no camera go to admins.

## The live stream

```bash
curl -N "https://yourname.vigiora.com/api/v1/events/stream?types=alert.created,camera.offline" \
  -H "X-API-Key: vgk_xxxxxxxx_xxxxxxxxxxxxxxxx"
```

Each event arrives as:

```text
id: 01JBXK6P3ZQ8R4V2M7N9T5W1YA
event: alert.created
data: {"id":"01JBXK6P3ZQ8R4V2M7N9T5W1YA","type":"alert.created", ... }
```

Filters: `types` (comma-separated event types) and `camera_ids` (comma-separated, at most 100).

### Snapshot links in events

From 1.6.13, on the stream and in the event log, `alert.created` with a snapshot, `guardian.event` with a frame, `motion.started`, `presence.changed` (when someone is present) and `camera.online` carry `data.snapshot_url` and `data.snapshot_url_expires_at`. It is a signed link, relative to the server's address and valid for 15 minutes, to the alert's snapshot, the entry's frame or a live snapshot. Show the image without sending your API key. Each reader gets its own link, and it stops working when the key that read it is revoked. Webhook deliveries don't contain links.

### The Things format

`?format=things` (from 1.6.13) sends each event as a [Things](https://vigiora.com/docs/developers/api-v1#things-one-model-for-every-device) envelope with CloudEvents 1.0 attributes: `type` is the capability's event, such as `vigiora.motion.started`, `subject` is the thing, such as `camera:3` or `ha:binary_sensor.back_door`, and `source` is `vigiora://<server id>/things/<thing>`. The SSE `event:` line carries the same type. `types` still filters by the usual event types.

Other frames you will see:

- `: heartbeat`, a comment every 15 seconds.
- `event: overflow` with `{"dropped": n}`: your stream fell behind and lost events. Reconnect with `Last-Event-ID` to fetch them.
- `event: reset`: your `Last-Event-ID` is older than the log. Re-read current state.
- `event: shutdown`: the server is stopping.

A stream lasts about a minute and then ends cleanly. That is normal: reconnect straight away. Limits: 3 open streams per key and 200 per server (`429 stream_limit`).

### Resume without missing events

Send the id of the last event you handled as the `Last-Event-ID` header (or `?last_event_id=`). The server replays every event after it first, from memory for recent ones and from the log for older ones, then continues live. Browsers' `EventSource` does this by itself. In a script, keep the last id and send it on each reconnect:

```bash
#!/bin/sh
LAST=""
while true; do
  curl -sN "https://yourname.vigiora.com/api/v1/events/stream" \
    -H "X-API-Key: $KEY" ${LAST:+-H "Last-Event-ID: $LAST"} |
  while read -r line; do
    case "$line" in id:*) LAST="${line#id: }" ;; data:*) echo "${line#data: }" ;; esac
  done
  sleep 1
done
```

(In a real script, store `LAST` in a file, since the inner loop runs in a subshell.)

## The event log

`GET /api/v1/events` returns the last 7 days, oldest first, and takes the same filters plus `from` (inclusive) and `to` (exclusive). Page forward with `next_cursor`. It is the place to reconcile after an outage:

```bash
curl -s "https://yourname.vigiora.com/api/v1/events?types=alert.created&from=2026-10-31T00:00:00Z&limit=100" \
  -H "X-API-Key: vgk_xxxxxxxx_xxxxxxxxxxxxxxxx"
```

## Webhooks

A webhook is a URL that Vigiora POSTs matching events to. Only **admins** manage webhooks, with keys that carry `webhooks:read` and `webhooks:write` (admin keys only). From version 1.6.16 they can also do it in the app, under **Settings** → **System** → **Webhooks**, where operators see the list read-only. See [Webhooks](https://vigiora.com/docs/admin/webhooks).

1. **Create the webhook**

   ```bash
   curl -s -X POST https://yourname.vigiora.com/api/v1/webhooks \
     -H "X-API-Key: vgk_xxxxxxxx_xxxxxxxxxxxxxxxx" \
     -H "Content-Type: application/json" \
     -d '{"name":"Alarm panel","url":"https://example.com/vigiora","event_types":["alert.created"],"camera_ids":[]}'
   ```
   An empty `event_types` means every type; an empty `camera_ids` means every camera. The response contains the signing `secret`, **shown only once** (and again when you rotate it). Store it. A server can have up to 50 webhooks.

2. **Send a test**

   `POST /api/v1/webhooks/{id}/actions/test` sends a `webhook.test` event now (one attempt, no retries) and returns the delivery, so you can see the status code or error. A disabled webhook answers `409`.

3. **Verify and answer 2xx**

   Check the signature (below), then answer with any 2xx status within 10 seconds.

From 1.6.16, each webhook in `GET /api/v1/webhooks` carries its newest delivery: `last_delivery_at`, `last_delivery_status` and `last_delivery_code`.

Other operations: `GET /api/v1/webhooks`, `GET`/`PATCH`/`DELETE /api/v1/webhooks/{id}`, `POST .../actions/rotate-secret`, `GET .../deliveries` (the delivery log, 14 days, filter by `status`) and `POST .../deliveries/{id}/actions/redeliver`.

### What Vigiora sends

The body is the event JSON. Headers:

| Header | Value |
| --- | --- |
| `X-Vigiora-Event` | The event type. |
| `X-Vigiora-Delivery` | The delivery id. |
| `X-Vigiora-Timestamp` | Unix seconds when it was sent. |
| `X-Vigiora-Signature` | `sha256=<hex>`, the HMAC-SHA256 of `timestamp + "." + raw body` with your secret. |

### Verify the signature

Compute the HMAC over the **raw** request body (not re-serialised JSON), compare in constant time, and refuse timestamps more than 5 minutes old.

The curl-and-openssl version, with the documented test vector:

```bash
SECRET='whsec_example'
TS='1793439000'
BODY='{"id":"01JBXK6P3ZQ8R4V2M7N9T5W1YA","type":"webhook.test","time":"2026-10-31T09:30:00Z","camera_id":null,"data":{"webhook_id":1}}'
printf '%s.%s' "$TS" "$BODY" | openssl dgst -sha256 -hmac "$SECRET" -hex
# (stdin)= d3970ed3552b5ff43e5d2f309b492adc79512de73ce6b793568894f11b096312
```

In Node:

```js
import crypto from 'node:crypto';

export function verify(secret, headers, rawBody) {
  const ts = headers['x-vigiora-timestamp'];
  if (Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false;
  const expected = crypto.createHmac('sha256', secret).update(`${ts}.${rawBody}`).digest('hex');
  // After a secret rotation the header can hold two signatures: accept either.
  return headers['x-vigiora-signature'].split(',').some((s) => {
    const got = s.trim().replace(/^sha256=/, '');
    return got.length === expected.length &&
      crypto.timingSafeEqual(Buffer.from(got), Buffer.from(expected));
  });
}
```

Or in Python:

```python
import hashlib, hmac, time

def verify(secret: str, headers: dict, raw_body: bytes) -> bool:
    ts = headers["X-Vigiora-Timestamp"]
    if abs(time.time() - int(ts)) > 300:
        return False
    expected = hmac.new(secret.encode(), ts.encode() + b"." + raw_body, hashlib.sha256).hexdigest()
    sigs = [s.strip().removeprefix("sha256=") for s in headers["X-Vigiora-Signature"].split(",")]
    return any(hmac.compare_digest(s, expected) for s in sigs)
```

> **Rotating the secret**
>
> `rotate-secret` takes effect at once. For the next 24 hours deliveries carry two signatures (`sha256=<new>,sha256=<old>`), so you can switch your receiver without losing events. Accept either.

### Delivery, retries and failures

Delivery is **at least once**:

- Deduplicate on the event `id`. A redelivery, or a resend after a server restart, has a new `X-Vigiora-Delivery` but the same event `id`.
- Under heavy database load the server can **drop** events for webhooks before a delivery is queued. The event log still has them, so reconcile from `GET /api/v1/events` if a gap matters.

An answer with a 2xx status within 10 seconds counts as delivered. Your answer's body is never read or stored, and redirects are not followed. Otherwise Vigiora retries 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours and 12 hours after each failure (7 attempts in all), and never later than 24 hours after the event. Each webhook has one attempt in flight at a time. The delivery log shows the status code and a short error class (`timeout`, `refused`, `tls`, `dns`, `blocked`, `connection`, `http_error`).

A failed delivery can be sent again with `redeliver`, which queues the same payload as a new delivery, due at once.

**Auto-disable.** A webhook is switched off only after a sustained run of failures: 24 hours without a single success, or 20 failed attempts spread over at least 6 hours, or at once on `410 Gone`. Test sends never count. When it happens, one `webhook.disabled` event is emitted. Deliveries still waiting are kept as `held`, not lost, and resume when you re-enable the webhook with `PATCH` and `{"enabled": true}` (which also resets its failure count).

### Which addresses are allowed (SSRF protection)

Webhook URLs must be `https`. Vigiora checks the address a name resolves to on every attempt and connects only to that checked address, so DNS tricks don't work.

- **Private (LAN) addresses and plain `http`** are refused unless the webhook has `allow_insecure: true`. Only an admin session, or a key with the `admin` scope, can set it.
- **Always refused, even with `allow_insecure`:** the server's own addresses (every interface, loopback and its container network), its service ports on private addresses, link-local and cloud-metadata addresses, the mesh ranges, multicast, unspecified and reserved addresses, and IPv6 forms that embed an IPv4 address.

A refused target shows as `blocked` in the delivery log.

## Protecting recordings from events

A common pattern: on `alert.created`, protect the matching recording so retention never deletes it. See [Protect a recording](https://vigiora.com/docs/developers/api-v1#protect-recordings).

## Without API v1

If you can't use API v1, the internal `/api` still supports polling `GET /api/detections?since=<last Id>&alerts_only=1`, and alert rules can notify people by push or email. See [How alerts reach you](https://vigiora.com/docs/ai/alert-rules#how-alerts-reach-you) and [API keys](https://vigiora.com/docs/developers/api-keys).

---

Source: https://vigiora.com/docs/developers/webhooks-and-events · Last updated 25 Nov 2026, 11:37 UTC
