---
title: "Authentication and scopes"
description: "Call API v1 with a scoped API key or a user session, pick the scopes an integration needs, and understand what decides whether a call is allowed."
url: https://vigiora.com/docs/developers/api-authentication
updated: 2026-11-25T11:37:01.000Z
---

# Authentication and scopes

> Call API v1 with a scoped API key or a user session, pick the scopes an integration needs, and understand what decides whether a call is allowed.

Every API v1 call needs a credential: an **API key** for scripts and integrations, or a **user session** for tools a person signs in to.

## Send an API key

Send the key in a header, either way:

```bash
curl -s https://yourname.vigiora.com/api/v1/me \
  -H "Authorization: Bearer vgk_xxxxxxxx_xxxxxxxxxxxxxxxx"

curl -s https://yourname.vigiora.com/api/v1/me \
  -H "X-API-Key: vgk_xxxxxxxx_xxxxxxxxxxxxxxxx"
```

A key is never accepted in the URL. If both headers are sent, `X-API-Key` wins.

`GET /api/v1/me` tells you who the credential is and which scopes it has:

```json
{
  "user": { "id": 7, "username": "automation", "role": "operator" },
  "auth": { "type": "api_key", "key_id": 12, "scoped": true, "scopes": ["cameras:read", "alerts:write"] }
}
```

`auth.type` is `api_key`, `session`, or `oauth` for an AI app that signed in through the [MCP server](https://vigiora.com/docs/developers/mcp). OAuth tokens work only on the MCP endpoint, never on REST.

## Use a user session

Tools a person signs in to can use the same session as the web app:

```bash
curl -s -X POST https://yourname.vigiora.com/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"username":"automation","password":"example-password"}'
```

Send the returned `access_token` as `Authorization: Bearer <token>`. A session has **every scope**; the user's role and camera permissions still apply. On v1 the token is only accepted in the header, never as `?token=`.

## Create a scoped key

Scoped keys are created with `POST /api/v1/api-keys`, which needs a **user session**: an API key can never create, list or revoke keys. That stops a leaked key from minting a successor.

1. **Sign in**

   Get an access token with `POST /api/auth/login` (above).

2. **Create the key**

   Choose a name, the scopes the integration needs, and optionally an expiry:

   ```bash
   curl -s -X POST https://yourname.vigiora.com/api/v1/api-keys \
     -H "Authorization: Bearer <access token>" \
     -H "Content-Type: application/json" \
     -d '{"name":"Alarm panel","scopes":["alerts:write","cameras:read"],"expires_in_days":365}'
   ```

3. **Store the key**

   The response holds the full key in `key`. It is shown **only once**: store it in your integration or a password manager now.

`expires_in_days` (1–3650) or `expires_at` (at most 10 years ahead) set an expiry; without either the key never expires. List your keys with `GET /api/v1/api-keys` and revoke one with `DELETE /api/v1/api-keys/{key_id}`. Admins can list and revoke anyone's keys with `?user_id=`.

> **Keys from the API keys page**
>
> Keys created in **Settings** → **People and access** → **API keys** in the web app have no scopes (read-only or read-write) by default. They work on API v1 with implicit scopes, see [Keys without scopes](#keys-without-scopes). To create a scoped key there, tick **Limit to specific scopes** (from version 1.6.7), or use `POST /api/v1/api-keys`.

## Scopes

A scope is a permission for one family of operations. Give a key only the scopes its integration needs.

| Scope | Grants |
| --- | --- |
| `cameras:read` | List and get cameras, live snapshots, a camera's AI services, audio and stream health, and vigiora-clients (admins, operators). Object recognition on a camera frame or an uploaded image (`detect-objects`, `images/analyze`). Signed live stream and snapshot links (`stream-url`, `snapshot-url`), and the [Things](https://vigiora.com/docs/developers/api-v1#things-one-model-for-every-device) list. |
| `cameras:write` | Add, change, delete, enable and disable cameras, turn AI on and off, change many cameras at once, switch and set a camera's AI services, reference frames, rooms and speakers, and manage vigiora-clients (admins). Includes `cameras:read`. |
| `cameras:control` | PTZ: move, stop, list, save and go to presets, and move a room's camera. Speak and play audio in a room or through a camera's own speaker (`cameras/{camera_id}/actions/speak`), and test a speaker. Includes `cameras:read`. Separate from `cameras:write`, so a joystick integration can't edit cameras. |
| `alerts:read` | List and get alerts, the unacknowledged-alert summary (`GET /alerts/summary`), alert snapshots, recognised faces and their photos, alert rules (camera and room rules), a camera's detection events (with the add-ons' reports) and object tracks, people counts and motion levels. |
| `alerts:write` | Acknowledge and unacknowledge alerts, one or in bulk, send alerts from your own systems (`POST /alerts`), delete alerts, and create, change and delete alert rules. Includes `alerts:read`. |
| `recordings:read` | List recordings, the timeline, the days with recordings, playback, a frame from the recordings (`GET /cameras/{camera_id}/frame`), an alert's recording, clip status and the clip list. Also needed for `detect-objects` on a recorded moment. |
| `recordings:write` | Export and delete clips, get clip download URLs, protect and unprotect recordings. Includes `recordings:read`. |
| `clips:share` | List, create and revoke **public** share links, and live share links of a camera (API 1.109.0). No other scope includes it, except `admin`. |
| `account:read`, `account:write` | From API 1.107.0: the caller's own two-factor status and signed-in devices (`account:read`), and signing a device out (`account:write`). Turning two-factor on or off needs a user session, never a key. OAuth connections (MCP) are never granted these scopes. |
| `guardian:read`, `guardian:write` | Read and search the Guardian log (also per room), an entry's frame and clip, Recently deleted moments (admins, operators), the clip and trash settings, speech transcripts, Guardian conversations and the Briefing. `guardian:write` adds Guardian chat, analysing a camera now, describing an uploaded image, AI Live, compare and plate reading, which use AI credits, and the Briefing's review marks. It also deletes, restores and purges moments, and recomputes pictures and clips (admins, operators; purge and recompute admins only). |
| `memory:read`, `memory:write` | What Guardian [remembers about you](https://vigiora.com/docs/ai/guardian-chat#what-guardian-remembers-about-you): `memory:read` lists and reads the facts kept for the key's own user, `memory:write` corrects and forgets them. `memory:write` includes `memory:read`. |
| `analytics:read`, `analytics:write` | [Analytics](https://vigiora.com/docs/ai/analytics): counting lines, zones, areas and a camera's analytics settings, and counts, occupancy, dwell and heatmaps. `analytics:write` creates, changes and deletes lines, zones and areas, changes a camera's analytics settings and sets an area's occupancy (admins, operators). Includes `analytics:read`. |
| `floorplans:read`, `floorplans:write` | [Floor plans](https://vigiora.com/docs/using/floor-plans): plans, their images, placed items and the live view, and where a camera is placed. `floorplans:write` creates, changes and deletes plans and replaces their items (admins, and operators who manage the site). Includes `floorplans:read`. |
| `devices:read`, `devices:write`, `devices:control` | Home Assistant devices shared with Vigiora through the [bridge](https://vigiora.com/docs/home-assistant/bridge): `devices:read` reads the connection, the shared devices, room signals, triggers, rule actions and the action log; `devices:write` changes which devices are shared and how (selection admins only), camera and room links, room signals, triggers and rule actions; `devices:control` sends commands to devices. Admins and operators only. `devices:write` and `devices:control` include `devices:read`. |
| `settings:read`, `settings:write` | Sites, rooms, layouts and layout sequences, system status, health and dashboard, the update, plan and remote access status (admins), the recording defaults, the configuration export (admins) and the Home Assistant install status (admins). `settings:write` creates, changes and deletes sites, layouts and layout sequences, changes the recording defaults, checks for an update, changes the Guardian clip pre-roll and how long deleted moments are kept, and installs, updates and connects Home Assistant (admins). |
| `users:read`, `users:write` | List users and groups; create, change and delete users and groups. Admins only. |
| `events:read` | The live event stream and the event log. Each event also needs the read scope of its family (for example `alerts:read` for alert events). |
| `webhooks:read`, `webhooks:write` | List webhooks and their deliveries; create, change, test, rotate and delete them. Admins' keys only. `webhooks:write` includes `webhooks:read`. |
| `network:read` | Scan the server's local network, list devices and look up the IP of a MAC address. Admins and operators only. It reads, but scans and lookups send traffic on the LAN, so no read-only access includes it. See [Network tools](https://vigiora.com/docs/developers/network-tools). |
| `admin` | Everything above, plus the configuration import, exporting camera passwords (encrypted with a passphrase), and naming and deleting faces. |

A few operations need a **user session** and refuse every key (`403 api_key_not_allowed`): API keys, connected apps, costs and billing, AI service instances, external AI tools and switching remote access. The [API reference](https://vigiora.com/docs/developers/api-reference) marks them *User session only*. They are not MCP tools either.

Rules for creating keys:

- `admin`, `users:read`, `users:write`, `settings:write`, `webhooks:read` and `webhooks:write` can only be given to an **admin's** key.
- `cameras:write`, `cameras:control`, `network:read`, `analytics:write`, `floorplans:write` and `devices:*` can't be given to a **viewer's** key, because their operations need the admin or operator role.
- A share link created with a key lives no longer than the key: it is revoked when the key is revoked and expires when the key expires.

## What decides if a call is allowed

A call is allowed only if all three allow it:

1. **The key's scopes** include the operation's scope (sessions have every scope),
2. **and the user's role** is one the operation accepts (admin, operator or viewer),
3. **and the user's permission on the camera** is high enough (viewer, operator or manager; admins have every permission).

The role and permissions are read from the user on every request, so a role change or a disabled user takes effect at once.

| Fails on | Answer |
| --- | --- |
| Scope | `403 insufficient_scope`, with `details.required_scope` and `details.granted_scopes` |
| Role | `403 forbidden` |
| Camera permission, and the camera is not visible to the user | `404 not_found` |
| Camera permission, the camera is visible | `403 forbidden` |
| An operation that needs a user session, called with a key | `403 api_key_not_allowed` |

Something you may not see always answers `404`, never `403`, so the API doesn't reveal what exists.

## Keys without scopes

Keys created before scopes existed, and keys from **Settings** → **People and access** → **API keys**, have no scopes ("legacy keys", `"scoped": false`). They keep working on `/api` exactly as before, and on v1 they get **implicit scopes** from their read-only flag:

| Key | Scopes on v1 |
| --- | --- |
| Read-only | `cameras:read`, `alerts:read`, `recordings:read`, `guardian:read`, `memory:read`, `settings:read` |
| Read-write | The above, plus `cameras:write`, `cameras:control`, `alerts:write`, `recordings:write`, `guardian:write`, and `settings:write` while the key's user is an admin |

A legacy key never gets `users:*`, `events:read`, `clips:share`, `network:read`, `analytics:*`, `floorplans:*`, `devices:*` or `admin`, so it can't do more on v1 than it could on `/api`.

> **Analytics needs a scoped key or sign-in**
>
> A legacy key, even a read-only one, has no `analytics:read`. Over MCP it therefore gets **no analytics tools** at all, and `GET /api/v1/analytics/...` answers `403 insufficient_scope`. For Analytics, floor plans or Home Assistant devices, create a scoped key with those scopes (tick **Limit to specific scopes** in **Settings** → **People and access** → **API keys**, or `POST /api/v1/api-keys`), or connect the app with sign-in (OAuth), whose **Read only** access includes `analytics:read`.

**Scoped keys work on `/api/v1` only.** On the internal `/api` they are refused with `403` and `"code": "api_key_scoped"`.

## Sign-in access (OAuth)

AI apps that sign in through the [MCP server](https://vigiora.com/docs/developers/mcp) get one of two fixed scope sets, chosen on the consent page:

| Access | Scopes |
| --- | --- |
| **Read only** | `cameras:read`, `alerts:read`, `recordings:read`, `events:read`, `analytics:read`, `floorplans:read`, `devices:read` |
| **Read and control** | The above, plus `cameras:write`, `cameras:control`, `alerts:write`, `recordings:write`, `network:read`, `analytics:write`, `floorplans:write`, `devices:control` |

A viewer's connection never gets the admin-and-operator scopes (`cameras:write`, `cameras:control`, `network:read`, `analytics:write`, `floorplans:write`, `devices:*`).

## Credentials stay hidden

Camera passwords never appear in v1 responses, for keys and sessions alike. A camera address comes back as `rtsp://REDACTED@192.0.2.20:554/stream1`. If you send such a value back unchanged in a `PATCH`, the stored password is kept.

## Revocation

A key stops working at once when it is revoked or expires, or when its user is disabled. A long response opened with a key, such as a video download, is closed within 30 seconds of the key being revoked. Repeated requests with wrong keys from one address are slowed down with `429 rate_limited`.

## Related pages

- [Conventions](https://vigiora.com/docs/developers/api-conventions)
- [API keys](https://vigiora.com/docs/developers/api-keys) — keys in the web app.
- [Users, roles and groups](https://vigiora.com/docs/admin/users-roles-groups)

---

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