Documentation / API

API overview

Base URLs, authentication (session cookie for the web UI, personal tokens for scripts, device tokens for ingestion), roles, error format, dates and pagination conventions shared by every endpoint.

Base URLs

Surface Base URL Used by
REST API https://apiv1.opensensorcloud.com/api/v1 the web UI, your scripts
HTTP ingestion https://apiv1.opensensorcloud.com/ingest/v1 devices (device token)
Network callbacks https://apiv1.opensensorcloud.com/ingest/v1/lorawan/…, …/sigfox/… TTN, ChirpStack, the Sigfox backend (integration secret)
Gateway configuration https://apiv1.opensensorcloud.com/gateway/v1/config the on-site Modbus / OPC-UA gateway
MQTT mqtts://mqtt.opensensorcloud.com:8883 devices (device id + token)

On a self-hosted instance, replace the host names with yours. The exact ingestion URL and MQTT host of an instance are returned when a device token is issued (ingestUrl, mqtt.host, mqtt.port, mqtt.tlsPort).

Each service also answers GET /healthz with {"ok": true}.

Authentication

The REST API authenticates users with an httpOnly session cookie named osc_session, set by POST /auth/login or POST /auth/register and valid for 30 days. Send it back on every request (credentials: 'include' in a browser, a cookie jar with curl -c/-b).

curl -c jar.txt -H 'Content-Type: application/json' \
  -d '{"email":"me@example.com","password":"…"}' \
  https://apiv1.opensensorcloud.com/api/v1/auth/login
curl -b jar.txt https://apiv1.opensensorcloud.com/api/v1/orgs

Cross-origin calls are only accepted from the web UI's own origin (CORS with credentials). For scripts and AI assistants, prefer a personal token (below).

Authenticating with a personal token

Create a personal API token in My account → Personal API tokens: give it a name, pick one organization and a role, viewer or editor, no higher than yours there (viewer is enough to read; no token can be admin or owner, so members and organization settings are never managed by token), and optionally an expiry date. The token (osc_pat_…) is shown once; only its hash is stored. Send it as a bearer token:

curl -H "Authorization: Bearer osc_pat_…" \
  https://apiv1.opensensorcloud.com/api/v1/orgs/<orgId>/devices

A request with a token acts as you, but only within the token's organization and with the token's role (or your current role there, if lower):

  • the organization routes /orgs/{orgId}/… of that organization, and GET /orgs (which then lists only that organization);
  • another organization answers 404 not_found, as for a non-member;
  • account routes (/auth/*, token management included), instance administration (/admin/*), invitations, organization creation, the real-time WebSocket and the assistant (/orgs/{orgId}/ai/*) answer 403 token_not_allowed;
  • an unknown, revoked or expired token answers 401 unauthorized.

Tokens are managed with a session cookie only: GET /auth/tokens (name, organization, role, last 4 characters, creation, expiry and last use; never the token), POST /auth/tokens with { "name", "organizationId", "role", "expiresAt"? } → 201 { "token": {…}, "secret": "osc_pat_…" } (403 role_not_allowed_for_token for owner or admin, 403 role_above_membership above your role, 404 if you are not a member, 400 expiry_in_past), and DELETE /auth/tokens/{id} → 204. Creation and revocation appear in the organization's audit log (api_token.create, api_token.revoke). The last use is recorded to the minute.

Device tokens (ingestion)

A device sends measurements with its own token (osc_dev_…), issued once when the device is created or its token regenerated:

  • HTTP: Authorization: Bearer osc_dev_…;
  • MQTT: username = device id, password = token.

A device token only allows publishing for that device. It gives no access to the REST API.

Integration secrets (network callbacks)

LoRaWAN and Sigfox callbacks carry the integration secret in the x-osc-secret header. See Integrations.

Organizations and roles

Almost every resource lives under /orgs/{orgId}/…. The caller's role in that organization decides what is allowed:

Role Allowed
viewer every GET of the organization
editor + create, update and delete devices, profiles, dashboards, alert rules; acknowledge alerts; gateway configuration
admin + members and invitations, integrations, notification channels, MQTT topics of devices and profiles, organization settings, audit log
owner + delete the organization

A non-member gets 404 (the organization's existence is not revealed); a member without the required role gets 403.

Requests and responses

  • Bodies are JSON (Content-Type: application/json). Unknown fields are ignored, except where a schema is strict (stated on the endpoint).
  • Dates are ISO 8601 strings in UTC (2026-11-13T09:24:56.936Z). Query parameters from / to accept anything JavaScript's Date parses; ISO 8601 is recommended.
  • Identifiers are UUIDs.
  • Successful creations return 201 with the created object; deletions and actions without a result return 204 with no body.

Errors

Errors are JSON with a stable machine-readable code:

{ "error": "slug_taken" }

A validation error (400) also lists the problems found, in the zod issue format:

{
  "error": "validation",
  "issues": [
    { "code": "too_small", "minimum": 10, "path": ["password"], "message": "String must contain at least 10 character(s)" }
  ]
}
Status Meaning Example codes
400 invalid input validation, invalid_hex, confirmation_mismatch, invalid_device_param
401 not signed in, or wrong credentials unauthorized, invalid_credentials
403 role too low forbidden, mqtt_topic_admin_only, admin_only
404 unknown resource, or not a member not_found
409 conflict with existing data email_taken, slug_taken, dev_eui_taken, mqtt_topic_taken
413 payload too large payload_too_large, too_many_points
429 rate limit or quota too_many_attempts, rate_limited, quota_exceeded
500 unexpected server error internal

Ingestion endpoints add a human-readable detail string next to error (see Ingestion).

Pagination

Lists are small by design and returned whole: devices, dashboards, profiles, rules, members… The exceptions:

  • the audit log is paginated by cursor: 50 entries per page, newest first; pass the id of the last entry as ?before= to get the next page (see Auth & organizations);
  • raw telemetry returns at most 10,000 points per request; longer periods are aggregated automatically (see Telemetry);
  • the CSV export streams up to 1,000,000 rows.

Limits

Limit Default
devices per organization 1,000
organizations owned per account 10
messages per device 3,000 per minute on average (bursts tolerated)
messages per organization 100,000 per UTC day (an instance administrator may change it per organization)
points per ingestion message 1,000
HTTP ingestion body 1 MiB (1 MiB decompressed for gzip)

Self-hosted instances can change these values.