Documentation / API

Ingestion

Send measurements over HTTP (JSON, batches, gzip, binary) or MQTT (topics, authentication, QoS, custom topics), and let an on-site gateway download its configuration.

Message format

The same body is accepted over HTTP and MQTT.

{ "temperature": 21.4, "humidity": 48, "door": false, "status": "ok" }
{ "ts": "2026-11-13T08:00:00Z", "values": { "temperature": 21.4 } }
[
  { "ts": "2026-11-13T08:00:00Z", "values": { "temperature": 21.4 } },
  { "ts": "2026-11-13T08:10:00Z", "values": { "temperature": 21.9, "humidity": 47 } }
]
  • Keys: ^[A-Za-z0-9_.-]{1,64}$, at most 100 per element. Each new key becomes a channel of the device.
  • Values: finite number, boolean, or text up to 1,024 characters. null means "no value for this key in this message" and is skipped; at least one value must be non-null.
  • ts: optional, ISO 8601 or anything Date parses; default = reception time. At most one hour in the future.
  • A message holds at most 1,000 points (keys × elements); beyond, it is rejected as a whole.
  • A message is ingested entirely or not at all.
  • With a profile timestampKey (e.g. date_time), flat objects carrying their own time are accepted: { "date_time": "2026-11-11T17:07:36.437Z", "hp": 10.7 }.
  • Any other JSON, or binary data, goes through the profile's decoder (see Profiles & decoders).

HTTP

POST https://apiv1.opensensorcloud.com/ingest/v1/telemetry

curl -X POST https://apiv1.opensensorcloud.com/ingest/v1/telemetry \
  -H "Authorization: Bearer osc_dev_…" \
  -H "Content-Type: application/json" \
  -d '{"temperature": 21.5, "humidity": 48}'
Content type Handling
application/json the format above, or the profile's decoder for another JSON shape
application/octet-stream raw bytes, passed to the profile's decoder
gzip (Content-Encoding: gzip, or a body starting with the gzip bytes 1f 8b) decompressed first (at most 1 MiB once decompressed), then as above
gzip -c batch.json | curl -X POST https://apiv1.opensensorcloud.com/ingest/v1/telemetry \
  -H "Authorization: Bearer osc_dev_…" -H "Content-Type: application/json" \
  -H "Content-Encoding: gzip" --data-binary @-

The request body is limited to 1 MiB.

Responses:

Status Body Meaning
202 { "accepted": 2 } number of points accepted
400 { "error": "validation", "detail": "(corps) : Invalid input" } invalid body; detail lists path : message for each problem ((corps) = the whole body)
401 { "error": "unauthorized" } missing or wrong token
413 { "error": "too_many_points", "detail": "1200 points, maximum 1000" } too many points
413 { "error": "payload_too_large", "detail": "…" } gzip body too large once decompressed
429 { "error": "rate_limited", "detail": "…" } + Retry-After: 1 device rate exceeded (3,000 messages per minute on average)
429 { "error": "quota_exceeded", "detail": "daily message quota reached (100000/day)" } + Retry-After: <seconds until midnight UTC> organization daily quota reached

A rate limit or quota counts one message per request, whatever its number of points: batching saves quota. Rejected messages are visible, with their reason, in the device's live debug view.

MQTT

Setting Value
Host mqtt.opensensorcloud.com (the mqtt.host returned with the token)
Ports 8883 MQTT over TLS (recommended); plaintext port as returned in mqtt.port, for trusted networks only; WebSocket over TLS at wss://apiv1.opensensorcloud.com/mqtt (to verify on the public instance)
Username the device id
Password the device token
Topic osc/<org slug>/<device id>/telemetry
QoS 0 and 1
mosquitto_pub -h mqtt.opensensorcloud.com -p 8883 --capath /etc/ssl/certs -q 1 \
  -u 8dec3c85-313d-4c4c-bb00-c8fad203200e -P osc_dev_… \
  -t osc/demo/8dec3c85-313d-4c4c-bb00-c8fad203200e/telemetry \
  -m '{"temperature": 21.5}'
  • The payload follows the message format above; binary and gzip payloads are accepted as over HTTP.
  • A device can only publish on its own topics and cannot subscribe to anything. A message published elsewhere is refused by the broker.
  • MQTT has no response: rejected messages (invalid, rate limit, quota) are dropped and shown in the live debug view.

Custom topics and topic templates

For equipment that imposes its own topics, a device may reserve up to 5 MQTT filters (mqttTopics, see Devices), and a gateway bound to a profile with a topicTemplate reserves the filter derived from its attributes (see Profiles). The equipment then publishes on those topics with the device's id and token:

  • standard JSON is accepted as is;
  • a bare value (45.2) becomes a channel named after the last topic level (…/relay/0/power → power);
  • anything else goes to the profile's decoder, which receives the topic in meta.topic.

With a template, each value of the free variables (e.g. {unit}) identifies a child device, created on its first message.

On-site gateway

A gateway device publishes its children's measurements on each child's own topic, osc/<org slug>/<child device id>/telemetry, with the gateway's credentials.

Gateway configuration

GET https://apiv1.opensensorcloud.com/gateway/v1/config

Called by the on-site Modbus / OPC-UA gateway with its own token (Authorization: Bearer osc_dev_…).

{
  "version": "3f2a…",
  "orgSlug": "demo",
  "gatewayId": "2e5de97a-8d20-477e-be9e-add38de17e3f",
  "config": { "pollSeconds": 10, "sources": [ … ] }
}

config is the configuration saved with PUT …/devices/{id}/gateway-config (see Devices). The response has an ETag; send it back in If-None-Match to get 304 Not Modified when nothing changed (the gateway polls and reloads hot). Errors: 401 (token), 403 not_a_gateway (the device is not of kind gateway).