---
name: vigiora-api
description: Call and integrate with a Vigiora Server's public REST API v1 (/api/v1) and its built-in MCP server (/api/v1/mcp) - cameras and their AI services, snapshots, frames, PTZ, alerts and rules, detection events (HAL reports), object recognition, recordings, clips and share links, the Guardian log, search, chat and Briefing, AI views, transcripts, sites, rooms (plan-drawn or virtual), speakers, layouts, users, settings, config export/import, network tools, setup wizard, camera discovery, catalogue and AI camera names, scoped API keys, human in the loop for AI agents, the events stream (SSE) and signed webhooks, Analytics, floor plans (uploaded or AI-drawn, device pins), Things, Home Assistant and IoT devices, Zigbee pairing, client error reports. Use when writing code, scripts or curl commands against a Vigiora Server, connecting an AI agent to it over MCP, finding people or objects in its cameras, handling its webhooks or events, or debugging Vigiora API errors. Not for the internal /api used by the web app.
license: Proprietary. Documentation of the Vigiora public API; free to use with Vigiora servers.
---

> If you are an AI assistant reading this from a URL: the reference files are linked below; fetch them as needed.

# Vigiora Server API v1

Vigiora Server is self-hosted video surveillance software with AI. Each server exposes a public, versioned REST API at `/api/v1`. Within v1, changes are additive only: never assume a field, enum value, event type or error code list is closed. Ignore what you don't know.

Reference files (read the one you need):

- [references/authentication.md](https://vigiora.com/skills/vigiora-api/references/authentication.md): API keys, sessions, every scope, what decides if a call is allowed.
- [references/endpoints.md](https://vigiora.com/skills/vigiora-api/references/endpoints.md): every operation with method, path, scope and roles (generated from the OpenAPI description).
- [references/errors-and-pagination.md](https://vigiora.com/skills/vigiora-api/references/errors-and-pagination.md): error codes, pagination, Idempotency-Key, rate limits, times and ids.
- [references/events-and-webhooks.md](https://vigiora.com/skills/vigiora-api/references/events-and-webhooks.md): the event stream, the event log, webhooks and signature checks.
- [references/mcp.md](https://vigiora.com/skills/vigiora-api/references/mcp.md): the built-in MCP server: connecting AI agents, OAuth sign-in, tools by scope, limits, human in the loop.
- [references/use-cases.md](https://vigiora.com/skills/vigiora-api/references/use-cases.md): 38 worked use cases by persona (home owner, shop owner, installer, developer, MCP assistant, accessibility, objects and frames, speakers and person alerts) with the calls in order, scopes and pitfalls.
- [references/object-recognition.md](https://vigiora.com/skills/vigiora-api/references/object-recognition.md): HAL services, object recognition (`hal-objects`), prompts, detection events and the HAL protocol.

The machine-readable description is the source of truth: `https://vigiora.com/openapi.json` (the current release), or the server's own copy at `<base>/api/v1/openapi.json` (matches that server's version exactly; needs a credential).

## Base URL

Use whichever address reaches the server:

- Anywhere: `https://<site>.vigiora.com/api/v1` (the site address, for example `https://yourname.vigiora.com`).
- Same local network: `http://<server-ip>:8080/api/v1` (for example `http://192.0.2.10:8080`).

Every path below starts with `/api/v1`.

## MCP: an alternative to curl

If you are an AI agent with MCP support, the server's built-in MCP server is usually easier than writing curl calls: every API v1 operation is a tool (`list_cameras`, `get_camera_snapshot`, `list_alerts`, `detect_objects`, `create_clip`, …; 423 tools on server 1.6.20 for a full-access admin key (386 on 1.6.19, 358 on 1.6.18, 347 on 1.6.17, 341 on 1.6.16, 306 on 1.6.13, 226 on 1.6.10 and 1.6.11)), filtered by the credential's scopes and the user's role. User-session-only operations (API keys, connected apps, costs, billing, AI service instances, external tools, remote access switch) are never tools.

- URL: `https://<site>.vigiora.com/api/v1/mcp` (or `http://<server-ip>:8080/api/v1/mcp` on the LAN), Streamable HTTP.
- claude.ai, Claude Desktop and ChatGPT: add it as a custom connector with only the URL; the user signs in and chooses **Read only** or **Read and control**. Such connections get the cameras, alerts, recordings, events, Analytics, floor-plan and Home Assistant device tools only (including `detect_objects` and `analyze_image` with `describe: false`), plus the network tools, Analytics and floor-plan writes and device commands with **Read and control** (admins and operators). A key without scopes (from the API keys page) has no `analytics:read`, so it gets no Analytics tools: use a scoped key or sign-in.
- Claude Code: `claude mcp add --transport http vigiora https://<site>.vigiora.com/api/v1/mcp --header "Authorization: Bearer $VIGIORA_API_KEY"` (leave out `--header` to sign in with `/mcp`). Codex and Cursor: the same URL with the key as a Bearer header from `VIGIORA_API_KEY`.
- Prompts: `daily_briefing`, `investigate_alert`, `camera_health_check`.
- `get_agent_policy`: whether to ask the user before risky tools (see Human in the loop below).

Details and setup per client: [references/mcp.md](https://vigiora.com/skills/vigiora-api/references/mcp.md). Use curl or code (below) for scripts, the event stream and video downloads.

## Human in the loop: check the policy first

Whether you ask the user before an action is the user's choice, set on their server (server 1.6.9 and later), not yours:

1. **At the start, check the policy:** the MCP tool `get_agent_policy`, or `GET /api/v1/agent-policy` (any credential, no scope). Over MCP the `initialize` instructions also say it. The answer: `human_in_the_loop` (true/false), `source` (`server`, `api_key`, `connected_app`), `confirm_operations` (operationIds; MCP tool names are the same in snake_case, for example `movePTZ` = `move_ptz`) and `note`.
2. **If `human_in_the_loop` is true:** ask the user before each operation in `confirm_operations` (PTZ moves and presets, scans, lookups and camera probes, relocate, creating, changing, enabling, disabling or deleting cameras, bulk updates, share links, clip deletes, unprotect, settings, auto-scan, diagnostic fixes, config import, users, webhooks, external alerts). Say in one sentence what will happen, then wait for a yes. The server also enforces it on MCP: it shows the user an Allow/Deny prompt when the client supports elicitation, or returns `confirmation_required`.
3. **If `human_in_the_loop` is false:** act directly, without asking. Report what you did.
4. Reads never need approval, and neither do `detect_objects`, `analyze_image` and `get_camera_frame` (they only look). From server 1.6.10 the confirm operations also cover alert rules, deleting alerts, a camera's AI services, PTZ presets, sites, groups, rooms, speakers, speaking in a room, faces, AI Live, vigiora-clients and the update check: always go by `confirm_operations`, not by a list you remember. A server older than 1.6.9 has no policy (`404 not_found` on `/agent-policy`): treat it as on, the 1.6.9 default.
5. **The policy is the only reason to ask.** When it is false, don't add confirmations of your own for server actions: act and report. Commands on the user's own computer (for example `sudo` in the vigiora-setup skill) follow the same policy; when you can't check it, ask.

**`confirmation_required`** (MCP tool error, HTTP status 428): show the user `error.details.action` (Vigiora's description of the action) and ask. Only after the user says yes, call the same tool again with the same arguments plus `confirm: true`. Never set `confirm: true` on your own or in advance. **`user_declined`** (403): the user chose Deny; don't retry unless they ask again. REST calls are never prompted and refuse a `confirm` field (`400 validation_error`); in a REST script, follow the policy yourself in the conversation. The policy can change between calls (it applies on the next call): re-check `get_agent_policy` if an answer surprises you. You cannot change the policy for the user; only the user (an admin, for the server setting) can, under **System → AI agents** and **API keys**.

Regardless of the policy, always: respect the camera login budget (never retry `auth_failed` or guess passwords), honour rate limits and `Retry-After`, relocate with `dry_run` first, keep keys and passwords out of the chat, and use least-privilege keys. Details: https://vigiora.com/docs/developers/human-in-the-loop.md

## Credentials

Send an API key in a header, never in the URL:

```bash
curl -s "$BASE/api/v1/me" -H "Authorization: Bearer vgk_xxxxxxxx_xxxxxxxxxxxxxxxx"
# or
curl -s "$BASE/api/v1/me" -H "X-API-Key: vgk_xxxxxxxx_xxxxxxxxxxxxxxxx"
```

`GET /api/v1/me` answers who the credential is and which scopes it has. Start there when debugging.

Getting a key:

- **Scoped key (recommended):** sign in with `POST /api/auth/login` (`{"username","password"}` → `access_token`), then `POST /api/v1/api-keys` with that token as `Authorization: Bearer <token>`. An API key can never create, list or revoke keys (`403 api_key_not_allowed`).
- **Key from the web app:** the **API keys** page creates keys without scopes (read-only or read-write) unless **Limit to specific scopes** is ticked (1.6.7 and later). Unscoped keys work on v1 with implicit scopes, but never get `events:read`, `clips:share`, `network:read`, `users:*` or `admin`.

```bash
TOKEN=$(curl -s -X POST "$BASE/api/auth/login" -H "Content-Type: application/json" \
  -d '{"username":"automation","password":"example-password"}' | jq -r .access_token)
curl -s -X POST "$BASE/api/v1/api-keys" -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"name":"Alarm panel","scopes":["alerts:write","cameras:read"],"expires_in_days":365}' | jq -r .key
```

The full key is in `key` and is shown only once. Store it in a secret store, never in code.

Scopes: `cameras:read`, `cameras:write`, `cameras:control` (PTZ), `alerts:read`, `alerts:write`, `recordings:read`, `recordings:write`, `clips:share`, `events:read`, `webhooks:read`, `webhooks:write`, `guardian:read` (Guardian log and search), `guardian:write` (chat and analyse, uses AI credits), `settings:read` (sites, rooms, layouts, system, settings, config export), `settings:write`, `users:read`, `users:write` (admins), `network:read` (LAN scan and MAC lookup; admins and operators; not part of any read-only access because it sends traffic on the LAN), `admin` (also config import and exporting secrets). `<x>:write` and `cameras:control` include the matching `:read`; `admin` includes everything. Give a key only what the integration needs. A call is allowed only if the key's scope, the user's role (admin, operator, viewer) and the user's permission on the camera all allow it. Details: [references/authentication.md](https://vigiora.com/skills/vigiora-api/references/authentication.md).

## Conventions

- JSON in and out, `snake_case` names. Unknown body fields are refused (`400 validation_error`).
- Optional values are present as `null`, never omitted. Ids are integers, except clip ids, network scan ids and PTZ preset tokens (strings). Treat ids as opaque.
- Times are RFC 3339. Responses are UTC (`2026-10-30T14:05:00Z`). A request time **without an offset** is refused.
- `GET` reads, `POST` creates (`201`, or `202` plus `Location` for jobs such as clip exports), `PATCH` changes only the fields sent, `DELETE` answers `204`. `PUT` is never used.
- Anything that is not plain CRUD is an action: `POST …/actions/<verb>`, for example `POST /api/v1/cameras/3/actions/enable-ai` or `POST /api/v1/alerts/actions/acknowledge`. Send no body or `{}` when it takes no parameters.
- Booleans in queries are `true` or `false` only.

## Errors

Every error, from every endpoint:

```json
{ "error": { "code": "insufficient_scope", "message": "…", "details": { "required_scope": "cameras:write", "granted_scopes": ["cameras:read"] } } }
```

Branch on `error.code` (stable), show `message` to people, and handle unknown codes by HTTP status. MCP only: `428 confirmation_required` and `403 user_declined` (see Human in the loop). Something the caller may not see is `404 not_found`, never `403`. Full table: [references/errors-and-pagination.md](https://vigiora.com/skills/vigiora-api/references/errors-and-pagination.md).

## Pagination

Lists answer `{"data": [...], "next_cursor": "…"}`. Send `?cursor=<next_cursor>` with **the same filters** for the next page; `next_cursor` is `null` on the last page. `?limit=` is 1-200 (default 50). There are no totals. Never build or parse cursors.

```bash
URL="$BASE/api/v1/alerts?from=2026-10-30T00:00:00Z&to=2026-10-31T00:00:00Z&limit=200"; CURSOR=""
while :; do
  PAGE=$(curl -s "$URL${CURSOR:+&cursor=$CURSOR}" -H "Authorization: Bearer $KEY")
  echo "$PAGE" | jq -c '.data[]'
  CURSOR=$(echo "$PAGE" | jq -r '.next_cursor // empty'); [ -z "$CURSOR" ] && break
done
```

## Retries, Idempotency-Key and rate limits

- Send `Idempotency-Key: <uuid>` on `POST /cameras`, `POST /clips` and every `…/actions/…` call so a retry never runs twice. The first answer is replayed for 24 hours with `Idempotent-Replayed: true`. Same key with a different request: `422 idempotency_key_reused`; still running: `409 idempotency_key_in_progress`. Creating an API key or a share link refuses the header (`400 idempotency_not_supported`).
- Each credential has a bucket of 120 requests refilled at 10 per second. Read `RateLimit-Remaining`. On `429`, wait `Retry-After` seconds, then retry. 5xx answers are not stored, so retry them with backoff.

## Events stream

Needs `events:read` plus the read scope of each event family (for example `alerts:read` for `alert.*`).

```bash
curl -N "$BASE/api/v1/events/stream?types=alert.created,camera.offline" -H "X-API-Key: $KEY" \
  ${LAST:+-H "Last-Event-ID: $LAST"}
```

Each event is `id:`, `event:` and `data:` (the event JSON `{"id","type","time","camera_id","data"}`). A stream ends cleanly after about a minute: that is normal, reconnect at once with the last handled id in `Last-Event-ID` and every missed event is replayed. Handle `: heartbeat`, `event: overflow` (reconnect with `Last-Event-ID`), `event: reset` (re-read current state) and `event: shutdown`. At most 3 streams per key. The log of the last 7 days is `GET /api/v1/events`. Details: [references/events-and-webhooks.md](https://vigiora.com/skills/vigiora-api/references/events-and-webhooks.md).

## Webhooks

Admins only, with `webhooks:write` (admin keys only). `POST /api/v1/webhooks` with `{"name","url","event_types":[],"camera_ids":[]}` (empty = all); the signing `secret` is shown once. Test with `POST /api/v1/webhooks/{webhook_id}/actions/test`.

Verify every delivery: `X-Vigiora-Signature: sha256=<hex>` is HMAC-SHA256 of `X-Vigiora-Timestamp + "." + raw body` with the secret. Use the **raw** body, compare in constant time, refuse timestamps older than 5 minutes, and accept any of several comma-separated signatures (after `rotate-secret` both old and new are sent for 24 hours).

```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');
  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));
  });
}
```

Answer 2xx within 10 seconds. Delivery is at least once: deduplicate on the event `id`. URLs must be `https`; private addresses need `allow_insecure: true`.

## More resources (API 1.4.0, server 1.6.6)

- Read-outs: `GET /sites`, `/rooms`, `/layouts`, `/system/status`, `/system/health` (`settings:read`), `GET /faces` (`alerts:read`), `GET /guardian/entries` and `/guardian/search?q=` (`guardian:read`), `GET /users` and `/groups` (`users:read`, admins).
- `POST /guardian/chat` `{"message": "…", "camera_id": 3}` and `POST /cameras/{camera_id}/actions/analyze` (`guardian:write`): use AI credits (`402 insufficient_credits`), 10 chats and 6 analyses a minute per credential, 2 at once (`429 rate_limited`). Analyze errors: `409 ai_not_enabled`, `503 capture_failed`, `503 ai_unavailable`.
- `POST /cameras/actions/bulk-update` (`cameras:write`): `enabled`, `recording_enabled` or `ai_enabled` for up to 100 cameras; always `200` with a result per camera.
- `POST /alerts` (`alerts:write`, operator on the camera): an alert from an external system with `camera_id`, `label` and `source`; filter with `GET /alerts?source=`. `POST /alerts/{alert_id}/actions/unacknowledge` undoes an acknowledge.
- `POST`, `PATCH`, `DELETE /users` (`users:write`, admins): audited; the last enabled admin can't be demoted, disabled or deleted (`409 conflict`). `GET`/`PATCH /settings`: recording defaults for new cameras.

## Network tools (API 1.5.0, server 1.6.7)

Self-hosted servers can probe their own LAN. Scope `network:read` (admins and operators); relocate needs `cameras:write` and operator permission on the camera.

- `POST /network/actions/scan` `{"subnet":"192.168.1.0/24","ports":[80,554],"onvif":true,"resolve_names":false}` (all optional) → `202` with a scan; poll `GET /network/scans/{scan_id}` until `status` is `done` or `failed`. Private (RFC 1918) subnets only, /22 to /30, ports from the allowlist 80, 443, 554, 8000, 8080, 8899, 9000 (1.6.8+), 34567, 37777. One scan at a time (`409 scan_in_progress`, `details.scan_id`); at most 1022 hosts, else `truncated: true` and `skipped_subnets`. ONVIF probes go by multicast plus unicast to hosts with an open port.
- `GET /network/devices?vendor=&has_port=&unassigned=true`: the latest devices (`ip`, `mac`, `vendor` from the IEEE registry, `hostname` only with `resolve_names`, `open_ports`, `onvif`, `known_camera_id`, `is_known_camera`). Sends no traffic.
- `GET /network/lookup?mac=08:cc:81:4a:1f:02` (any MAC spelling) or `?ip=`: neighbour table first, then a capped sweep (up to about 20 s). `404 not_found` when nothing has it.
- `POST /cameras/{camera_id}/actions/relocate` `{"dry_run":true}`: moves the camera to its MAC's current IP after an RTSP Digest login check. `409 conflict` with `details.reason` such as `old_address_alive` (the old IP still answers), `mac_mismatch` (no login is sent then), `verify_failed`, `device_not_found`, `ambiguous`, `ip_in_use`, `no_hardware_id`.
- Limits: 2 scans and 30 lookups a minute per credential (relocate counts as a lookup; `429 rate_limited`). While camera following uses the LAN, or after 4 lookup sweeps in 10 minutes per server: `503 network_busy` with `Retry-After`. Hosted servers and containers without host networking: `409 network_unavailable` with `details.reason` (`hosted`, `container_network`, …).
- MCP tools: `start_network_scan`, `get_network_scan`, `list_network_devices`, `lookup_network_address`, `relocate_camera` (destructive). Scans, lookups and relocate are confirm operations: ask first only when human in the loop is on. Always relocate with `dry_run` first.

Recipe, "a camera changed IP" (a Hikvision went from .37 to .38 after a router restart; its MAC still matched):

```bash
curl -s "$BASE/api/v1/network/lookup?mac=08:cc:81:4a:1f:02" "${H[@]}" | jq '{ip, known_camera_id}'   # -> 192.168.1.38, camera 81
curl -s -X POST "$BASE/api/v1/cameras/81/actions/relocate" "${H[@]}" -H "Content-Type: application/json" \
  -d '{"dry_run":true}' | jq '{old_ip, new_ip, changed}'                                             # check the change
curl -s -X POST "$BASE/api/v1/cameras/81/actions/relocate" "${H[@]}" -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" -d '{}' | jq .applied                                          # apply (user's OK first if HITL is on)
```

Vigiora also follows cameras by MAC automatically; the tools are for doing it now, on request. Details: https://vigiora.com/docs/developers/network-tools.md

## Setup, diagnostics, camera probe and auto-scan (API 1.7.0, server 1.6.8)

Everything the setup wizard does. All admin or operator; self-hosted servers for anything that touches the LAN. MCP tool names in brackets.

- **Health check** `GET /setup/diagnostics[?cached=true]` (`settings:read`) [`run_diagnostics`]: `status` (`ok`/`warn`/`fail`), `platform` (`linux`, `docker`, `macos`, `windows`) and `checks[]` with stable ids `disk, clock, ports, cloud, go2rtc, ffmpeg, gpu, lan, dns, updates` (more may come), each `status` `ok|warn|fail|skip`, `title`, `detail` (user-facing text) and, on warn/fail, `fix`: `{"kind":"auto","action_id":…}` or `{"kind":"manual","steps":[…]}`. Runs in about 6 s; `cached=true` reuses the last report. Thresholds: disk warn < 15 % free, fail < 5 %; clock warn > 5 s, fail > 5 min; `gpu` is information only.
- **Fix** `POST /setup/diagnostics/actions/fix` `{"action_id":"restart_go2rtc"|"check_updates"|"resync_cloud"}` (`settings:write`, admins) [`run_diagnostic_fix`]: runs it and answers the re-run `check`. `restart_go2rtc` stops live view and recording on every camera for a few seconds: tell the user (and ask first when human in the loop is on). `409 conflict` (`details.reason`: `action_unavailable`, `action_failed`), `429 rate_limited` (same fix within 20 s). Never run a `manual` step's shell commands without asking (they often need `sudo`).
- **Camera probe** `POST /cameras/actions/detect` `{"ip":"10.0.0.64","port":null,"username":"admin","password":"…","vendor":"Hikvision"}` (`cameras:write`) [`detect_camera`]: synchronous, up to about 20 s. ONVIF first, then known RTSP paths (Hikvision, EZVIZ, Dahua, Amcrest, Reolink, Tapo, Uniview, Axis, Foscam, generic); `vendor` is tried first. Always HTTP 200 for a probe outcome: `ok: true` with `detection_id` (30 min, yours only), `main_url`/`sub_url` **without credentials**, `codec`, `width`, `height`, `fps`, `snapshot_jpeg_base64`, `method` (`onvif` or `path`), `attempts_left`; or `ok: false` with `failure.code` `auth_failed`, `onvif_auth_failed`, `rtsp_closed`, `unreachable`, `no_stream`, `timeout` plus `message` and `hint` (show both as given). `ip` must be a private IPv4 on a subnet the server is connected to (`400`, `details.connected_subnets`); `port` one of 80, 443, 554, 2020, 8000, 8080, 8554, 8899, 9000, 34567, 37777. Hosted or no LAN: `409 network_unavailable`.
- **Lockout note (important):** cameras lock their account after a few wrong passwords, so the probe stops at the first refusal, never resends a refused login to that camera for 30 minutes (instant `auth_failed`, `auth_attempts: 0`), sends the login to only one RTSP path until one accepts it (so without the right `vendor` a camera that wants a password everywhere may answer `no_stream`: ask the user for the maker), and after **3 refused logins per camera in a sliding 30 minutes** sends nothing: `429 rate_limited`, `details.reason: camera_login_budget`, `Retry-After`. Read `attempts_left` (0-3) and warn the user when it is below 3. **Never retry `auth_failed` automatically or loop over guessed passwords**; ask the user to check the camera's own login first. The password is a tool argument: prefer a camera account made for Vigiora.
- **Batch** `POST /cameras/actions/detect-batch` `{"ips":[…],"username","password","vendor"}` (1-32 unique IPs, one login) → `202`, poll `GET /cameras/detect-batches/{batch_id}` every second until `status: done` [`detect_camera_batch`, `get_detection_batch`]. Items with `rate_limited: true` were not tried. One running batch per user (`409`, `batch_running`), 3 per server (`server_busy`).
- **Add** `POST /cameras/actions/add-detected` `{"cameras":[{"detection_id":"…","name":"Front door","recording_enabled":null,"site_id":null,"enabled":null,"tags":null}]}` [`add_detected_cameras`]: `201` (at least one created) or `200`, with `created` (cameras) and `failed` (per-detection v1 errors: `not_found` = expired, detect again; `limit_reached`; `validation_error`). The stream URL and its credentials stay on the server.
- **Checklist** `GET /setup/checklist` (`settings:read`) and `PATCH /setup/checklist` `{"items":{"phone_app":"skipped"}}` (`settings:write`, admins) [`get_setup_checklist`, `update_setup_checklist`]: items `health, cameras, recording, ai_cameras, notifications, phone_app, claude_connector` (optional) as `done|skipped|pending`, `source` `auto|user`; `complete` when every non-optional item is done or skipped. Data-derived `done` can't be undone by a mark.
- **AI suggestion** `GET /setup/ai-camera-suggestions` (`cameras:read`) [`suggest_ai_cameras`]: `slots`, `used`, `free`, `basis` (`activity`, `stream`, `order`), cameras with `suggested` and `reason`; then `POST /cameras/{camera_id}/actions/enable-ai`.
- **Auto-scan** `GET /network/auto-scan` (`settings:read`) [`get_auto_scan`]: `enabled`, `interval_minutes`, `interval_choices`, last and next run, `running`/`scan_id`/`progress`, `available` + `unavailable_reason` (hosted servers are always `enabled: false`). `PATCH /network/auto-scan` `{"enabled":true,"interval_minutes":60}` (15, 30, 60, 180, 720; `settings:write`, admins; hosted: `409 network_unavailable`) [`update_auto_scan`]. `POST /network/auto-scan/actions/run` (`network:read`) [`run_auto_scan`]: scan now, `202` with `scan_id`; same limits as network scans (`409 scan_in_progress`, `503 network_busy`, 2 a minute).
- **Candidates** `GET /network/candidates[?wizard_ready=true|false]` (`network:read`) [`list_camera_candidates`]: devices that look like cameras and aren't one: `confidence` `high` (ONVIF or RTSP 554 open) or `medium` (camera maker's MAC with a port open, or ONVIF port 8899), both `wizard_ready`; `low` = possible camera with `hint`/`hint_code` (`enable_rtsp_onvif`, `reolink_rtsp_off`). `POST /network/candidates/{candidate_id}/actions/dismiss` (MAC as id) [`dismiss_camera_candidate`] hides one. Event: `network.camera_found`.
- **Camera status** (1.6.8): `status` may be `standby` (not recording, nobody watching: healthy). `camera.offline` means a recording camera stopped writing segments, or a non-recording camera's stream port stopped answering; `camera.online` its recovery; online ↔ standby emits nothing.

Recipe, "set up the new camera Vigiora found": `list_camera_candidates` (`wizard_ready=true`) → ask the user for the camera's login → `detect_camera` with the candidate's `ip` and `vendor` → on `ok`, show resolution and fps and `add_detected_cameras` with a name the user picks; on `auth_failed`, stop and report `attempts_left`.

## Objects, frames and detection events (API 1.9-1.11, server 1.6.10)

- **Detection events** `GET /cameras/{camera_id}/detection-events?from=&to=&source=&label=` (`alerts:read`) [`list_camera_detection_events`]: one feed, oldest first, of the server's own detections (`source: "core-ai"`) and the reports of the HAL services on the camera (`source`/`service` = the service, for example `hal-objects`, `hal-face`; `confidence`, `bbox`, raw report in `attributes` when ≤ 2 KB). `source` is repeatable or comma-separated; `label` is exact. HAL reports are kept 30 days (`hal_events_retention_days` in `GET`/`PATCH /settings`, 1-365).
- **Guardian HAL context:** a Guardian entry's `detections` (`label`, `count`, `max_confidence`, `tracks`) is what the camera's detectors reported from 5 s before to 2 s after the clip, given to the AI to check its description against. Empty when the camera's `guardian_use_detections` is off.
- **Find objects** `POST /cameras/{camera_id}/actions/detect-objects` `{"prompts":["person","red shirt"],"at":null,"min_confidence":0.25,"annotate":true}` (`cameras:read`; a recorded `at` also needs `recordings:read`) [`detect_objects`]: `objects[]` with `label`, `confidence`, `bbox` (0-1, top-left `x`,`y`), `frame_time`, `model`, `annotated_image_url` (`GET /object-images/{image_id}` [`get_object_image`], 15 min, same credential only). At most 20 prompts of 40 characters; default the camera's list. Read-only, never stored as a detection, not a confirm operation. 20 a minute. Errors: `503 no_detector` (no runner online), `504 detector_timeout` (10 s), `502 detector_failed`, `422 clip_no_recordings`, `503 snapshot_unavailable`.
- **Analyse with objects** `POST /cameras/{camera_id}/actions/analyze` `{"include_objects":true,"prompts":[…]}` (`guardian:write`): recognition on 3 live frames first, given to the AI, returned in `objects`. Writes a Guardian entry and may fire alert rules.
- **Uploaded image** `POST /images/actions/analyze` (`cameras:read`; `describe` needs `guardian:write` and uses AI credits) [`analyze_image`]: `multipart/form-data` field `image` (options as form fields, `prompts` comma-separated) or JSON `image_base64` (a `data:` URL is accepted). JPEG, PNG or WebP, ≤ 10 MB, ≤ 40 MP (`413`, `415`). **Never stored**: re-encoded without metadata; only the annotated result is kept 15 minutes in memory. Over MCP a call is at most 1 MB, so about 750 KB of image: scale down first. 6 a minute with `describe`, 20 without.
- **Frames from recordings** `GET /cameras/{camera_id}/frame?at=…&width=&format=jpeg|png&quality=&stream=main|sub&download=` (`recordings:read`) [`get_camera_frame`, image]: the picture closest to `at`; `X-Vigiora-Frame-Time` is its time. `404 no_recording` has `details.nearest_before`/`nearest_after`. 30 a minute. Guardian: `GET /guardian/entries/{entry_id}/frame` [`get_guardian_entry_frame`] (the best moment of the clip) and `/clip` (MP4, not an MCP tool).
- **Prompts:** plain words; describe what you look for: `black t-shirt`, `red car`, `parcel` (bare `t-shirt` scores below the 0.25 default). Treat results as likely, not certain: show the annotated picture. Object recognition is a preview (`hal-objects`, a GPU HAL service available on request); without it, fall back to `search_guardian` and the Guardian entries, which describe clothing colours.

Recipe, "find a person in a red shirt at the entrance in the last hour":

```bash
FROM=$(date -u -v-1H +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%SZ)
curl -s "$BASE/api/v1/cameras/5/detection-events?from=$FROM&label=person" "${H[@]}" | jq -c '.data[] | {start_time, source, peak_confidence}'
curl -s -G "$BASE/api/v1/guardian/search" --data-urlencode "q=person in a red shirt" -d camera_id=5 "${H[@]}" | jq -c '.data[] | {occurred_at, description}'
curl -s -X POST "$BASE/api/v1/cameras/5/actions/detect-objects" "${H[@]}" -H "Content-Type: application/json" \
  -d '{"at":"2026-11-01T14:37:05+07:00","prompts":["person","red shirt"]}' | jq '{objects, annotated_image_url}'
```

## More API 1.9-1.11 operations (server 1.6.10)

156 operations were added; almost everything the web app does is in v1. Look them up in [references/endpoints.md](https://vigiora.com/skills/vigiora-api/references/endpoints.md):

- **Alert rules** (`alerts:read`/`alerts:write`, admins and operators): Guardian rules (`/alert-rules`, `/cameras/{camera_id}/alert-rules`, a sentence checked against clips `video_rule` or transcripts `audio_rule`), label alert rules (`/cameras/{camera_id}/label-alert-rules`; `GET /cameras/{camera_id}/labels` lists the labels seen), smart-motion lines and zones (`/cameras/{camera_id}/motion-rules`). A rule on a camera without AI returns `warnings: ["ai_not_enabled"]`. E-mail recipients are never set with a key. Events `alert_rule.created|updated|deleted`.
- **Cameras:** `PATCH /cameras/{camera_id}` takes every setting (sub stream, ONVIF, AI and speech settings, `guardian_use_detections`); `GET /cameras/{camera_id}/ai-services`, `.../ai-services/{ai_service_id}/actions/enable|disable`, `PATCH .../ai-services/{ai_service_id}` (only its `config_fields`, for example the `prompts` of `hal-objects`); reference frame, compare, read plates, audio level and status, pipeline, current objects.
- **Guardian and Briefing:** `GET /briefing`, `/briefing/feed`, `/briefing/recap`, review marks; conversations; `GET /guardian/transcripts`; AI Live sessions per camera and per room; entries are plain text in `lang`/`Accept-Language` with `descriptions` per language.
- **Organisation:** sites, groups (admins), layouts and sequences, faces (name or delete: `admin` scope), rooms, speakers, speak and play audio in a room.
- **System and fleet:** dashboard, AI status, objects, mesh, edge, plan, update (`POST /system/update/actions/check`), remote access; vigiora-clients (list, restart, update, resync, install ffmpeg, add a camera, remove; admins for writes).
- Also: delete an alert (`?delete_recording=true`, audited), an alert's recording, recording days, people counts and motion levels, all share links, clip preflight.

## Speakers, person confirmation and presence (API 1.12-1.14, server 1.6.11)

No new operations; new fields only:

- **Camera speakers without a client** (1.12): `POST /outputs` `{"name":"Gate speaker","kind":"camera_backchannel","camera_id":7}` (`cameras:write`, admins and operators) [`create_output`]: `client_id` may be absent, `null` or `""`, and then this server plays the camera's two-way audio itself (a camera the server streams directly; a camera behind a vigiora-client is still played by that client). `PATCH /outputs/{output_id}` `{"client_id":null}` [`update_output`] moves an existing camera speaker to this server; `usb` and `cast` speakers can't change client (`400 validation_error`). Test with `POST /outputs/{output_id}/actions/test` `{"text":"…"}` (`cameras:control`) [`test_output`]: a `502` whose message says *this camera has no speaker / two-way audio*, *camera speaker is busy* or *camera speakers are not available on this server* (Docker installs can't play yet) explains why it didn't play. One message per camera at a time, at most 60 s; the call returns after the audio has played.
- **Person rules wait for the detector** (1.13): alert rules have `require_detector_confirmation` (default `true`) on `POST /cameras/{camera_id}/alert-rules` [`create_alert_rule`] and `PATCH /alert-rules/{alert_rule_id}` [`update_alert_rule`]. For a rule about people on a camera with a person-capable detector (`hal-objects` with a person prompt, `hal-smart-motion`, `hal-weapon`) that ran for the whole clip and saw nobody, no alert is sent; the Guardian entry is kept. Without such a detector, or when it wasn't running, rules alert as before.
- **Guardian entries** (1.13-1.14) [`list_guardian_entries`, `get_guardian_entry`, `search_guardian`]: `detector_checked` (a person detector covered the clip, so no `person` in `detections` means nobody was seen), `unconfirmed_alerts` (`[{alert_rule_id, name}]`, the person rules that matched but were held back) and `person_present_seconds` (seconds a person was in view per the detector's presence report, ±2 s around the clip; `0` = watched and nobody; `null` = no presence data).
- To answer "why didn't I get an alert?": find the entry, then read `unconfirmed_alerts` and `person_present_seconds`, and show `GET /guardian/entries/{entry_id}/frame` so the user can judge. Don't turn the setting off on your own: changing a rule is a confirm operation, and the user decides.

## Analytics, floor plans, Home Assistant and moments (API 1.15-1.25, server 1.6.13)

89 operations were added (347 in all). Details in [references/endpoints.md](https://vigiora.com/skills/vigiora-api/references/endpoints.md):

- **Analytics** (`analytics:read`/`analytics:write`; needs the Analytics add-on and an object detector on the camera): `GET /analytics/counts?area_id=|line_id=|camera_id=&period=today|from=&to=&step=1h&class=person` [`get_analytics_counts`] (in and out through entrance lines, 15-minute buckets, `from` rounded down to the quarter hour; local times without an offset are in the server's time zone), `GET /analytics/occupancy` [`get_analytics_occupancy`], `GET /analytics/dwell` (exactly one of `zone_id`, `area_id`, `camera_id`) [`get_analytics_dwell`], `GET /analytics/heatmap?camera_id=&layer=pass|stop` [`get_analytics_heatmap`]; setup with `/analytics/lines`, `/analytics/zones`, `/analytics/areas` and `GET`/`PATCH /cameras/{camera_id}/analytics`. **Always report `covered_pct` when it is below 100** (the detector wasn't watching the whole period). A key without scopes never has `analytics:read`.
- **Floor plans** (`floorplans:read`/`floorplans:write`): `GET /floor-plans`, `/floor-plans/{floor_plan_id}/items`, `/floor-plans/{floor_plan_id}/live` [`get_floor_plan_live`] ("what is happening on floor 1") and `GET /cameras/{camera_id}/locations` [`get_camera_locations`] ("where is camera X": a plain-language `description`). Writes carry the plan's `version` (`409 conflict` when stale).
- **Moments** (`guardian:write`, admins and operators): `DELETE /guardian/entries/{entry_id}` [`delete_guardian_entry`] and `POST /guardian/entries/actions/delete` `{"ids":[…]}` [`delete_guardian_entries`] move moments (clip, frame, the alerts Guardian raised) to Recently deleted; recordings are never deleted. `GET /guardian/trash` [`list_guardian_trash`], `POST /guardian/trash/actions/restore` [`restore_guardian_entries`] (not a confirm operation), `POST /guardian/trash/actions/purge` (admins). Kept 7 days by default (`/guardian/trash/settings`). `409 entry_protected` (a protected recording covers it) and `409 entry_shared` (an export or share link covers it; an admin may send `force=true`, which revokes the links: ask first).
- **Pictures and clips:** entries have `frame_time`, `frame_reason`, `frame_box`, `clip_start`, `clip_end`, `clip_reason`. Clips start `preroll_seconds` (default 3) before the motion: `GET`/`PATCH /guardian/clips/settings`, per camera `guardian_clip_preroll_sec`. Backfills (admins, confirm operations, never automatic): `POST /guardian/entries/actions/recompute-clips` then `.../recompute-frames`, **always with `dry_run: true` first**.
- **Live media:** `POST /cameras/{camera_id}/actions/stream-url` `{"ttl_seconds":600,"quality":"sub"}` [`create_camera_stream_url`] returns a signed HLS `hls_url` (relative; no key needed; RTSP and WebRTC are `null`); `.../snapshot-url` [`create_camera_snapshot_url`] a signed image link. `503 stream_unavailable`. Don't paste these links into public places: anyone with the link can watch until it expires.
- **Camera speak:** `POST /cameras/{camera_id}/actions/speak` `{"text":"…","volume":0.8}` (`cameras:control`) [`speak_on_camera`]; `422 speaker_not_supported`. A confirm operation.
- **Identity and summary:** `GET /server` [`get_server`] (any credential: id, name, version, `features`), `GET /alerts/summary` [`get_alert_summary`] (unacknowledged counts by severity and camera).
- **Rooms:** `ai_mode` `live`/`guardian`/`both`; room alert rules `/rooms/{room_id}/alert-rules` [`create_room_alert_rule`]; `GET /rooms/{room_id}/guardian-entries` [`list_room_guardian_entries`].
- **Things:** `GET /thing-capabilities`, `GET /things` [`list_things`] and the `format=things` event stream (CloudEvents). `POST /things/{thing_id}/commands/{command_id}` is REST only (not a tool).
- **Home Assistant** (`/integrations/home-assistant`): install, update, `update-integration`, restart, uninstall (admins, `settings:write`); the bridge (`devices:read`, `devices:write`, `devices:control`, admins and operators): `GET .../devices` [`list_home_assistant_devices`], `POST .../devices/{entity_id}/actions/command` `{"command":"onoff.turn_on"}` [`command_home_assistant_device`], triggers, rule actions, room signals, `GET .../action-log`. Only devices an admin shared are visible. **Locks, alarm panels and sirens always need the user's approval**, even with human in the loop off; `502 device_failed` when Home Assistant refuses.
- **Events:** `motion.started`, `motion.ended`, `presence.changed` (`cameras:read`), `device.state_changed` (`devices:read`), and `data.snapshot_url` (signed, 15 min) on the stream and the log.

## Analytics alerts, door displays, integrations and Add camera (API 1.26-1.30, servers 1.6.15-1.6.16)

36 operations were added (383 in all), no new scopes. Check `features` in `GET /server` first (`analytics_queues`, `analytics_bays`, `analytics_alerts`, `analytics_display`, `mqtt`, `chat_notifications`, `picture_links`).

- **Analytics reads** (`analytics:read`): `GET /analytics/queues` [`get_analytics_queues`] (waiting now, avg/max wait per queue zone), `GET /analytics/bays` [`get_analytics_bays`] (each bay free/taken with the current stay), `GET /analytics/speed` [`get_analytics_speed`] (estimates rounded to 5 km/h; `calibrated: false` = no speeds; never present them as evidence), `GET /analytics/busy-hours`, `GET /analytics/flows`. Zones have `kind` `zone`/`queue`/`bay`; schedules are `{mon:[["HH:MM","HH:MM"]],…}` local time, end exclusive, `null` = always.
- **Analytics alert rules** (`analytics:write`, confirm operations): `POST /analytics/alert-rules` [`create_analytics_alert_rule`] with `kind` (capacity, queue_length, queue_wait, loitering, wrong_direction, tailgating, speed, no_bays_free, zone_empty, line_below, bay_reserved, bay_overstay), exactly one target (`zone_id`/`line_id`/`area_id`/`camera_id`), `params`, `schedule`, `channels`, `severity`, `cooldown_sec` (default 300). History: `GET /analytics/alert-events` [`list_analytics_alert_events`]. Alerts have `source: "analytics"` and label `analytics:<kind>`.
- **Door displays** (`analytics:write`): `POST /analytics/displays` [`create_analytics_display`] returns the display address and token **once**: hand it to the user, don't log or repeat it. `DELETE /analytics/displays/{analytics_display_id}` revokes.
- **Add camera** (`cameras:write`): `detect`/`add-detected` return and take device facts (`model`, `serial`, `has_audio`, `suggested_name`); `ai_guardian_enabled` stays off unless the user asks (Core AI uses credits). An `ip_conflict` in a scan can be fixed with `POST /network/devices/actions/move-to-dhcp` [`move_device_to_dhcp`] (admins, confirm operation, 202 + `GET /network/dhcp-moves/{job_id}`); it never activates an inactive camera (`activated: false`).
- **Integrations** (admins; `settings:write`): `/integrations/mqtt`, `/integrations/telegram`, `/integrations/line` (GET, PATCH, `actions/test`). Tokens and passwords are write-only: ask the user to paste them into the app, never into the chat. `allow_control` on MQTT lets broker clients switch recording and AI: confirm with the user.
- **Home Assistant instances:** `/integrations/home-assistant/instances` [`list_home_assistant_instances`…]; older operations act on instance 1; device keys of other instances look like `2:light.porch`.

## Config export and import: be careful

- `GET /api/v1/config/export` (admins) returns settings, sites, cameras, alert rules, rooms, layouts and outputs. Credentials are `REDACTED`. With `include_secrets=true` and an `X-Export-Passphrase` header of at least 12 characters (needs the `admin` scope and an admin user) they are encrypted with that passphrase. Treat the file as sensitive anyway, never print secrets, and ask the user to type the passphrase into an environment variable, never into the chat. Every export is audited.
- `POST /api/v1/config/import` (`admin` scope): **always run `dry_run=true` first** and check the diff (show it to the user and ask before the real import when human in the loop is on). It is all or nothing (`400 validation_error` with `details.errors`), never deletes, keeps absent fields, and refuses retention reductions unless `allow_retention_reduction=true`, which deletes older recordings: set it only when the user asked for that reduction.

```bash
curl -s "$BASE/api/v1/config/export" "${H[@]}" -o vigiora-config.json
curl -s -X POST "$BASE/api/v1/config/import?dry_run=true" "${H[@]}" -H "Content-Type: application/json" \
  --data-binary @vigiora-config.json | jq '.summary'
```

## Recipes

```bash
BASE="https://yourname.vigiora.com"; KEY="vgk_xxxxxxxx_xxxxxxxxxxxxxxxx"
H=(-H "Authorization: Bearer $KEY")

# Cameras the key's user can view
curl -s "$BASE/api/v1/cameras" "${H[@]}" | jq '.data[] | {id, name, status, ai_enabled}'

# Live JPEG (may be up to an hour old; its age in seconds is in the Age header)
curl -s "$BASE/api/v1/cameras/3/snapshot" "${H[@]}" -o front-door.jpg

# Acknowledge alerts in bulk (at most 500 ids), safe to retry
curl -s -X POST "$BASE/api/v1/alerts/actions/acknowledge" "${H[@]}" \
  -H "Idempotency-Key: $(uuidgen)" -H "Content-Type: application/json" -d '{"ids":[1201,1202]}'

# Export a clip (max 30 minutes) -> 202, poll until status is ready or failed, then a one-time download URL (60 s)
CLIP=$(curl -s -X POST "$BASE/api/v1/clips" "${H[@]}" -H "Idempotency-Key: $(uuidgen)" -H "Content-Type: application/json" \
  -d '{"camera_id":3,"from":"2026-10-30T14:00:00Z","to":"2026-10-30T14:05:00Z"}' | jq -r .id)
until [ "$(curl -s "$BASE/api/v1/clips/$CLIP" "${H[@]}" | jq -r .status)" != "running" ]; do sleep 2; done
URL=$(curl -s -X POST "$BASE/api/v1/clips/$CLIP/actions/create-download-url" "${H[@]}" | jq -r .url)
curl -s "$BASE$URL" -o clip.mp4

# Public share link (needs clips:share; expires_in 1h, 24h or 7d; the URL is returned only here)
curl -s -X POST "$BASE/api/v1/clips/$CLIP/shares" "${H[@]}" -H "Content-Type: application/json" -d '{"expires_in":"24h"}'

# Protect the recordings around an alert so retention never deletes them (recordings:write)
curl -s "$BASE/api/v1/recordings?camera_id=3&from=2026-10-30T14:00:00Z&to=2026-10-30T14:05:00Z" "${H[@]}" | jq '.data[].id'
curl -s -X POST "$BASE/api/v1/recordings/812/actions/protect" "${H[@]}" -H "Idempotency-Key: $(uuidgen)"
```

Protected recordings may use at most 20% of the recordings disk (`409 protect_limit`); on a critically low disk protect answers `507 disk_low`.

## Use cases

The patterns to know (prompt → calls). All 40, with scopes, results and pitfalls: [references/use-cases.md](https://vigiora.com/skills/vigiora-api/references/use-cases.md).

- "Who rang the doorbell this afternoon?" → `GET /api/v1/alerts?camera_id=…&label=person&from=…&to=…` (`alerts:read`), `GET /api/v1/alerts/{alert_id}/snapshot` for each, and with a key `GET /api/v1/guardian/entries?camera_id=…` (`guardian:read`). Vigiora sees people, not button presses.
- "Did the delivery arrive?" → `GET /api/v1/guardian/search?q=parcel delivered&camera_id=…` (`guardian:read`), then `GET /api/v1/cameras/{camera_id}/snapshot` to see if it is still there.
- "Turn the Entrance camera left, take a photo of each side and show me" → `GET /api/v1/cameras` (`has_ptz`), snapshot, `POST /api/v1/cameras/{camera_id}/ptz/actions/move` `{"pan":-0.5,"duration_ms":1500}` (`cameras:control`; ask first if human in the loop is on), wait, snapshot; the same to the right. **Compare the pictures**: a `200` means the command was taken, not that the view changed. If "left" matches "before", the camera is already at its pan limit: report that. Check the snapshot's `Age`; `409 ptz_busy` = retry shortly.
- "Is everything OK at home?" → the MCP prompt `daily_briefing`, or `GET /api/v1/cameras` (`standby` is healthy), `GET /api/v1/alerts?is_alert=true&from=…`, `GET /api/v1/events?types=camera.offline,camera.online&from=…`.
- "What were the busiest hours today?" → page `GET /api/v1/alerts?label=person&from=…&limit=200` and count per hour (detections, not unique visitors), or `POST /api/v1/guardian/chat` (`guardian:write`, uses AI credits).
- "What did customers ask about?" → `GET /api/v1/guardian/entries?camera_id=…&from=…` and read `audio_transcript` (cameras with audio and Voice detection); summarise topics, never personal details.
- "Send me the clip of 14:05 for the police" → `POST /api/v1/clips` (`recordings:write`, max 30 min), poll `GET /api/v1/clips/{clip_id}` until `ready`, then `POST /api/v1/clips/{clip_id}/shares` `{"expires_in":"7d"}` (`clips:share`; the URL is returned once), and protect the recordings.
- "A camera went offline after a router restart" → `GET /api/v1/network/lookup?mac=…` (`network:read`), `POST /api/v1/cameras/{camera_id}/actions/relocate` `{"dry_run":true}`, then apply (after the user's OK if human in the loop is on). `503 network_busy` = wait `Retry-After`.
- "Add 10 Hikvision cameras with the same login" → `POST /api/v1/cameras/actions/detect` on one first, then `POST /api/v1/cameras/actions/detect-batch`, poll `GET /api/v1/cameras/detect-batches/{batch_id}`, `POST /api/v1/cameras/actions/add-detected`. Never retry `auth_failed`.
- "Find a person in a red shirt at the entrance in the last hour" → `GET /api/v1/cameras/{camera_id}/detection-events?from=…&label=person` and `GET /api/v1/guardian/search?q=red shirt&camera_id=…`, then `POST /api/v1/cameras/{camera_id}/actions/detect-objects` with `at` and `prompts: ["person","red shirt"]` on those moments (`recordings:read` too), and show `annotated_image_url`.
- "What objects are on camera X now?" → `POST /api/v1/cameras/{camera_id}/actions/detect-objects` without `at`; `503 no_detector` = object recognition isn't set up (a preview on request).
- "Describe this uploaded photo" → `POST /api/v1/images/actions/analyze` (`image_base64` over MCP, at most about 750 KB; multipart `image` in scripts). Not stored. `describe` needs `guardian:write`.
- "Show me the driveway at 07:30" → `GET /api/v1/cameras/{camera_id}/frame?at=…` (`recordings:read`); `404 no_recording` gives the nearest recorded times.
- "Why didn't I get an alert at 04:10?" → `GET /api/v1/guardian/entries?camera_id=…&from=…&to=…` (`guardian:read`): an entry with `unconfirmed_alerts` was held back because the person detector saw nobody (`person_present_seconds: 0`); show `GET /api/v1/guardian/entries/{entry_id}/frame`. The rule's `require_detector_confirmation` turns it off (ask first if human in the loop is on).
- "Make the gate camera say 'Please close the gate'" → `GET /api/v1/outputs` (`cameras:read`) for a `camera_backchannel` speaker, or create one without `client_id` (server 1.6.11), then `POST /api/v1/outputs/{output_id}/actions/test` `{"text":"Please close the gate"}` (`cameras:control`; a confirm operation).
- "How many customers came in this morning?" → `GET /api/v1/analytics/areas` (`analytics:read`), then `GET /api/v1/analytics/counts?area_id=…&from=<today>T09:00&to=<today>T12:00` [`get_analytics_counts`]; say so when `covered_pct` is below 100. Without Analytics, count person alerts instead and call it an estimate.
- "Delete that false alarm from last night" → `GET /api/v1/guardian/entries?camera_id=…&from=…` (`guardian:read`), then `DELETE /api/v1/guardian/entries/{entry_id}` (`guardian:write`, a confirm operation); it can be restored for 7 days with `POST /api/v1/guardian/trash/actions/restore`.
- "Post to Slack (or Telegram, Home Assistant) when a person is seen at night" → a receiver that verifies `X-Vigiora-Signature`, `POST /api/v1/webhooks` `event_types: ["alert.created"]` (admin, `webhooks:write`), `POST /api/v1/webhooks/{webhook_id}/actions/test`. Or stream `GET /api/v1/events/stream` with `Last-Event-ID`.

Before any of these, check `get_agent_policy` (or `GET /api/v1/agent-policy`): if `human_in_the_loop` is true, ask the user before the operations in `confirm_operations` (the server also prompts or returns `confirmation_required`); if false, act directly without asking. Reads, including object recognition and frames, never need a confirmation.

Ask the user for the key through an environment variable (for example `VIGIORA_API_KEY`); never ask them to paste it into the chat. Use the smallest set of scopes, and try writes on a test server first.

## Pitfalls

- Use `/api/v1`, not `/api`: `/api` is the web app's internal API and changes in any release. Scoped keys are refused there (`403 api_key_scoped`).
- Never put a key in a query string, and never log it. Camera passwords come back as `rtsp://REDACTED@…`; sending that value back in a `PATCH` keeps the stored password.
- Every time parameter needs an offset (`Z` or `+07:00`).
- Re-send the same filters with a cursor, or you get `400 invalid_cursor`.
- Clip exports are asynchronous: wait for `status` `ready` (`409 clip_not_ready` before). One export per user at a time (`429 clip_user_busy`).
- PTZ calls on a camera without PTZ answer `409 ptz_not_supported`; `409 ptz_busy` means retry shortly.
- Event streams end every minute by design. Always reconnect with `Last-Event-ID`; reconcile from `GET /api/v1/events` after an outage.
- Webhook signatures must be computed over the raw body bytes, not re-serialised JSON.
- On the free plan, playing recordings through Vigiora's relay counts against the monthly remote video allowance (`429 relay_limit`).

## More

- Docs: https://vigiora.com/docs/developers/api-v1 ([markdown](https://vigiora.com/docs/developers/api-v1.md)), quickstart https://vigiora.com/docs/developers/api-quickstart.md, conventions https://vigiora.com/docs/developers/api-conventions.md, authentication https://vigiora.com/docs/developers/api-authentication.md, reference https://vigiora.com/docs/developers/api-reference.md, webhooks and events https://vigiora.com/docs/developers/webhooks-and-events.md.
- MCP server: https://vigiora.com/docs/developers/mcp.md. HAL services and object recognition: https://vigiora.com/docs/ai/hal-services.md. Network tools: https://vigiora.com/docs/developers/network-tools.md. Setup wizard: https://vigiora.com/docs/getting-started/setup-wizard.md. Automatic discovery: https://vigiora.com/docs/cameras/automatic-discovery.md.
- OpenAPI 3.1: https://vigiora.com/openapi.json and https://vigiora.com/openapi.yaml.
- All docs for LLMs: https://vigiora.com/llms.txt and https://vigiora.com/llms-full.txt.
