---
title: "API conventions"
description: "The rules every API v1 operation follows — errors and error codes, cursor pagination, Idempotency-Key, rate limits, times, ids and actions."
url: https://vigiora.com/docs/developers/api-conventions
updated: 2026-12-03T18:24:47.000Z
---

# API conventions

> The rules every API v1 operation follows — errors and error codes, cursor pagination, Idempotency-Key, rate limits, times, ids and actions.

Every operation of API v1 follows the same rules. Learn them once and every endpoint behaves the way you expect.

## Requests and responses

| Topic | Rule |
| --- | --- |
| Names | JSON properties and query parameters are `snake_case`. Paths use plural nouns (`/cameras`, `/api-keys`) and name their ids after the resource (`{camera_id}`). |
| Bodies | Request bodies are JSON. **Unknown fields are refused** (`400 validation_error`), so a typo never silently does nothing. |
| Ids | Integers for cameras, alerts, recordings, shares and API keys; strings for clips, network scans and PTZ preset tokens. Treat them as opaque. |
| Missing values | Optional values are present as `null`, never left out. |
| Booleans in queries | `true` or `false` only. `1` and `0` are refused. |
| Methods | `GET` reads, `POST` creates (`201`, or `202` for a job such as a clip export, with a `Location` header), `PATCH` changes only the fields you send, `DELETE` deletes or revokes (`204`). `PUT` is never used. |
| Media | Snapshots and recordings answer the image or video on success and the JSON error on failure. Video supports range requests. Signed media links (`/api/v1/media/<token>/...`, from API 1.17) carry their own short-lived token and need no header. |

## Times

All times are **RFC 3339**. Responses are always in UTC, for example `2026-10-30T14:05:00Z` (with fractional seconds when there are any). In requests you may use any offset, such as `2026-10-30T21:05:00+07:00`, but a time **without** an offset is refused with `400 validation_error`. Durations are whole seconds (`duration_seconds`) and sizes whole bytes (`size_bytes`).

## Actions

Things that aren't plain create, read, update or delete are **actions**: `POST` to `…/actions/<verb>`.

| Action | Example |
| --- | --- |
| On one resource | `POST /api/v1/cameras/3/actions/enable-ai`, `POST /api/v1/alerts/1201/actions/acknowledge` |
| On a collection | `POST /api/v1/alerts/actions/acknowledge` (bulk) |
| On a sub-resource | `POST /api/v1/cameras/3/ptz/actions/move`, `POST /api/v1/clips/{clip_id}/actions/create-download-url` |

An action answers the updated resource when there is one, else a small result object. Send no body or `{}` to actions without parameters.

## Errors

Every error, from every endpoint (including unknown paths and media endpoints), has the same shape:

```json
{
  "error": {
    "code": "insufficient_scope",
    "message": "This API key lacks the cameras:write scope.",
    "details": { "required_scope": "cameras:write", "granted_scopes": ["cameras:read"] }
  }
}
```

- `code` is stable and meant for your code. New codes may be added within v1.
- `message` is for people and may change.
- `details` is an object, possibly empty. Its keys depend on the code.

### Error codes

| HTTP | `code` | Meaning |
| --- | --- | --- |
| 400 | `validation_error` | A bad body field or parameter. `details.field` names it when one field is at fault. |
| 400 | `invalid_cursor` | The cursor is malformed, or comes from another endpoint or other filters. |
| 400 | `idempotency_not_supported` | `Idempotency-Key` was sent to an operation that refuses it. |
| 401 | `unauthenticated` | No credential, or an invalid, expired or revoked key or session. |
| 402 | `limit_reached` | A plan limit. `details.limit`, `details.allowed`, `details.used`, `details.pending`. |
| 402 | `insufficient_credits` | The AI credits ran out (camera analysis, Guardian chat). |
| 403 | `insufficient_scope` | The key lacks the scope. `details.required_scope`, `details.granted_scopes`. |
| 403 | `forbidden` | The user's role or camera permission is too low. |
| 403 | `api_key_not_allowed` | The operation needs a user session (key management), or a key may not write that field. |
| 404 | `not_found` | No such resource, or not visible to you. Also unknown paths. |
| 404 | `no_recording` | No recorded footage at the requested time (frames from recordings). `details.nearest_before` and `details.nearest_after` are the closest recorded moments, or `null`. |
| 404 | `no_preview` | A recording has no preview pictures: it has no video (a microphone) or is still being written. |
| 405 | `method_not_allowed` | The `Allow` header lists the methods. |
| 409 | `conflict` | A state conflict; `details` depends on the operation. |
| 409 | `idempotency_key_in_progress` | A request with the same `Idempotency-Key` is still running. |
| 409 | `dependency_not_met` | An AI service needs another one first (`details.requires_any`). |
| 409 | `dependent_service_assigned` | Another AI service depends on this one (`details.dependent`). |
| 409 | `ptz_not_supported` | The camera has no PTZ (`has_ptz` is false). |
| 409 | `onvif_disabled` | The camera's **Use ONVIF** switch is off (`onvif_enabled` is false). |
| 409 | `not_a_robot` | The camera is not a Vigiora Robot, so robot actions do not apply. |
| 409 | `robot_unsupported` | The robot's firmware lacks this feature. Update the robot's firmware. |
| 409 | `light_unsupported` | The robot's firmware has no light control. |
| 409 | `robot_busy` | The robot is moving, on a route or away on a Bluetooth job. Retry when it stands still. |
| 409 | `ble_unsupported` | The robot's firmware has no Bluetooth jobs. |
| 409 | `battery_low` | The robot's battery is too low for the job. Charge it first. |
| 409 | `ptz_busy` | Another PTZ command for this camera is running. Retry shortly. |
| 409 | `clip_not_ready` | The clip export hasn't finished yet. |
| 409 | `clip_too_old` | The clip is too old to share. |
| 409 | `ai_not_enabled` | The camera has no AI, so it can't be analysed. |
| 409 | `protect_limit` | Protected recordings already use their share of the disk (20% by default). Unprotect some first. |
| 409 | `network_unavailable` | The network tools can't see the LAN here (hosted server, a container without host networking…). `details.reason` says why. |
| 409 | `scan_in_progress` | A network scan is already running. `details.scan_id` is its id. (A Bluetooth scan already running answers the same code.) |
| 409 | `bluetooth_unavailable` | The server can't scan Bluetooth here (not Linux, no adapter, the adapter is off, or it's denied). `details.reason` says why. |
| 409 | `entry_protected` | A protected recording covers the moment's clip, so it can't be deleted. Unprotect the recording first. |
| 409 | `entry_shared` | An active clip export or public share link covers the moment. `details.reasons`, `details.recording_ids`, `details.clip_ids`, `details.share_ids`, `details.can_force`. An admin can delete it anyway with `force=true`, which revokes the covering share links. |
| 403 | `user_declined` | MCP only: the user chose **Deny** on the approval prompt ([human in the loop](https://vigiora.com/docs/developers/human-in-the-loop)). Don't retry unless the user asks. |
| 428 | `confirmation_required` | MCP only: human in the loop is on and the action needs the user's approval. Show `details.action`, and only if the user agrees call again with `confirm: true`. |
| 413 | `payload_too_large` | The body is over the operation's limit. |
| 415 | `unsupported_media_type` | The body is not JSON, or an uploaded image is not JPEG, PNG or WebP. |
| 422 | `idempotency_key_reused` | The same `Idempotency-Key` was used for a different request. |
| 422 | `clip_too_long` | The clip asks for more than 30 minutes. |
| 422 | `clip_no_recordings` | There is no recording in the requested time. |
| 422 | `timelapse_too_long` | The timelapse asks for a range of more than 7 days. |
| 422 | `timelapse_too_short` | The range holds too little footage for the length you chose. |
| 422 | `speaker_not_supported` | The camera's speaker check found no audio backchannel, so it can't speak. |
| 429 | `rate_limited` | Too many requests, or too many failed key attempts. `Retry-After` is set. |
| 429 | `relay_limit` | The free plan's remote video allowance is used up (recording media through Vigiora's relay). |
| 429 | `clip_busy` | The server is busy exporting other clips. `Retry-After` is set. |
| 429 | `timelapse_busy` | The server is already making a timelapse. `Retry-After` is set. |
| 429 | `clip_user_busy` | You already have a clip export running. `Retry-After` is set. |
| 429 | `stream_limit` | Too many open event streams (3 per key, 200 per server). |
| 502 | `ptz_failed` | The camera refused or didn't answer a PTZ command. `message` is safe to show. |
| 503 | `addon_offline` | The add-on the operation needs is not installed or not running. |
| 502 | `detector_failed` | The object recognition service failed on the frame or image. |
| 502 | `device_failed` | Home Assistant refused or failed a device command, or can't be reached when connecting. |
| 503 | `device_unreachable` | A device on the local network, such as a Vigiora Robot, did not answer. Sent with `Retry-After`; try again later. From API 1.147.0. |
| 503 | `ptz_unavailable` | PTZ isn't available on this server right now. |
| 503 | `snapshot_unavailable` | No current frame and no recent one to serve. |
| 503 | `capture_failed` | The camera gave no clip to analyse. |
| 503 | `stream_unavailable` | The camera's live stream isn't available on this server right now, so no stream link can be made. |
| 503 | `preview_busy` | The server is busy making other preview pictures. `Retry-After` is set. |
| 503 | `preview_unavailable` | The preview pictures can't be made now: the camera's privacy masks can't be read (nothing unmasked is ever served) or the picture tool failed. |
| 503 | `ai_unavailable` | The AI service didn't answer. Retry later. |
| 503 | `service_unavailable` | A feature is not enabled or temporarily unavailable. |
| 503 | `no_detector` | No object recognition add-on is online for this camera (see [Add-ons](https://vigiora.com/docs/ai/hal-services)). |
| 504 | `detector_timeout` | The object recognition service didn't answer within 10 seconds. Retry later. |
| 503 | `network_busy` | Automatic camera following is using the network, or the server's lookup budget is spent (`details.reason`). `Retry-After` is set. |
| 507 | `clip_no_space` | Not enough disk space for the clip. |
| 507 | `clip_quota` | Your clip storage quota is used. |
| 507 | `disk_low` | The disk is critically low, so no new recording can be protected. Existing protections stay. |
| 500 | `internal_error` | Logged on the server with `details.request_id`. Include it if you report the problem. |

Handle unknown codes by their HTTP status.

## Pagination

Lists answer a page:

```json
{ "data": [ { "id": 1 }, { "id": 2 } ], "next_cursor": "eyJ2IjoxLCJlIjoiY2FtZXJhcyIsImsiOlsyXX0" }
```

- `?limit=` sets the page size, 1–200 (default 50).
- To get the next page, send `?cursor=<next_cursor>` **with the same filters**. A cursor used with another endpoint or other filters is `400 invalid_cursor`.
- `next_cursor` is `null` on the last page.
- Pages stay stable while new rows arrive: you never see a row twice or skip one because of an insert.
- There are no totals.
- Cursors are opaque. Don't build or parse them; their format may change.

Each list has a fixed order: cameras by id, alerts newest first, recordings oldest first within the range, clips newest first.

```bash
URL="https://yourname.vigiora.com/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 vgk_xxxxxxxx_xxxxxxxxxxxxxxxx")
  echo "$PAGE" | jq -c '.data[]'
  CURSOR=$(echo "$PAGE" | jq -r '.next_cursor // empty')
  [ -z "$CURSOR" ] && break
done
```

## Idempotency-Key

Network errors happen. To retry a write safely, send an `Idempotency-Key` header with a value you choose (1–255 printable ASCII characters, for example a UUID):

```bash
curl -s -X POST https://yourname.vigiora.com/api/v1/clips \
  -H "Authorization: Bearer vgk_xxxxxxxx_xxxxxxxxxxxxxxxx" \
  -H "Idempotency-Key: 0c6c2d1e-5b0f-4f43-9d8e-7b1f0a3c2e11" \
  -H "Content-Type: application/json" \
  -d '{"camera_id":3,"from":"2026-10-30T14:00:00Z","to":"2026-10-30T14:05:00Z"}'
```

- It is honoured on `POST /cameras`, `POST /clips`, `POST /alerts` and every `…/actions/…` operation. The [reference](https://vigiora.com/docs/developers/api-reference) says so per operation.
- The first response is stored for **24 hours**, per credential. Retrying the same request with the same key returns the stored response with the header `Idempotent-Replayed: true`, without doing the work twice. Before replaying a success, the server checks that you may still access the camera, alert or clip.
- The same key with a **different** request is `422 idempotency_key_reused`. While the first request is still running, it is `409 idempotency_key_in_progress`.
- Server errors (5xx) are not stored, so you can simply retry them.
- Operations whose answer contains a secret shown once (creating an API key, creating a share link) refuse the header with `400 idempotency_not_supported`.
- At most 10,000 responses are kept per credential; past that, the oldest are dropped.

## Rate limits

Each credential (an API key, or a user for sessions) has a bucket of **120 requests**, refilled at **10 per second** (600 a minute sustained). Every response carries:

| Header | Meaning |
| --- | --- |
| `RateLimit-Limit` | The bucket size. |
| `RateLimit-Remaining` | Requests left now. |

When the bucket is empty, the answer is `429 rate_limited` with a `Retry-After` header (seconds) and `details.retry_after_seconds`. Wait that long, then retry. Other `429` codes (`relay_limit`, `clip_busy`, `clip_user_busy`) work the same way.

AI operations have extra limits per credential: at most 6 camera analyses (`POST /cameras/{camera_id}/actions/analyze`) and 10 Guardian chats a minute, and 2 AI operations at once. Non-admins also wait 5 minutes between analyses of the same camera (`429 rate_limited` with `details.reason: camera_cooldown`).

Frames and object recognition have their own limits per credential, and share the limit of 2 AI operations at once:

| Operation | Limit |
| --- | --- |
| `GET /cameras/{camera_id}/frame` (a frame from the recordings) | 30 a minute |
| `POST /cameras/{camera_id}/actions/detect-objects` | 20 a minute |
| `POST /images/actions/analyze` | 6 a minute with `describe` (the analysis limit), 20 a minute for detection only |

Live media and device actions have their own limits:

| Operation | Limit |
| --- | --- |
| `POST /cameras/{camera_id}/actions/stream-url` and `snapshot-url` (signed links) | 60 links a minute per credential |
| Requests to the signed media links (`/api/v1/media/...`) | 6000 a minute per credential |
| `POST /cameras/{camera_id}/actions/speak` | 12 a minute per credential |
| Home Assistant device commands | 10 a minute per device, 30 a minute per credential, 60 a minute in all |

The [network tools](https://vigiora.com/docs/developers/network-tools) allow at most 2 scans and 30 lookups a minute per credential (a camera relocate counts as a lookup).

Through Vigiora's relay on the free plan, playing recordings counts against the monthly remote video allowance, like in the app. See [Free plan remote video limit](https://vigiora.com/docs/remote-access/free-plan-remote-video-limit).

## Related pages

- [Authentication and scopes](https://vigiora.com/docs/developers/api-authentication)
- [API reference](https://vigiora.com/docs/developers/api-reference)

---

Source: https://vigiora.com/docs/developers/api-conventions · Last updated 3 Dec 2026, 18:24 UTC
