Camera Integration Partner API
Register and manage live camera streams for Animal Friends OS pet-care businesses. Cameras you register appear directly inside the OS camera viewer that boarding & daycare clients already use to watch their pets.
This API is built for camera hardware and streaming partners. You provision a stream URL for a tenant's facility; Animal Friends OS handles the branded viewer, secure stream proxying, client access links, and audio containment. You never touch customer PII — you work with cameras, stream URLs, and online/offline status.

A key + secret pair scoped to your environment. Sandbox and live keys, one host.
Set up auth →Confirm credentials, register your first camera, watch it appear in the viewer.
Start building →Register, list, update, and report status for every camera you manage.
Browse endpoints →Signed, HMAC-verified events whenever one of your cameras changes state.
Wire up events →1Base URLs
The API host is the same for both environments. Your credentials decide the environment — a sandbox key operates only against your isolated sandbox tenant; a live key operates against exactly the shops that have connected you, named by their site code.
| Environment | Base URL | Selected by |
|---|---|---|
| Sandbox | https://animalfriendsos.app | afos_ck_sandbox_… + afos_sk_sandbox_… |
| Live | https://animalfriendsos.app | afos_ck_live_… + afos_sk_live_… |
All endpoints are versioned under /api/partner/v1. JSON in, JSON out. All requests must be HTTPS.
2Authentication
Every request (except this documentation and the discovery root) is authenticated with a key + secret pair:
- Key ID —
afos_ck_<env>_…— a public identifier, safe to log. - Secret —
afos_sk_<env>_…— private. We store only a SHA-256 hash of it; treat it like a password and never expose it in client-side code.
Send them as two headers:
X-AFOS-Key: afos_ck_sandbox_0b9bc1a844dec444a7 X-AFOS-Secret: afos_sk_sandbox_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Or, equivalently, as a colon-joined bearer token:
Authorization: Bearer afos_ck_sandbox_0b9bc1a844dec444a7:afos_sk_sandbox_xxxx
403 key_revoked.3Sandbox
Your sandbox credentials are bound to a single, dedicated sandbox tenant that contains no real customer data. A sandbox key is structurally incapable of reading or mutating any production tenant — the tenant is resolved server-side from your key, never from anything in your request. Build and test freely; nothing you do in sandbox can reach a real business.
When you are ready for production, Animal Friends OS issues live credentials. A live key on its own reaches nothing — each shop connects you itself and gives you a site code. See Connecting a shop; it is the one extra thing a live integration has to implement.
X-AFOS-Site header with a sandbox key it is refused (403 site_code_not_for_environment) rather than silently ignored — so a mis-wired environment fails loudly instead of writing to the wrong place.4Connecting a shop (site codes)
A live credential does not carry a tenant. Each shop grants you access itself, from Dashboard › Cameras inside Animal Friends OS: they pick you as their camera provider, press Connect, and the OS generates a site code that identifies that one location.
SITE-7QK4-M2XR-9PD3
The shop copies that code and sends it to you. You store it against that customer and send it back on every request as the X-AFOS-Site header:
X-AFOS-Key: afos_ck_live_481acc0ff25dc1c726 X-AFOS-Secret: afos_sk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx X-AFOS-Site: SITE-7QK4-M2XR-9PD3
Rules, in full:
- The header selects which linked shop the request applies to. It is an addressing token, not a credential — on its own it grants nothing, and it only ever resolves to a shop that has already connected your key.
- If you are connected to exactly one shop you may omit it and we resolve that shop. As soon as a second shop connects you, an unaddressed request returns
400 site_code_requiredrather than guessing. - No shop has connected you yet →
403 no_tenant_link. Nothing is wrong with your key; there is simply nobody to talk to yet. - The code is unknown, belongs to another partner, or was revoked →
403 unknown_site_code. These are deliberately the same error, so the endpoint cannot be used to probe which codes exist. - Formatting is forgiving. Case, spaces and dashes are normalised:
site-7qk4-m2xr-9pd3,7QK4M2XR9PD3andSITE-7QK4-M2XR-9PD3are the same code. Store it however you like. - Codes change. A shop can press Regenerate (the old code dies immediately) or Disconnect (access is revoked on your very next request — nothing is cached). Handle a sudden
403 unknown_site_codeas "ask the customer for their current code", not as an outage. - If you prefer a query parameter,
?site_code=SITE-7QK4-M2XR-9PD3is accepted anywhere the header is. The header is preferred; it does not end up in logs and proxies. - external_ref is scoped per shop. Two customers may both use
front-1; they are two different cameras and neither can overwrite the other.
GET /api/partner/v1/ping with the site code. A 200 echoes back the tenant_id and site_code it resolved to; anything else tells you exactly what is wrong. This is the right check to run when a customer first hands you a code.curl https://animalfriendsos.app/api/partner/v1/ping \ -H "X-AFOS-Key: $AFOS_KEY" \ -H "X-AFOS-Secret: $AFOS_SECRET" \ -H "X-AFOS-Site: SITE-7QK4-M2XR-9PD3"
{
"error": {
"type": "authentication_error",
"code": "no_tenant_link",
"message": "No shop has connected this partner yet. The shop connects you from Dashboard > Cameras in Animal Friends OS and gives you the site code it generates; send that code as the X-AFOS-Site header."
}
}55-minute quickstart
1. Confirm your credentials work.
curl https://animalfriendsos.app/api/partner/v1/ping \ -H "X-AFOS-Key: $AFOS_KEY" \ -H "X-AFOS-Secret: $AFOS_SECRET" # LIVE: add the shop's site code. Omit it only while exactly one shop # has connected you. # -H "X-AFOS-Site: $AFOS_SITE"
{
"object": "response",
"data": {
"object": "ping",
"ok": true,
"partner": "abcKam",
"environment": "sandbox",
"tenant_id": 42,
"site_code": null,
"key_id": "afos_ck_sandbox_0b9bc1a844dec444a7",
"server_time": "2026-01-15T10:30:00.000Z"
}
}2. Register a camera. Provide your own stable external_ref (your camera's id in your system) and the stream URL.
curl -X POST https://animalfriendsos.app/api/partner/v1/cameras \
-H "X-AFOS-Key: $AFOS_KEY" \
-H "X-AFOS-Secret: $AFOS_SECRET" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: cam-create-001" \
-H "X-AFOS-Site: SITE-7QK4-M2XR-9PD3" \
-d '{
"external_ref": "kennel-7-cam",
"name": "Kennel 7 — Suite View",
"stream_url": "https://cdn.abckam.com/streams/kennel-7.mjpg",
"area_type": "boarding",
"status": "online"
}'3. That's it. The camera is now live in the OS viewer for that tenant. Update its status any time as your stream goes up or down (step 5 below).
6Errors
Every error uses one envelope. HTTP status conveys the class; error.code is a stable machine-readable string.
{
"error": {
"type": "invalid_request_error",
"code": "invalid_stream_url",
"message": "stream_url is required and must be a valid http(s)/rtsp URL.",
"param": "stream_url"
}
}| HTTP | type | Meaning |
|---|---|---|
| 400 | invalid_request_error | A parameter is missing or malformed. |
| 401 | authentication_error | Missing or invalid credentials. |
| 403 | authentication_error | Key revoked, partner suspended, or no shop has linked this credential. |
| 404 | invalid_request_error | The resource does not exist. |
| 409 | invalid_request_error | Idempotency conflict. |
| 429 | rate_limit_error | Too many requests. |
| 500 | api_error | Something went wrong on our end. |
7Idempotency
All write requests (POST, PATCH, DELETE) accept an Idempotency-Key header. Send a unique key per logical operation. If the same key is replayed with the same request body, you receive the original stored response (with an Idempotent-Replayed: true header) instead of the action happening twice. Re-using a key with a different body returns 409 idempotency_key_reuse.
external_ref: POSTing an existing external_ref updates that camera and returns 200 rather than creating a duplicate.8Rate limits
Sandbox keys are limited to 600 requests per minute. Every response includes X-RateLimit-Limit and X-RateLimit-Remaining. On 429 a Retry-After header tells you how many seconds to wait.
9Endpoints
Also the cheapest way to verify a site code a customer has just given you: the response echoes the tenant_id and site_code the request resolved to, and changes nothing.
Verifies your credentials and returns the resolved partner, environment, and tenant. No side effects.
Registers (or, for an existing external_ref, updates) a camera and makes it appear in the OS viewer.
| Field | Type | Required | Notes |
|---|---|---|---|
external_ref | string | yes | Your stable id. 1–160 chars: letters, digits, . _ : - |
name | string | yes | Display name shown to staff/clients. 1–200 chars. |
stream_url | string | yes | http(s) or rtsp URL of the feed. |
area_type | string | no | One of boarding, daycare, grooming, lobby, outdoor, custom. Default boarding. |
status | string | no | online, offline, or maintenance. Default online. |
{
"object": "response",
"data": {
"object": "camera",
"id": "pcam_18",
"external_ref": "kennel-7-cam",
"environment": "sandbox",
"name": "Kennel 7 — Suite View",
"area_type": "boarding",
"status": "online",
"online": true,
"stream_url": "https://cdn.abckam.com/streams/kennel-7.mjpg",
"tenant": { "id": 42, "environment": "sandbox" },
"os_camera_id": 91,
"os_viewer_url": "/api/cameras/91/viewer",
"created_at": "2026-01-15T10:31:00.000Z",
"updated_at": "2026-01-15T10:31:00.000Z"
}
}Lists your cameras for the current environment. Query params: limit (1–200, default 50) and offset.
Retrieves a single camera by your external_ref.
Updates any of name, stream_url, area_type, status. Only send the fields you want to change.
curl -X PATCH https://animalfriendsos.app/api/partner/v1/cameras/kennel-7-cam \
-H "X-AFOS-Key: $AFOS_KEY" -H "X-AFOS-Secret: $AFOS_SECRET" \
-H "Content-Type: application/json" \
-d '{ "name": "Kennel 7 — Deluxe Suite" }'Reports online/offline health (and optionally a fresh stream_url). Call this whenever a feed changes state. A change fires the camera.status_changed webhook.
curl -X POST https://animalfriendsos.app/api/partner/v1/cameras/kennel-7-cam/status \
-H "X-AFOS-Key: $AFOS_KEY" -H "X-AFOS-Secret: $AFOS_SECRET" \
-H "Content-Type: application/json" \
-d '{ "status": "offline" }'Removes a camera from the OS viewer. History (access logs, snapshots) is retained; the camera is deactivated, not purged.
10Webhooks
Register an HTTPS endpoint and we will POST a signed JSON event whenever one of your cameras changes. Events:
| Event | Fires when |
|---|---|
camera.registered | A new camera is registered. |
camera.updated | A camera's details change. |
camera.status_changed | A camera goes online/offline/maintenance. |
camera.deleted | A camera is removed. |
Verifying signatures
Each delivery carries an X-AFOS-Signature header of the form t=<timestamp>,v1=<hex>. Compute HMAC-SHA256(signing_secret, "<timestamp>.<raw_body>") and compare in constant time.
const crypto = require('crypto'); function verify(rawBody, header, secret) { const parts = Object.fromEntries(header.split(',').map(p => p.split('='))); const expected = crypto.createHmac('sha256', secret) .update(parts.t + '.' + rawBody).digest('hex'); return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1)); }
Body: url (required) and an optional events array (defaults to all). The response includes a signing_secret shown once — store it.
curl -X POST https://animalfriendsos.app/api/partner/v1/webhooks \
-H "X-AFOS-Key: $AFOS_KEY" -H "X-AFOS-Secret: $AFOS_SECRET" \
-H "Content-Type: application/json" \
-d '{ "url": "https://hooks.abckam.com/afos", "events": ["camera.status_changed"] }'List your webhooks (secrets are never returned again) or delete one by id.
11Error codes
| code | HTTP | Meaning |
|---|---|---|
missing_credentials | 401 | No key/secret supplied. |
invalid_credentials | 401 | Key/secret invalid or mismatched environment. |
key_revoked | 403 | The API key has been revoked. |
partner_suspended | 403 | The partner account is suspended. |
no_tenant_link | 403 | No shop has connected these credentials yet. See Connecting a shop. |
unknown_site_code | 403 | The X-AFOS-Site value does not match an active link for these credentials — unknown, another partner's, or revoked. Ask the customer for their current code. |
site_code_required | 400 | More than one shop has connected you, so the request must name one with X-AFOS-Site. |
site_code_not_for_environment | 403 | A site code was sent with sandbox credentials. Sandbox always uses the sandbox tenant. |
sandbox_unavailable | 403 | No sandbox tenant is provisioned. |
invalid_external_ref | 400 | external_ref missing/malformed. |
invalid_name | 400 | name missing/too long. |
invalid_stream_url | 400 | stream_url missing/invalid. |
invalid_area_type | 400 | area_type not recognised. |
invalid_status | 400 | status not recognised. |
invalid_events / invalid_url | 400 | Webhook payload invalid. |
camera_not_found / webhook_not_found | 404 | Resource does not exist. |
idempotency_key_reuse | 409 | Key reused with a different body. |
request_in_progress | 409 | Same key still processing. |
rate_limit_exceeded | 429 | Slow down. |
internal_error | 500 | Server error. |
12Changelog
| Version | Date | Notes |
|---|---|---|
| v1.1 | 2026-08-24 | Live tenant linking. A shop connects a partner from Dashboard › Cameras and issues a site code; send it as X-AFOS-Site. New errors: no_tenant_link, unknown_site_code, site_code_required, site_code_not_for_environment. external_ref is now scoped per shop. No change to sandbox behaviour or to any request body. |
| v1.0 | 2026-08-17 | Initial release: camera CRUD, status reporting, webhooks, idempotency, sandbox environment. |
13Support
Questions, live-key provisioning, or a bug? Email [email protected]. Include your public key_id (never your secret) and a request timestamp so we can find it in the audit log.
Base URL https://animalfriendsos.app · This reference: /partners/cameras/docs