# Vigiora API v1 use cases

Real requests people make, grouped by who asks, with the calls that answer them. Each use case gives:

- **Prompt:** what the user says.
- **Calls:** the API v1 operations in order (method and path, with the scope), and the MCP tool names in brackets.
- **Result:** what the user gets.
- **Watch out:** the safety notes and the errors to expect.

Every path starts with `/api/v1` on the server's base address (`https://<site>.vigiora.com` or `http://<server-ip>:8080`). Ids such as `{camera_id}` come from earlier calls; never guess them.

## Before any use case

- Read the credential from an environment variable (for example `VIGIORA_API_KEY`). **Never ask the user to paste a key, password or passphrase into the chat.**
- Call `GET /api/v1/me` first: it says who the credential is and which scopes it has. A missing scope is `403 insufficient_scope` with `details.required_scope`; ask for a key with that scope instead of working around it.
- Use the least privilege that works: a read-only key for questions, a write scope only for the use case that needs it, and an expiry.
- **Check the human-in-the-loop policy at the start:** the MCP tool `get_agent_policy` [`get_agent_policy`], or `GET /api/v1/agent-policy` (any credential). If `human_in_the_loop` is true, ask the user before the operations in `confirm_operations` (moving a PTZ camera, scanning or probing the network, relocating, adding, changing or deleting cameras, bulk changes, share links, config import, diagnostic fixes, users, webhooks, settings…): say what will happen in one sentence and wait for a yes. The server also enforces it over MCP, with an Allow/Deny prompt or the tool error `confirmation_required`. If it is false, act directly without asking, and report what you did. In the use cases below, "the HITL check" means exactly this.
- **On `428 confirmation_required`** (MCP): show the user `details.action`, and only after they say yes call the same tool again with the same arguments and `confirm: true`. Never send `confirm: true` on your own. On `403 user_declined` the user chose Deny: stop.
- Times need an offset. "This afternoon" is in the user's time zone: ask for it if you don't know it, and send `from` and `to` with that offset (`2026-10-31T12:00:00+07:00`). Answers are in UTC; convert them back when you speak to the user.
- Each credential has 120 requests refilled at 10 a second. On `429`, wait `Retry-After` seconds. Page lists with `next_cursor` and the same filters.
- Connections made by signing in (the claude.ai, Claude Desktop or ChatGPT connector) get only the cameras, alerts, recordings and events tools, plus the network tools with **Read and control**. Guardian, share links, settings, users, webhooks and the configuration need an API key (Claude Code, Codex, Cursor or a script).

## Home owner

### 1. Who rang the doorbell this afternoon?

- **Prompt:** "Who rang the doorbell this afternoon?"
- **Calls:**
  1. `GET /api/v1/cameras` (`cameras:read`) [`list_cameras`]: find the door camera by name ("Front door", "Doorbell", "Entrance").
  2. `GET /api/v1/alerts?camera_id={camera_id}&label=person&from=…&to=…` (`alerts:read`) [`list_alerts`]: the people seen in that window. `label=face` instead lists recognised faces (labels `face:<name>`).
  3. `GET /api/v1/alerts/{alert_id}/snapshot` (`alerts:read`) [`get_alert_snapshot`] for each one.
  4. With an API key, `GET /api/v1/guardian/entries?camera_id={camera_id}&from=…&to=…` (`guardian:read`) [`list_guardian_entries`]: Guardian's descriptions, and `audio_transcript` when the camera has audio.
- **Result:** a short list: "14:12, a man with a parcel (snapshot); 16:40, Anna (recognised face)".
- **Watch out:** Vigiora sees people at the door, not button presses: say "people at the door", not "rang". Recognised names exist only when face recognition is set up. No alerts can also mean AI is off on that camera (`ai_enabled` false).

### 2. Did the delivery arrive?

- **Prompt:** "Did my delivery arrive today?"
- **Calls:**
  1. `GET /api/v1/guardian/search?q=delivery courier parcel left at the door&camera_id={camera_id}` (`guardian:read`) [`search_guardian`]: ranked hits by meaning (`match: semantic`) or, as a fallback, by keyword (`match: keyword`).
  2. `GET /api/v1/guardian/entries/{entry_id}` (`guardian:read`) [`get_guardian_entry`] for the best hits.
  3. `GET /api/v1/cameras/{camera_id}/snapshot` (`cameras:read`) [`get_camera_snapshot`]: is a parcel there now?
- **Result:** "A courier left a box at 11:05; it is still by the door in the current picture."
- **Watch out:** "Nothing found" is not "nobody came": say what you searched and the time range. Over a sign-in connector (no Guardian tools), use `list_alerts` with `label=person` and the snapshots instead.

### 3. Turn the Entrance camera left, take a photo of each side and show me

- **Prompt:** "Turn the Entrance camera left, take a photo of each side and show me."
- **Calls:**
  1. `GET /api/v1/cameras` (`cameras:read`) [`list_cameras`]: find "Entrance" and check `has_ptz` is true.
  2. The HITL check for `move_ptz`. Either way, tell the user the camera will move and recordings follow the new view until it moves back.
  3. `GET /api/v1/cameras/{camera_id}/snapshot` [`get_camera_snapshot`]: the "before" picture.
  4. `POST /api/v1/cameras/{camera_id}/ptz/actions/move` with `{"pan": -0.5, "duration_ms": 1500}` and an `Idempotency-Key` (`cameras:control`) [`move_ptz`]. Wait about 2 seconds, then take a snapshot.
  5. `POST /api/v1/cameras/{camera_id}/ptz/actions/move` with `{"pan": 0.5, "duration_ms": 3000}`, wait, snapshot again.
  6. To go back: `GET /api/v1/cameras/{camera_id}/ptz/presets` [`list_ptz_presets`] and `POST /api/v1/cameras/{camera_id}/ptz/presets/{preset_token}/actions/goto` [`goto_ptz_preset`], or a move the other way.
- **Result:** the before, left and right pictures, each with one line on what it shows.
- **Watch out:**
  - **Compare the pictures before you report.** A `200` means the camera took the command, not that the view changed. A camera may already be at its pan limit: then the "left" picture matches the "before" one. Say so ("the camera seems to be at its left limit already; the picture did not change") instead of claiming it turned.
  - A snapshot may be up to an hour old when the camera can't give a fresh frame (the `Age` header, `age_seconds` over MCP). An old frame from before the move also looks unchanged: check the age.
  - A move sent while another one runs is dropped (`status: coalesced`). `409 ptz_busy`: wait a moment and retry. `409 ptz_not_supported`: no PTZ on this camera (see use case 15). `502 ptz_failed`: the camera refused or didn't answer.
  - Over a sign-in connector this needs **Read and control**; viewers never get PTZ.

### 4. Is everything OK at home?

- **Prompt:** "Is everything OK at home?"
- **Calls:** the MCP prompt `daily_briefing` (`hours`, default 24) does it in one go. With REST:
  1. `GET /api/v1/cameras` (`cameras:read`) [`list_cameras`]: `status` per camera.
  2. `GET /api/v1/alerts?is_alert=true&from=…` (`alerts:read`) [`list_alerts`] and the snapshots of the main ones.
  3. `GET /api/v1/events?types=camera.offline,camera.online&from=…` (`events:read` and `cameras:read`) [`list_events`]: cameras that dropped out and came back.
  4. With `settings:read`: `GET /api/v1/system/health` [`get_system_health`].
- **Result:** three or four sentences: cameras working, the alerts that matter with pictures, anything to check.
- **Watch out:** `standby` is healthy (not recording, nobody watching), not offline. Lead with what needs attention; don't list every detection.

### 5. Stop showing me the car alerts on the driveway

- **Prompt:** "Acknowledge all of yesterday's car alerts on the driveway camera."
- **Calls:**
  1. `GET /api/v1/alerts?camera_id={camera_id}&label=car&acknowledged=false&from=…&to=…` (`alerts:read`) [`list_alerts`]: show the user how many.
  2. `POST /api/v1/alerts/actions/acknowledge` with `{"ids": [...]}` (at most 500) and an `Idempotency-Key` (`alerts:write`) [`acknowledge_alerts`]. `{"before": "…", "camera_id": …}` acknowledges every unacknowledged alert on that camera before a time, whatever its label, so use `ids` here.
- **Result:** the alerts acknowledged; `not_found_ids` and `forbidden_ids` reported.
- **Watch out:** `POST /api/v1/alerts/{alert_id}/actions/unacknowledge` undoes one. To stop such alerts in future, the user changes the camera's alert rules in the app.

## Shop or pharmacy owner

### 6. What were the busiest hours today?

- **Prompt:** "What were the busiest hours in the shop today?"
- **Calls:**
  1. `GET /api/v1/alerts?camera_id={camera_id}&label=person&from=…&limit=200` (`alerts:read`) [`list_alerts`], every page, then count per hour in the user's time zone.
  2. Or, with an API key, `POST /api/v1/guardian/chat` with `{"message": "What were the busiest hours today?", "camera_id": …, "timezone": "Asia/Bangkok"}` (`guardian:write`) [`guardian_chat`].
- **Result:** "Busiest 11:00-12:00 (34 detections), then 17:00-18:00 (29)."
- **Watch out:** detections are not unique visitors (one person can be detected several times). Say "people detections". The People counting add-on is coming soon. Guardian chat uses AI credits (`402 insufficient_credits`) and allows 10 chats a minute (`429 rate_limited`).

### 7. What did customers ask about?

- **Prompt:** "What did customers ask about at the counter today?"
- **Calls:**
  1. `GET /api/v1/cameras/{camera_id}` (`cameras:read`) [`get_camera`]: check `has_audio`.
  2. `GET /api/v1/guardian/entries?camera_id={camera_id}&from=…&to=…` (`guardian:read`) [`list_guardian_entries`], every page: read `audio_transcript`.
  3. Optionally `GET /api/v1/guardian/search?q=asked about price or stock&camera_id={camera_id}` [`search_guardian`].
- **Result:** the main topics with rough counts ("8 asked about cold medicine, 3 about opening hours").
- **Watch out:** only cameras with a microphone, AI and the Voice detection add-on have transcripts. Summarise topics; don't repeat names, phone numbers or health details from what customers said. Recording conversations may be regulated where the shop is: that is the owner's call.

### 8. Send me the clip of 14:05 to share with the police

- **Prompt:** "Send me the clip of 14:05 at the till so I can share it with the police."
- **Calls:**
  1. `GET /api/v1/cameras/{camera_id}/timeline?from=…&to=…` (`recordings:read`) [`get_camera_timeline`]: check there is footage.
  2. `POST /api/v1/clips` with `{"camera_id": …, "from": "…T14:03:00+07:00", "to": "…T14:08:00+07:00"}` and an `Idempotency-Key` (`recordings:write`) [`create_clip`]: `202`.
  3. `GET /api/v1/clips/{clip_id}` [`get_clip`] every few seconds until `status` is `ready` or `failed`.
  4. The HITL check, then `POST /api/v1/clips/{clip_id}/shares` with `{"expires_in": "7d"}` (`clips:share`, API key only) [`create_clip_share`]. The URL is in this answer only.
  5. For a file instead: `POST /api/v1/clips/{clip_id}/actions/create-download-url` (`recordings:write`) [`create_clip_download_url`], a one-time URL valid for 60 seconds.
  6. To keep the original footage: `GET /api/v1/recordings?camera_id={camera_id}&from=…&to=…` and `POST /api/v1/recordings/{recording_id}/actions/protect` (`recordings:write`) [`protect_recording`].
- **Result:** a public link that expires in 7 days (or a downloaded MP4), and protected recordings.
- **Watch out:** anyone with the link can watch it: give the shortest expiry that works (`1h`, `24h`, `7d`). A link made with an API key lives no longer than the key. Revoke with `DELETE /api/v1/clips/{clip_id}/shares/{share_id}`. Clip errors: `422 clip_too_long` (over 30 minutes), `422 clip_no_recordings`, `429 clip_user_busy` (one export at a time), `507 clip_no_space`. A ready clip is kept 24 hours (longer while a link is live). Over a sign-in connector there is no `clips:share`: make the clip, then the user taps **Share** in the app.

### 9. Keep last night's recordings

- **Prompt:** "Protect all recordings of the loading-bay camera from last night."
- **Calls:** `GET /api/v1/recordings?camera_id={camera_id}&from=…&to=…` (`recordings:read`) [`list_recordings`], then `POST /api/v1/recordings/{recording_id}/actions/protect` for each one with an `Idempotency-Key` (`recordings:write`) [`protect_recording`].
- **Result:** recordings that retention never deletes.
- **Watch out:** protected recordings may use at most 20% of the recordings disk (`409 protect_limit`); on a nearly full disk, `507 disk_low`.

### 10. A morning recap by email

- **Prompt:** "Every morning at 7, email me yesterday's alerts and what happened on my cameras."
- **Calls:** a script that pages through `GET /api/v1/alerts?is_alert=true&from=…&to=…` (`alerts:read`) and `GET /api/v1/events?from=…` (`events:read` plus the read scope of each event family; the log keeps 7 days), formats a summary and sends it with the user's own mail service; plus a cron line.
- **Result:** a script, a schedule, and a key with only `alerts:read`, `events:read` and `cameras:read`.
- **Watch out:** keep the key in the script's environment, not in the file.

## Installer or IT

### 11. Set up a new server

- **Prompt:** "This server is fresh. Check it and connect the cameras on the network."
- **Calls:**
  1. `GET /api/v1/setup/diagnostics` (`settings:read`) [`run_diagnostics`]: report each `warn` or `fail` check with its `detail`.
  2. For a `fix` of kind `auto`: the HITL check, then `POST /api/v1/setup/diagnostics/actions/fix` with its `action_id` (`settings:write`, admins) [`run_diagnostic_fix`]. `restart_go2rtc` stops live view and recording for a few seconds: say so. A `manual` step's shell commands run on the user's machine (often with `sudo`): show them and let the user run them or approve them.
  3. `GET /api/v1/network/candidates?wizard_ready=true` (`network:read`) [`list_camera_candidates`]; if empty, `POST /api/v1/network/auto-scan/actions/run` [`run_auto_scan`] (after the HITL check).
  4. Ask the user for each camera's maker and login, typed into an environment variable or the tool form, never the chat.
  5. `POST /api/v1/cameras/actions/detect` with `ip`, `username`, `password` and `vendor` (`cameras:write`) [`detect_camera`]: on `ok: true`, show resolution, fps and the snapshot.
  6. `POST /api/v1/cameras/actions/add-detected` with the `detection_id` and a name the user picks [`add_detected_cameras`].
  7. `GET /api/v1/setup/ai-camera-suggestions` (`cameras:read`) [`suggest_ai_cameras`], then `POST /api/v1/cameras/{camera_id}/actions/enable-ai` for the ones the user picks (`cameras:write`) [`enable_camera_ai`].
  8. `GET /api/v1/setup/checklist` (`settings:read`) [`get_setup_checklist`]: what is left.
- **Result:** a healthy server with named cameras, AI on the chosen ones, and a list of what is left.
- **Watch out (lockout budget):** cameras lock their account after a few wrong passwords. On `failure.code` `auth_failed`, **stop**: don't retry and don't guess passwords; report `attempts_left`. After 3 refused logins per camera in 30 minutes the probe sends nothing (`429 rate_limited`, `details.reason: camera_login_budget`, `Retry-After`). Without the right `vendor`, a camera may answer `no_stream`: ask for the maker. Hosted servers and containers without host networking: `409 network_unavailable`.

### 12. A camera went offline after a router restart

- **Prompt:** "The Garage camera went offline after we restarted the router."
- **Calls:**
  1. `GET /api/v1/cameras/{camera_id}` (`cameras:read`) [`get_camera`]: `status` is `offline`.
  2. `GET /api/v1/network/lookup?mac=…` (`network:read`) [`lookup_network_address`] with the camera's MAC (from the user, or **Hardware ID (MAC)** in the camera's settings): its address now.
  3. `POST /api/v1/cameras/{camera_id}/actions/relocate` with `{"dry_run": true}` (`cameras:write`) [`relocate_camera`]: show `old_ip`, `new_ip` and `changed`.
  4. The HITL check, then the same call with `{}` and an `Idempotency-Key`.
- **Result:** the camera on its new address, with recording and PTZ following.
- **Watch out:** always dry run first. `409 conflict` reasons: `old_address_alive` (something still answers at the old IP), `mac_mismatch`, `verify_failed`, `device_not_found`, `ambiguous`, `ip_in_use`, `no_hardware_id`. `503 network_busy` with `Retry-After`: camera following is using the network, or 4 lookup sweeps ran in 10 minutes; wait. 30 lookups a minute per credential (relocate counts). Vigiora often fixes this by itself within minutes; suggest a DHCP reservation so it doesn't happen again.

### 13. Find all cameras on this network not yet added

- **Prompt:** "Find all the cameras on this network that aren't in Vigiora yet."
- **Calls:**
  1. `GET /api/v1/network/candidates` (`network:read`) [`list_camera_candidates`]: what the last scans found (sends no traffic).
  2. For a fresh look, the HITL check, then `POST /api/v1/network/actions/scan` with `{"subnet": "192.168.1.0/24", "onvif": true}` [`start_network_scan`] and poll `GET /api/v1/network/scans/{scan_id}` [`get_network_scan`] until `status` is `done` or `failed`.
  3. `GET /api/v1/network/devices?unassigned=true` [`list_network_devices`]: devices no camera uses, with `vendor`, `open_ports` and `onvif`.
- **Result:** a table of likely cameras (IP, maker, ports, confidence) and the next step for each.
- **Watch out:** a scan sends traffic on the LAN (a confirm operation while human in the loop is on). Private subnets only, /22 to /30; one scan at a time (`409 scan_in_progress` with `details.scan_id`: poll that scan instead); 2 scans a minute; over 1022 hosts the scan is `truncated`. A scan sends no logins.

### 14. Add 10 Hikvision cameras with the same login

- **Prompt:** "Add these 10 Hikvision cameras; they all use the same login."
- **Calls:**
  1. Test the login on one camera first: `POST /api/v1/cameras/actions/detect` with `vendor: "Hikvision"` (`cameras:write`) [`detect_camera`].
  2. If it works: `POST /api/v1/cameras/actions/detect-batch` with `{"ips": [...], "username": …, "password": …, "vendor": "Hikvision"}` (1-32 addresses) [`detect_camera_batch`]: `202`.
  3. `GET /api/v1/cameras/detect-batches/{batch_id}` [`get_detection_batch`] every second until `status` is `done`.
  4. `POST /api/v1/cameras/actions/add-detected` with every `ok` detection and the names the user gives [`add_detected_cameras`].
- **Result:** the cameras that accepted the login are added; the others listed with their `failure.code` and `hint`.
- **Watch out:** a wrong shared password spends one try on every camera at once: that is why you test one first. Items with `rate_limited: true` were not tried. One running batch per user (`409`, `details.reason: batch_running`). An expired detection is `not_found` in `failed`: detect again. Without discovery, add cameras with `POST /api/v1/cameras` (one call per camera, each with its own `Idempotency-Key`).

### 15. Why does the Reolink show no PTZ?

- **Prompt:** "Why does my Reolink show no PTZ controls?"
- **Calls:**
  1. `GET /api/v1/cameras/{camera_id}` (`cameras:read`) [`get_camera`]: `has_ptz` is false, so PTZ calls answer `409 ptz_not_supported`.
  2. `GET /api/v1/network/devices?vendor=reolink` (`network:read`) [`list_network_devices`]: is port 8000 in `open_ports`?
- **Result:** the explanation and the fix. Reolink serves ONVIF on port 8000, not 80. From server 1.6.8 Vigiora tries ports 80, 8000, 8899, 2020 and 8080 by itself. If PTZ is still not detected: in the Reolink app turn on ONVIF; then in Vigiora open the camera, **Edit**, and in the PTZ block set **ONVIF address** to `http://<camera-ip>:8000/onvif/device_service`, **Save**, **Detect again**.
- **Watch out:** the ONVIF address is set in the app, not through API v1. An address typed by hand is not updated when the camera's IP changes.

### 16. A Reolink with RTSP off

- **Prompt:** "Vigiora says 'Possible camera' for a Reolink. What do I do?"
- **Calls:**
  1. `GET /api/v1/network/candidates?wizard_ready=false` (`network:read`) [`list_camera_candidates`]: the device has `confidence: low` and `hint_code: reolink_rtsp_off` (port 9000 only).
  2. Tell the user: Reolink app → **Settings → Network → Advanced → Server Settings** → turn on RTSP, ONVIF and HTTP.
  3. The HITL check, then `POST /api/v1/network/auto-scan/actions/run` [`run_auto_scan`], and `GET /api/v1/network/candidates?wizard_ready=true` again.
  4. Continue with `detect_camera` and `add_detected_cameras` (use case 11).
- **Result:** the Reolink found as a real camera and added.
- **Watch out:** a computer running the Reolink desktop app opens port 9000 too; such devices are not listed as candidates. `POST /api/v1/network/candidates/{candidate_id}/actions/dismiss` [`dismiss_camera_candidate`] hides a device that is not a camera.

### 17. Turn recording on for every camera of a site

- **Prompt:** "Turn recording on for all cameras at the warehouse."
- **Calls:** `GET /api/v1/sites` (`settings:read`) [`list_sites`], `GET /api/v1/cameras?site_id={site_id}` [`list_cameras`], show the list, then (after the HITL check) `POST /api/v1/cameras/actions/bulk-update` with `{"camera_ids": [...], "recording_enabled": true}` and an `Idempotency-Key` (`cameras:write`) [`bulk_update_cameras`].
- **Result:** a result per camera.
- **Watch out:** up to 100 cameras per call. The answer is `200` even when some cameras failed: read each result. Recording uses disk (about 33 GB a day for a 1080p camera).

### 18. A weekly health check

- **Prompt:** "Check all cameras and tell me which ones aren't recording."
- **Calls:** the MCP prompt `camera_health_check`, or `GET /api/v1/cameras` [`list_cameras`], `GET /api/v1/cameras/{camera_id}/timeline?from=…&to=…` (`recordings:read`) [`get_camera_timeline`] for the recording ones, `GET /api/v1/system/status` (`settings:read`) [`get_system_status`] for disks, and `GET /api/v1/setup/diagnostics?cached=true` [`run_diagnostics`].
- **Result:** cameras with gaps, offline cameras, disk space, and failed health checks.
- **Watch out:** the timeline covers at most 31 days per call.

## Developer or integrator

### 19. Webhooks to Slack, Telegram or Home Assistant

- **Prompt:** "Post to our Slack channel when a person is detected at the back door after 22:00."
- **Calls:**
  1. A small receiver that verifies each delivery and then forwards a message to Slack (incoming webhook), Telegram (the bot API) or Home Assistant.
  2. `POST /api/v1/webhooks` with `{"name": …, "url": "https://…", "event_types": ["alert.created"], "camera_ids": [...]}` (`webhooks:write`, admins) [`create_webhook`]: the `secret` is in this answer only. Store it in the receiver's secret store.
  3. `POST /api/v1/webhooks/{webhook_id}/actions/test` [`test_webhook`].
  4. In the receiver, `GET /api/v1/alerts/{alert_id}` (`alerts:read`) when it needs more than the event.
- **Result:** a tested receiver and a registered webhook.
- **Watch out:** verify `X-Vigiora-Signature` (HMAC-SHA256 of `X-Vigiora-Timestamp` + `.` + the raw body), compare in constant time, refuse timestamps older than 5 minutes, accept any of the comma-separated signatures (after `rotate-secret`), answer 2xx within 10 seconds, and deduplicate on the event `id`. Do the time-of-day check in the receiver. A Home Assistant address on the LAN over plain `http` needs `allow_insecure: true` (an admin session or an `admin`-scoped key); Home Assistant's own webhook trigger does not check the signature, so put a verifying relay in front, or use the event stream (use case 20).

### 20. An event stream consumer

- **Prompt:** "Write a service that reacts to alerts and camera outages in real time."
- **Calls:** `GET /api/v1/events/stream?types=alert.created,camera.offline,camera.online` (`events:read` plus `alerts:read` and `cameras:read`), Server-Sent Events.
- **Result:** a consumer that stores the last handled event `id` and reconnects with `Last-Event-ID`.
- **Watch out:** a stream ends after about a minute by design: reconnect at once with `Last-Event-ID` and missed events are replayed. Handle `: heartbeat`, `event: overflow` (reconnect with `Last-Event-ID`), `event: reset` (re-read the current state) and `event: shutdown`. At most 3 streams per key. After a long outage, catch up with `GET /api/v1/events?from=…` (7 days). Not available over MCP.

### 21. A nightly CSV export of alerts

- **Prompt:** "Every night, save the day's alerts as a CSV per camera."
- **Calls:** `GET /api/v1/alerts?from=…&to=…&limit=200` (`alerts:read`), following `next_cursor` with the same filters; group by `camera_id`; `GET /api/v1/cameras` for names.
- **Result:** a script, a cron line and a key with `alerts:read` and `cameras:read`.
- **Watch out:** `from` is inclusive and `to` exclusive, so consecutive nights never overlap. Changing a filter with a cursor is `400 invalid_cursor`. There are no totals.

### 22. Alerts from an external sensor

- **Prompt:** "When the back-door contact sensor opens, raise an alert on the back-door camera."
- **Calls:** `POST /api/v1/alerts` with `{"camera_id": …, "label": "door_open", "source": "door-sensor"}` and an `Idempotency-Key` (`alerts:write`, operator on the camera) [`create_alert`]. Read them back with `GET /api/v1/alerts?source=door-sensor`.
- **Result:** sensor events in Vigiora's alerts, Briefing, event stream and webhooks, next to the video.
- **Watch out:** labels starting `face:` are reserved; `detected_at` may be up to 7 days old. The camera's alert rules decide `is_alert`. Use a key with only `alerts:write`.

### 23. Back up the configuration

- **Prompt:** "Back up my server's configuration, including the camera passwords."
- **Calls:**
  1. The user sets the passphrase in an environment variable themselves (at least 12 characters).
  2. `GET /api/v1/config/export?include_secrets=true` with the `X-Export-Passphrase` header (`admin` scope, admin user) [`export_config`]. Without `include_secrets`, credentials are `REDACTED`.
  3. To restore: `POST /api/v1/config/import?dry_run=true` with the document (and the passphrase header) [`import_config`], check the summary, then the HITL check and the same call without `dry_run`.
- **Result:** an encrypted backup file, and a tested restore.
- **Watch out:** never print the passphrase or secrets. Every export is audited (`config.exported`). An import is all or nothing and never deletes; a retention reduction needs `allow_retention_reduction=true`, which deletes older recordings: set it only when the user asked for that reduction. Users, recordings and alerts are not in the export.

### 24. A scoped key for a contractor

- **Prompt:** "Give our installer access to the warehouse cameras for two weeks, nothing else."
- **Calls:**
  1. `GET /api/v1/groups` (`users:read`, admins) [`list_groups`]: the group that grants the warehouse cameras (groups are made in the app).
  2. `POST /api/v1/users` with `{"username": …, "password": …, "role": "operator", "group_ids": [...]}` (`users:write`, admins) [`create_user`]. The admin types the password; the agent reads it from an environment variable.
  3. The contractor signs in and creates their own key: `POST /api/v1/api-keys` with `{"name": "Install", "scopes": ["cameras:read", "cameras:write", "network:read"], "expires_in_days": 14}` (user sessions only).
  4. When the work is done: `PATCH /api/v1/users/{user_id}` with `{"enabled": false}` [`update_user`]. Admins can list every key with `GET /api/v1/api-keys?all_users=true`.
- **Result:** access limited to those cameras and scopes, ending by itself.
- **Watch out:** a key sees exactly the cameras its user may see, so limit cameras with the user's groups, not the key. API keys can never create keys (`403 api_key_not_allowed`). The last enabled admin can't be disabled (`409 conflict`).

### 25. Why did my webhook stop?

- **Prompt:** "My Vigiora webhook stopped sending. Find out why and fix it."
- **Calls:** `GET /api/v1/webhooks/{webhook_id}` (`webhooks:read`) [`get_webhook`]: `enabled`, `consecutive_failures`, `disabled_reason`; `GET /api/v1/webhooks/{webhook_id}/deliveries` [`list_webhook_deliveries`]: the error per delivery; after the receiver is fixed, `PATCH /api/v1/webhooks/{webhook_id}` with `{"enabled": true}` (`webhooks:write`) [`update_webhook`], and `POST /api/v1/webhooks/{webhook_id}/deliveries/{delivery_id}/actions/redeliver` [`redeliver_webhook`] for the ones that matter.
- **Result:** the cause, and deliveries flowing again.

## AI assistant over MCP (claude.ai connector)

### 26. Questions with Read only access

- **Prompt:** "Anything happen overnight? Which cameras recorded?"
- **Calls:** [`list_alerts`], [`get_alert_snapshot`], [`list_events`], [`list_recordings`], [`get_camera_timeline`], [`get_camera_snapshot`]; the prompts `daily_briefing`, `investigate_alert` (`alert_id`) and `camera_health_check`.
- **Result:** answers with pictures, without changing anything.
- **Watch out:** a **Read only** connection never sees a write tool, so it can't move cameras or acknowledge alerts: say so and point to **Read and control** if the user wants that. Text results are capped at about 100 KB: on a `truncated` note, ask again with a smaller `limit`. Snapshots are not served over a Cloudflare Tunnel address: connect through the site address or the LAN for pictures.

### 27. Actions with Read and control access

- **Prompt:** "Point the garden camera at the gate, turn AI on for it and acknowledge last night's alerts."
- **Calls:** [`list_ptz_presets`] and [`goto_ptz_preset`] or [`move_ptz`], [`enable_camera_ai`], [`acknowledge_alerts`].
- **Result:** the actions done, each reported with what changed (a fresh snapshot after a move).
- **Watch out:** first [`get_agent_policy`]. With `human_in_the_loop` true, `goto_ptz_preset`, `move_ptz` and `enable_camera_ai` need the user's OK (one sentence each; Vigiora may show the user an Allow/Deny prompt itself, or answer `confirmation_required`: ask, then retry with `confirm: true`); `acknowledge_alerts` doesn't. With it false, do all three directly. Always relocate with `dry_run` first. Viewers never get camera changes, PTZ or the network tools. `import_config` is not offered to sign-in connections; with an API key it needs the `admin` scope and a dry run first.

### 28. Set up a camera Vigiora found

- **Prompt:** "Set up the new camera Vigiora found."
- **Calls:** [`list_camera_candidates`] with `wizard_ready=true`, ask for the login (typed into the tool form, never the chat), [`detect_camera`] with the candidate's `ip` and `vendor`, then [`add_detected_cameras`] with a name the user picks.
- **Result:** the camera added with its sub-stream.
- **Watch out:** the password is a tool argument: suggest a camera account made for Vigiora. On `auth_failed`, stop and report `attempts_left`. `detect_camera` and `add_detected_cameras` are confirm operations: the HITL check first.

### 29. Should the assistant ask me first?

- **Prompt:** "Do you need my OK before you move cameras? I'd rather you just do it."
- **Calls:** `GET /api/v1/agent-policy` (any credential) [`get_agent_policy`]: `human_in_the_loop`, `source` and `override`.
- **Result:** "Human in the loop is on for this connection (the server setting), so I ask before moving cameras, scans and changes. You can turn it off for this app under **API keys → Connected apps → Ask before actions → Never ask**, or an admin can turn it off for the server under **System → AI agents**."
- **Watch out:** the agent can't change the policy itself: keys and connected apps can't manage keys or apps, and `PATCH /api/v1/settings/agents` [`update_agent_settings`] is itself a confirm operation (admins, `settings:write`). While the server setting is on, only an admin can choose **Never ask**. The change applies on the next call: check [`get_agent_policy`] again afterwards.

## Accessibility

### 30. Who is at the door? (spoken)

- **Prompt:** "I'm blind. Someone knocked. Who is at the door?"
- **Calls:** `GET /api/v1/cameras/{camera_id}/snapshot` (`cameras:read`) [`get_camera_snapshot`], then describe the picture. With an API key and the admin or operator role, `POST /api/v1/cameras/{camera_id}/actions/analyze` (`guardian:write`) [`analyze_camera`] adds Guardian's own description from a short clip.
- **Result:** one or two spoken sentences: "One person, a woman in a blue delivery uniform, holding a small box, standing at the door."
- **Watch out:** say how old the picture is when it isn't live (`age_seconds`). Describe what is visible; don't guess identity unless a face is recognised (`label=face` alerts). Analyze uses AI credits, 6 a minute, and non-admins wait for the camera's 5-minute cooldown (`429`, `details.reason: camera_cooldown`). Errors: `409 ai_not_enabled`, `503 capture_failed`.

### 31. Read me today's recap

- **Prompt:** "Read me today's recap."
- **Calls:** the MCP prompt `daily_briefing`, or `GET /api/v1/alerts?is_alert=true&from=…` [`list_alerts`] and, with an API key, `GET /api/v1/briefing/recap` [`get_briefing_recap`] (server 1.6.10+, the AI-written summary) or `GET /api/v1/guardian/entries?from=…` [`list_guardian_entries`].
- **Result:** a recap written to be heard: short sentences, times in words ("just after two in the afternoon"), most important first, no tables, no URLs or ids read aloud.
- **Watch out:** end with what needs action, and offer details on request instead of reading every event.

### 32. Describe what changed

- **Prompt:** "I have low vision. Tell me what changed in the garden since this morning."
- **Calls:** `GET /api/v1/guardian/entries?camera_id={camera_id}&from=…` (`guardian:read`) [`list_guardian_entries`], or over a sign-in connector the alerts with their snapshots, plus a current [`get_camera_snapshot`].
- **Result:** a plain-language list of changes, then a description of the garden now.
- **Watch out:** keep the same order every time (now, then changes, then what to check), so the answer is easy to follow by ear.

## Objects, frames and photos (server 1.6.10)

Object recognition runs on the `hal-objects` [HAL service](https://vigiora.com/docs/ai/hal-services.md), a preview on a machine with an NVIDIA GPU. Without it, `detect_objects`, `analyze_image` with `detect` and `include_objects` answer `503 no_detector`: say that object recognition isn't set up on this server (available on request), and fall back to Guardian (search, entries, chat). Prompts are plain words; describe the thing (`black t-shirt`, `red car`, `parcel`), not just `t-shirt`: bare clothing words score below the 0.25 default.

### 33. Find a person in a red shirt at the entrance in the last hour

- **Prompt:** "Find a person in a red shirt at the entrance in the last hour."
- **Calls:**
  1. `GET /api/v1/cameras` (`cameras:read`) [`list_cameras`]: the Entrance camera's id. Ask for the user's time zone if you don't know it.
  2. `GET /api/v1/cameras/{camera_id}/detection-events?from=…&to=…&label=person` (`alerts:read`) [`list_camera_detection_events`]: when people were seen (both `core-ai` and HAL reports; `source=hal-objects&label=red shirt` when the camera's object recognition already looks for it).
  3. `GET /api/v1/guardian/search?q=person in a red shirt&camera_id=…` (`guardian:read`) [`search_guardian`]: Guardian's descriptions mention clothing colours.
  4. For each candidate moment: `POST /api/v1/cameras/{camera_id}/actions/detect-objects` `{"at":"2026-11-01T14:37:05+07:00","prompts":["person","red shirt"]}` (`cameras:read` + `recordings:read`) [`detect_objects`], then `GET /api/v1/object-images/{image_id}` [`get_object_image`] to show the boxes.
- **Result:** "Two moments: 14:12 a man in a red shirt walked to the door (picture), 14:37 a woman in a red jacket (picture; the recognition scored it 0.46 as red shirt)."
- **Watch out:** a detection is a likelihood, not a fact: show the picture and say how sure it is. 20 detect-objects calls a minute; pick moments from steps 2 and 3 instead of scanning every second. A recorded `at` without `recordings:read` is `403 insufficient_scope`. These are reads: no HITL check needed.

### 34. What objects are on camera X now?

- **Prompt:** "What objects are on the garage camera now?"
- **Calls:** `POST /api/v1/cameras/{camera_id}/actions/detect-objects` with no `at` (`cameras:read`) [`detect_objects`]; without `prompts` the camera's own list is used, or send your own (`["car","bicycle","parcel","person"]`). Show [`get_object_image`]. `GET /api/v1/cameras/{camera_id}/objects` [`get_camera_objects`] gives the live people and vehicle counts of the counting service.
- **Result:** "A car (0.53), a bicycle (0.41) and a parcel by the door (0.38)."
- **Watch out:** a parked car or a plant can be misread as another object on a still night scene; check the picture. `503 snapshot_unavailable` when the camera gives no live frame; `504 detector_timeout` after 10 s.

### 35. Describe this uploaded photo

- **Prompt:** "Describe this photo." (the user attaches an image)
- **Calls:** `POST /api/v1/images/actions/analyze` (`cameras:read`; `describe` also needs `guardian:write` and uses AI credits) [`analyze_image`]. Over MCP, pass the image in `image_base64` (a `data:` URL is fine); a script can use `multipart/form-data` with the field `image`.
- **Result:** a short description, plus the objects found (`detect`, default on).
- **Watch out:** JPEG, PNG or WebP, at most 10 MB and 40 megapixels; over MCP a call carries at most 1 MB, so about 750 KB of image: scale it down first. The image is never stored; tell the user so if they ask. Sign-in connections (claude.ai connector) have no `guardian:write`: send `describe: false` and describe the picture yourself. 6 a minute with `describe`, 20 without.

### 36. A still from the recordings at an exact time

- **Prompt:** "Show me the driveway at 07:30 this morning."
- **Calls:** `GET /api/v1/cameras/{camera_id}/frame?at=2026-11-01T07:30:00+07:00&width=1280` (`recordings:read`) [`get_camera_frame`]. `X-Vigiora-Frame-Time` is the frame's exact time. For a Guardian entry, `GET /api/v1/guardian/entries/{entry_id}/frame` [`get_guardian_entry_frame`] is the picture that shows the event best.
- **Result:** the picture, with its time.
- **Watch out:** `404 no_recording` when nothing was recorded then: offer `details.nearest_before` or `details.nearest_after`. The segment being written is available once it closes (a minute or so). 30 frames a minute; to step through time, call it a few times rather than exporting a clip. Over the relay a frame doesn't count against the free plan's video allowance.

## Speakers and person alerts (server 1.6.11)

### 37. Why didn't I get an alert?

- **Prompt:** "Guardian says it saw a man in the driveway at 04:10, so why didn't I get an alert?"
- **Calls:**
  1. `GET /api/v1/guardian/entries?camera_id={camera_id}&from=…&to=…` (`guardian:read`) [`list_guardian_entries`]: the entry around 04:10.
  2. Read `unconfirmed_alerts`, `detector_checked` and `person_present_seconds` on it. A rule listed in `unconfirmed_alerts` matched, but the camera's person detector watched the clip and saw nobody, so the rule's `require_detector_confirmation` held the alert back.
  3. `GET /api/v1/guardian/entries/{entry_id}/frame` [`get_guardian_entry_frame`]: show the picture so the user can judge.
- **Result:** "The rule *person at the gate* matched, but the object detector watched the whole clip and saw no one (0 seconds of a person in view), so no alert was sent. Here is the picture: it shows moving shadows on an empty driveway."
- **Watch out:** if the picture does show a person, the detector missed them (small, far away or seated people score lower). Offer to turn the setting off for that rule with `PATCH /api/v1/alert-rules/{alert_rule_id}` `{"require_detector_confirmation":false}` (`alerts:write`) [`update_alert_rule`], a confirm operation: ask first while human in the loop is on. `person_present_seconds: null` means the detector sent no presence report for that time (an older detector, or its stream dropped).

### 38. Talk through a camera's speaker without a Vigiora Client

- **Prompt:** "Make the gate camera say: please close the gate."
- **Calls:**
  1. `GET /api/v1/outputs` (`cameras:read`, admins and operators) [`list_outputs`]: a speaker with `kind: "camera_backchannel"` on that camera.
  2. If there is none: `POST /api/v1/outputs` `{"name":"Gate speaker","kind":"camera_backchannel","camera_id":7}` (`cameras:write`) [`create_output`], without `client_id`, so this server plays it (server 1.6.11, a camera the server streams itself).
  3. `POST /api/v1/outputs/{output_id}/actions/test` `{"text":"Please close the gate."}` (`cameras:control`) [`test_output`].
- **Result:** `{"output_id": 6, "played": true}` once the camera has said it, a few seconds after the call.
- **Watch out:** creating a speaker and speaking are confirm operations: ask first while human in the loop is on. A `502` whose message says *this camera has no speaker / two-way audio* means the camera offers no two-way audio; *camera speakers are not available on this server* means a Docker install, which can't play camera speakers yet. One message per camera at a time, at most 60 seconds. Check local rules before speaking to people.

## Analytics and moments (server 1.6.13)

### 39. How many customers came in this morning?

- **Prompt:** "How many customers came in between 9 and 12 today, and how many are inside now?"
- **Calls:**
  1. `GET /api/v1/analytics/areas` (`analytics:read`) [`list_analytics_areas`]: the shop's area (an area groups the entrance lines).
  2. `GET /api/v1/analytics/counts?area_id={analytics_area_id}&from=2026-11-03T09:00&to=2026-11-03T12:00&step=1h` [`get_analytics_counts`]: `in`, `out`, `covered_pct` and one point per hour. A local time without an offset is in the server's time zone.
  3. `GET /api/v1/analytics/occupancy?area_id={analytics_area_id}` [`get_analytics_occupancy`]: how many are inside now, with the area's capacity.
- **Result:** "84 people came in between 9 and 12, most between 10 and 11 (37). 12 are inside now, of 40."
- **Watch out:** when `covered_pct` is below 100, the detector wasn't watching the whole time: say so with the numbers. Counts are kept in 15-minute buckets, so `from` is rounded down to the quarter hour. A key without scopes (from the **API keys** page) has no `analytics:read` and gets `403 insufficient_scope` (and no Analytics tools over MCP): ask for a scoped key or a sign-in connection. A camera without the Analytics add-on or an object detector counts nothing.

### 40. Delete a false alarm, and bring it back

- **Prompt:** "Delete last night's moment about a cat on the porch. Actually, bring it back."
- **Calls:**
  1. `GET /api/v1/guardian/entries?camera_id={camera_id}&from=…&to=…` (`guardian:read`) [`list_guardian_entries`]: find the moment and show its picture with `GET /api/v1/guardian/entries/{entry_id}/frame` [`get_guardian_entry_frame`].
  2. `DELETE /api/v1/guardian/entries/{entry_id}` (`guardian:write`, admins and operators) [`delete_guardian_entry`]: the moment, its clip, frame and the alerts Guardian raised for it go to Recently deleted. Recordings are kept.
  3. To undo: `GET /api/v1/guardian/trash` [`list_guardian_trash`], then `POST /api/v1/guardian/trash/actions/restore` `{"ids":[…]}` [`restore_guardian_entries`].
- **Result:** "Deleted. It stays in Recently deleted for 7 days." … "Restored, with the same id and its alerts."
- **Watch out:** deleting is a confirm operation: show the picture and ask first while human in the loop is on. `409 entry_protected` means a protected recording covers it; `409 entry_shared` means a clip export or share link covers it, and only an admin can force the delete, which revokes those links: never force without the user's explicit OK. `POST /api/v1/guardian/trash/actions/purge` (admins) deletes for good.
