API docs
API reference

Sensors

A sensor is anything that raises alerts and checks in: a motion sensor, a door contact, a camera, a radar. One that goes quiet is treated as an event, because a cut or jammed sensor is a warning in itself.

The sensor object

Ochio keeps one record per sensor. It works out the zone from the location, and the status from the check-ins.

Attributes
idstring
The sensor's id: letters, digits, ., _ and -, up to 64 characters.
namestring
A name people read.
typestring
What it is, in your words: motion, door, camera, radar.
locationobject
Where it is: {"lat", "lon"}.
zone_idstringor null
The zone it sits in, worked out from its location. null outside the operating area.
checkin_interval_snumber
How often it checks in, in seconds.
missed_checkins_allowedinteger
How many check-ins it may miss before it counts as silent.
statusstring
pending, online or silent. See statuses.
last_seenstringor null
When it last checked in or sent an alert.
expires_atstringor null
When it turns silent if nothing arrives first.
battery_pctnumberor null
The battery level from its last check-in, if it sent one.
reported_statusstringor null
The health word from its last check-in, like ok or degraded.
simulatedboolean
true for the sandbox's simulated sensors.
originstring
How it was added: api, site (part of the site's setup) or replay.
created_atstring
When it was registered.
updated_atstring
When it last changed.
The sensor object
{
  "id": "east-gate-pir-02",
  "name": "East gate motion sensor 2",
  "type": "motion",
  "location": {
    "lat": 38.5005,
    "lon": -97.995
  },
  "zone_id": "east-gate",
  "checkin_interval_s": 10.0,
  "missed_checkins_allowed": 2,
  "status": "online",
  "last_seen": "2026-10-19T21:33:03.876Z",
  "expires_at": "2026-10-19T21:33:23.876Z",
  "battery_pct": 87.0,
  "reported_status": "ok",
  "simulated": false,
  "origin": "api",
  "created_at": "2026-10-19T21:33:02.764Z",
  "updated_at": "2026-10-19T21:33:03.876Z"
}

Check-ins and statuses

A sensor proves it's alive by checking in every checkin_interval_s seconds. Any alert it sends counts too. Each check-in moves expires_at to now plus checkin_interval_s × missed_checkins_allowed. With the defaults, 10 seconds and 2, a sensor turns silent 20 seconds after Ochio last heard from it.

StatusMeansEvent when it starts
pendingRegistered, but hasn't checked in yet. Not watched until it does.sensor.registered
onlineChecking in on time.sensor.online the first time, sensor.recovered after a silence
silentMissed its check-ins. A rule can send a drone to it.sensor.silent

A silent sensor stays silent until it checks in again. Mission Control and your systems hear about each change through events.

A silent sensor
{
  "id": "generator-yard-door-01",
  "name": "Generator yard door",
  "type": "door",
  "location": {
    "lat": 38.4979,
    "lon": -98.0047
  },
  "zone_id": "generator-yard",
  "checkin_interval_s": 10.0,
  "missed_checkins_allowed": 2,
  "status": "silent",
  "last_seen": "2026-10-19T21:39:43.634Z",
  "expires_at": "2026-10-19T21:40:03.634Z",
  "battery_pct": null,
  "reported_status": null,
  "simulated": true,
  "origin": "site",
  "created_at": "2026-10-19T21:30:10.072Z",
  "updated_at": "2026-10-19T21:40:03.755Z"
}

Register a sensor

POST/v1/sensors
AccessAPI key · sensors:write

Adds a sensor and gives it its secret. The answer is the only time Ochio shows the secret: give it to the sensor, which signs its requests with it.

Body
idstringrequired
Your id for it, unique on the site: letters, digits, ., _ and -, up to 64 characters, starting with a letter or digit.
namestringrequired
A name people read, up to 120 characters.
typestring
What it is, in your words. Default motion.
locationobjectrequired
Where it is.
latnumberrequired
Latitude in decimal degrees, -90 to 90.
lonnumberrequired
Longitude in decimal degrees, -180 to 180.
checkin_interval_snumber
How often it will check in, 1 to 86,400 seconds. Default 10.
missed_checkins_allowedinteger
Check-ins it may miss before it's silent, 1 to 100. Default 2.
Returns

201 with the sensor and its secret. The sensor starts pending, and a sensor.registered event goes out.

Errors
StatusCodeWhen
409sensor_existsA sensor with this id exists. To give it a new secret, rotate it instead.
400invalid_requestA field is missing or out of range.
Request
curl -X POST "$OCHIO_URL/v1/sensors" \
  -H "Authorization: Bearer $OCHIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "id": "east-gate-pir-02",
    "name": "East gate motion sensor 2",
    "type": "motion",
    "location": {
      "lat": 38.5005,
      "lon": -97.995
    },
    "checkin_interval_s": 10,
    "missed_checkins_allowed": 2
  }'
Response
{
  "id": "east-gate-pir-02",
  "name": "East gate motion sensor 2",
  "type": "motion",
  "location": {
    "lat": 38.5005,
    "lon": -97.995
  },
  "zone_id": "east-gate",
  "checkin_interval_s": 10.0,
  "missed_checkins_allowed": 2,
  "status": "pending",
  "last_seen": null,
  "expires_at": null,
  "battery_pct": null,
  "reported_status": null,
  "simulated": false,
  "origin": "api",
  "created_at": "2026-10-19T21:33:02.764Z",
  "updated_at": "2026-10-19T21:33:02.764Z",
  "secret": "ssk_test_example_secret_000000000001"
}

Check in

POST/v1/sensors/{sensor_id}/heartbeat
AccessSensor signatureorAPI key · alerts:write

The sensor's regular sign of life, signed with its secret. Send it every checkin_interval_s seconds. An alert from the sensor counts as a check-in too.

Path
sensor_idstringrequired
The sensor's id.
Headers
Ochio-Timestampstring
Unix time in whole seconds when the request was signed. Needed when a sensor signs the request.
Ochio-Signaturestring
v1= and the hex HMAC-SHA256 of the timestamp, a dot and the raw body, keyed with the sensor's secret. See Signing sensor requests.
Body

The body is optional. Send {} or nothing if the sensor has nothing to report.

battery_pctnumber
The sensor's battery level, 0 to 100.
statusstring
The sensor's own health word, up to 32 characters: ok, degraded.
Returns

200 with the sensor's status, next_checkin_by (when the next one is due) and expires_at (when it turns silent without one). A repeat of a request Ochio already counted answers "repeat": true and doesn't count again.

Errors
StatusCodeWhen
401invalid_signatureThe signature doesn't match. See Signing.
404unknown_sensorA signed check-in for a sensor that isn't registered.
404not_foundThe same, sent with an API key.
Request
BODY='{"battery_pct":87,"status":"ok"}'
TS=$(date +%s)
SIG=$(printf '%s.%s' "$TS" "$BODY" | openssl dgst -sha256 -hmac "$SENSOR_SECRET" | awk '{print $NF}')

curl -X POST "$OCHIO_URL/v1/sensors/east-gate-pir-02/heartbeat" \
  -H "Content-Type: application/json" \
  -H "Ochio-Timestamp: $TS" \
  -H "Ochio-Signature: v1=$SIG" \
  -d "$BODY"
Response
{
  "sensor_id": "east-gate-pir-02",
  "status": "online",
  "next_checkin_by": "2026-10-19T21:33:12.770Z",
  "expires_at": "2026-10-19T21:33:22.770Z"
}

List sensors

GET/v1/sensors
AccessAPI key · read

Every registered sensor, with its status.

Query
statusstring
Only sensors in this status: pending, online or silent.
Returns

{"data": [...]} with a sensor for each.

Request
curl "$OCHIO_URL/v1/sensors?status=silent" \
  -H "Authorization: Bearer $OCHIO_API_KEY"
Response
{
  "data": [
    {
      "id": "generator-yard-door-01",
      "name": "Generator yard door",
      "type": "door",
      "location": {
        "lat": 38.4979,
        "lon": -98.0047
      },
      "zone_id": "generator-yard",
      "checkin_interval_s": 10.0,
      "missed_checkins_allowed": 2,
      "status": "silent",
      "last_seen": "2026-10-19T21:39:43.634Z",
      "expires_at": "2026-10-19T21:40:03.634Z",
      "battery_pct": null,
      "reported_status": null,
      "simulated": true,
      "origin": "site",
      "created_at": "2026-10-19T21:30:10.072Z",
      "updated_at": "2026-10-19T21:40:03.755Z"
    }
  ]
}

Get a sensor

GET/v1/sensors/{sensor_id}
AccessAPI key · read

One sensor, by id.

Path
sensor_idstringrequired
The sensor's id.
Returns

The sensor.

Errors
StatusCodeWhen
404not_foundNo sensor with this id.
Request
curl "$OCHIO_URL/v1/sensors/east-gate-pir-02" \
  -H "Authorization: Bearer $OCHIO_API_KEY"
Response
{
  "id": "east-gate-pir-02",
  "name": "East gate motion sensor 2",
  "type": "motion",
  "location": {
    "lat": 38.5005,
    "lon": -97.995
  },
  "zone_id": "east-gate",
  "checkin_interval_s": 10.0,
  "missed_checkins_allowed": 2,
  "status": "online",
  "last_seen": "2026-10-19T21:33:03.876Z",
  "expires_at": "2026-10-19T21:33:23.876Z",
  "battery_pct": 87.0,
  "reported_status": "ok",
  "simulated": false,
  "origin": "api",
  "created_at": "2026-10-19T21:33:02.764Z",
  "updated_at": "2026-10-19T21:33:03.876Z"
}

Rotate a sensor's secret

POST/v1/sensors/{sensor_id}/rotate-secret
AccessAPI key · sensors:write

Gives the sensor a new secret. The old one stops working at once, so update the sensor right after. Use it when a secret may have leaked, or when you replace the device.

Path
sensor_idstringrequired
The sensor's id.
Returns

200 with sensor_id and the new secret, shown once.

Errors
StatusCodeWhen
404not_foundNo sensor with this id.
Request
curl -X POST "$OCHIO_URL/v1/sensors/east-gate-pir-02/rotate-secret" \
  -H "Authorization: Bearer $OCHIO_API_KEY"
Response
{
  "sensor_id": "east-gate-pir-02",
  "secret": "ssk_test_example_secret_000000000002"
}

Remove a sensor

DELETE/v1/sensors/{sensor_id}
AccessAPI key · sensors:write

Removes the sensor. Its alerts stay, and its secret stops working. A sensor.removed event goes out.

Path
sensor_idstringrequired
The sensor's id.
Returns

200 with {"id", "deleted": true}.

Errors
StatusCodeWhen
404not_foundNo sensor with this id.
Request
curl -X DELETE "$OCHIO_URL/v1/sensors/east-gate-pir-02" \
  -H "Authorization: Bearer $OCHIO_API_KEY"
Response
{
  "id": "east-gate-pir-02",
  "deleted": true
}