API docs
Get started

Authentication

Apps and people use API keys. Sensors sign each request with their own secret. Ochio signs everything it sends you.

Three kinds of credentials

WhoCredentialHow it's sent
Apps, connected systems, people, the Claude MCP serverAPI key ochio_…Authorization: Bearer <key>
SensorsSensor secret ssk_…, one per sensorOchio-Timestamp and Ochio-Signature headers
Your webhook receiverWebhook secret whsec_…, one per subscriptionOchio signs each delivery; you check it

Ochio shows each key and secret once, when it's created. Keep them in your own secret store.

API keys

Send the key in the Authorization header of every request. A key carries scopes, and each endpoint names the scope it needs. A request whose key lacks it gets 403 missing_scope.

Scopes don't include each other, so give a key every scope it needs: even admin doesn't include read. Ochio creates two keys the first time it starts: operator, with every scope, and partner, for connected systems. An admin makes more with Create an API key.

ScopeLets the keyoperatorpartner
readRead everything but the API keys: every other GET, the live stream and the exportyesyes
alerts:writeSend alerts and check-ins for registered sensorsyesyes
sensors:writeRegister, remove and re-key sensorsyesno
missions:requestRequest missions; without missions:launch they wait for approvalyesyes
missions:launchLaunch missions without waiting for approvalyesno
missions:approveApprove, deny and cancel missions; dismiss alertsyesno
webhooks:writeManage webhook subscriptionsyesyes
adminManage API keys, see every key's webhooks, and use the sandbox controlsyesno

Calling the API with a key

GET/v1/status
AccessAPI key · read

Any endpoint works the same way. Here, the site's status.

Request
curl "$OCHIO_URL/v1/status" \
  -H "Authorization: Bearer $OCHIO_API_KEY"
Response
{
  "site": {
    "name": "Demo Depot",
    "center": {
      "lat": 38.5005,
      "lon": -98.0005
    },
    "operating_area_id": "depot"
  },
  "time": "2026-10-19T21:33:02.753Z",
  "version": "1.0.0",
  "counts": {
    "alerts_open": 0,
    "alerts_responding": 0,
    "missions_active": 0,
    "missions_pending_approval": 0,
    "sensors_online": 3,
    "sensors_silent": 0,
    "sensors_pending": 0,
    "vehicles_ready": 2,
    "vehicles_flying": 0
  }
}

Signing sensor requests

Sensors don't use API keys. Each sensor gets its own secret when it's registered, and signs every request it sends with it:

  1. Take the current Unix time in whole seconds as the timestamp.
  2. Compute HMAC-SHA256 over the timestamp, a dot, and the raw body bytes, keyed with the secret.
  3. Send Ochio-Timestamp: <timestamp> and Ochio-Signature: v1=<hex digest>.

Ochio checks the signature over the exact bytes it receives, so sign the body you send, not a copy you format again. It refuses a timestamp more than 300 seconds away from its clock, so keep the sensor's clock set.

A repeat of a request Ochio has already received, with the same timestamp and body, is answered but changes nothing: a check-in answers "repeat": true, an alert answers duplicate. A captured check-in can't keep a dead sensor alive, so sign each new request with a fresh timestamp.

Two endpoints take sensor signatures: Check in and Send an alert. Both also take an API key with alerts:write, for systems that speak for many sensors.

Sign and send an alert
BODY='{"id":"pir02-000412","source":"east-gate-pir-02","type":"motion","priority":"high"}'
TS=$(date +%s)
SIG=$(printf '%s.%s' "$TS" "$BODY" | openssl dgst -sha256 -hmac "$SENSOR_SECRET" | awk '{print $NF}')

curl -X POST "$OCHIO_URL/v1/alerts" \
  -H "Content-Type: application/json" \
  -H "Ochio-Timestamp: $TS" \
  -H "Ochio-Signature: v1=$SIG" \
  -d "$BODY"
Response
{
  "error": {
    "code": "invalid_signature",
    "message": "The signature does not match the body. Nothing was recorded."
  }
}

Checking Ochio's signature

Ochio signs every webhook delivery the same way, with the subscription's whsec_ secret. Before you trust a delivery:

  1. Read the raw body, before any JSON parsing.
  2. Compute HMAC-SHA256 over Ochio-Timestamp, a dot, and the raw body, keyed with your secret.
  3. Compare it with the hex after v1= in Ochio-Signature, in constant time.
  4. Refuse it if the timestamp is more than 300 seconds from your clock.

Then answer with any 2xx status within 5 seconds, and do the slow work afterwards. How deliveries work covers retries and ordering.

Check a delivery
import hashlib, hmac, time

def verify(secret: str, body: bytes, timestamp: str, signature: str) -> bool:
    """True when the delivery came from Ochio and is less than 5 minutes old."""
    if abs(time.time() - int(timestamp)) > 300:
        return False
    expected = hmac.new(secret.encode(), f"{timestamp}.".encode() + body, hashlib.sha256).hexdigest()
    given = [p.strip()[3:] for p in signature.split(",") if p.strip().startswith("v1=")]
    return any(hmac.compare_digest(expected, g) for g in given)

# in your handler:
# ok = verify(WEBHOOK_SECRET, request.get_data(),
#             request.headers["Ochio-Timestamp"], request.headers["Ochio-Signature"])

The sandbox's test mode

The sandbox starts in test mode, so you can try requests without a key. In test mode, a request made on the same computer, from a terminal, a script or the sandbox's own pages, acts as the operator key.

Web pages from other sites, requests from other machines, and anything sent to another host name still need a key. Turn test mode off whenever other machines can reach Ochio: start it with --no-dev, or set OCHIO_DEV_MODE=0.

Tip

Send a key anyway while you build. Your code then works unchanged against a real Ochio server, where test mode is off.

When authentication fails

StatusCodeWhat happened
401unauthorizedNo key was sent, or the Authorization header isn't Bearer <key>.
401invalid_keyThe key isn't one Ochio knows. It may have been revoked.
401missing_signatureOnly one of Ochio-Timestamp and Ochio-Signature was sent.
401invalid_signatureThe signature doesn't match the body, or isn't in the v1=<hex> form. Nothing was recorded.
401timestamp_out_of_rangeThe timestamp is more than 300 seconds away from Ochio's clock.
403missing_scopeThe key is valid but lacks the scope this endpoint needs. On most endpoints details.required_scope names it.
404unknown_sensorA signed request, or any alert, names a sensor that isn't registered.