Public API

Read-only JSON for external systems, plus controller maintenance endpoints for automation such as Ansible.


Every request must send the header X-API-Key with the value of PUBLIC_API_KEY from the server .env. Without it the API returns 401.

Endpoints

  • GET /api/v1/devices and /api/v1/devices/:id: devices and their current status.
  • GET /api/v1/devices/:id/metrics: metric history for one device.
  • GET /api/v1/alerts/active: currently firing alerts.
  • GET /api/v1/availability?from=&to=&groupBy=device|controller|type|site&target=99.9: availability, with an optional SLA target.
  • GET /api/v1/controllers: controllers and their IDs.
  • GET /api/v1/controllers/:id/maintenance: whether a window is open for the controller.
  • POST /api/v1/controllers/:id/maintenance/start: opens a window for all devices of the controller. Idempotent.
  • POST /api/v1/controllers/:id/maintenance/stop: closes the open windows. Idempotent.

Maintenance around an update

# Before the update
curl -X POST -H "X-API-Key: $CS_KEY" https://cobrasense.cobrasystems.nl/api/v1/controllers/$ID/maintenance/start
# ... run the update ...
# After the update
curl -X POST -H "X-API-Key: $CS_KEY" https://cobrasense.cobrasystems.nl/api/v1/controllers/$ID/maintenance/stop