Documentation / API

Devices & tokens

Create, list, update and delete devices; issue and regenerate their ingestion token; set their profile, network identifiers, MQTT topics, position and attributes; configure an on-site gateway.

All paths are relative to https://apiv1.opensensorcloud.com/api/v1. Reading requires membership; writing requires the editor role, except MQTT topics (admin).

The device object

{
  "id": "8dec3c85-313d-4c4c-bb00-c8fad203200e",
  "name": "Greenhouse A",
  "description": "",
  "kind": "device",
  "gatewayId": null,
  "profileId": "9f10a175-69ef-4a3d-b39b-006705af34e7",
  "location": { "latitude": 45.764, "longitude": 4.8357, "source": "manual", "radiusM": null, "updatedAt": null },
  "lastSeenAt": "2026-11-13T09:24:57.059Z",
  "createdAt": "2026-11-13T09:24:56.956Z"
}
Field Meaning
kind device, or gateway (on-site Modbus / OPC-UA gateway, or MQTT controller / bridge)
gatewayId for a device created by a gateway or controller, that gateway's id
location null, or the position with its source: manual (typed), gps (decoded points), network (Sigfox, with radiusM precision in metres); updatedAt = time of the measurement that set it
lastSeenAt last accepted message; the UI shows a device as online below 5 minutes

List and read

GET /orgs/{orgId}/devices

All devices of the organization, sorted by name (array of device objects), each with profileName (name of its profile, null without one), devEui and sigfoxId (null when not set). With ?include=deleting, the devices being deleted are listed too, each device with deleting: true or false.

GET /orgs/{orgId}/devices/{deviceId}

The device plus its details and channels:

{
  "id": "8dec3c85-…", "name": "Greenhouse A", "kind": "device", "profileId": "9f10a175-…",
  "devEui": null, "sigfoxId": null, "mqttTopics": [], "attributes": { "site": "north" },
  "channels": [
    { "key": "temperature", "type": "number", "unit": "°C", "label": "Temperature", "min": -10, "max": 50,
      "declared": true, "lastTs": "2026-11-13T09:24:56.936Z", "lastValue": 25.5 },
    { "key": "door", "type": "bool", "unit": null, "label": "Door open", "min": null, "max": null,
      "declared": true, "lastTs": "2026-11-13T09:24:56.936Z", "lastValue": false }
  ]
}

channels merges the channels declared by the profile (declared: true, shown before any measurement) and those actually received. type is number, bool or string.

Create

POST /orgs/{orgId}/devices — editor

{ "name": "Greenhouse A", "kind": "device", "description": "" }

kind defaults to device. 201:

{
  "device": { "id": "8dec3c85-…", "name": "Greenhouse A", "kind": "device", "…": "…" },
  "token": "osc_dev_W1axHkMk6FxUcgDgoUeXxhS209oyZz8Seas-p2fceMo",
  "ingestUrl": "https://apiv1.opensensorcloud.com",
  "mqtt": {
    "host": "mqtt.opensensorcloud.com", "port": 1884, "tlsPort": 8883,
    "username": "8dec3c85-313d-4c4c-bb00-c8fad203200e",
    "topic": "osc/demo/8dec3c85-313d-4c4c-bb00-c8fad203200e/telemetry"
  }
}

The token is returned only here (and on regeneration): it is stored hashed. tlsPort is absent when the instance does not offer MQTT over TLS. Error: 403 device_quota_reached.

Token

POST /orgs/{orgId}/devices/{deviceId}/token — editor

Issues a new token and invalidates the previous one immediately. 200 with { token, ingestUrl, mqtt } as above.

Update

PATCH /orgs/{orgId}/devices/{deviceId} — editor

Only the given fields change.

{
  "name": "Greenhouse A",
  "description": "North site, row 3",
  "profileId": "9f10a175-…",
  "devEui": "70-B3-D5-7E-D0-00-12-34",
  "sigfoxId": "1A2B3C",
  "location": { "latitude": 45.764, "longitude": 4.8357 },
  "attributes": { "site": "north" },
  "mqttTopics": ["tele/plug-livingroom/#"]
}
Field Rules
profileId a profile of the organization, or null
devEui LoRaWAN devEUI, 16 hex characters (separators and case ignored), unique in the organization (409 dev_eui_taken), or null
sigfoxId 1 to 8 hex characters, stored lowercase without leading zeros, unique in the organization (409 sigfox_id_taken), or null
location both coordinates (latitude −90…90, longitude −180…180), or null to clear it (a network or GPS position may then place the device again)
attributes up to 20; keys ^[a-z][a-z0-9_]{0,31}$, values 1 to 64 characters without / + # $ or spaces. For a gateway bound to a profile with a topic template, they are the template variables
mqttTopics admin only (403 mqtt_topic_admin_only); up to 5 MQTT filters; see below

MQTT topic filters: + takes a whole level, # only last; the first level must be a literal name; $… and osc/… are reserved. A filter may not overlap any other device's filter on the whole instance (409 mqtt_topic_taken). For a controller (gateway with a topic-template profile): 400 template_needs_free_variable if every variable is set but one should stay free, 400 unknown_template_variable for an attribute that is not a template variable.

Returns 200 with the device object.

Delete

DELETE /orgs/{orgId}/devices/{deviceId} — editor

Deletes the device, its token, channels, measurements and raw messages. Asynchronous: answers 202 { "status": "deleting" } at once. From then on the device is gone for the API (404, absent from lists, dashboards and selectors, not counted in the device quota), its token is revoked and its devEUI, Sigfox ID and MQTT topics are released (they can be given to another device at once); ingestion refuses it. Its history is then removed in the background, which may take a few minutes for a long one. Deleting it again meanwhile answers 202 again; once it is gone, 404. The device.delete audit entry stays.

Measurements

See Telemetry for GET …/devices/{deviceId}/telemetry and GET …/devices/{deviceId}/export.csv.

Gateway configuration (Modbus / OPC-UA)

For a device of kind gateway running the on-site gateway.

GET /orgs/{orgId}/devices/{deviceId}/gateway-config

PUT /orgs/{orgId}/devices/{deviceId}/gateway-config — editor

{
  "pollSeconds": 10,
  "sources": [
    {
      "id": "plc1", "name": "PLC", "deviceId": "93fae36f-…", "protocol": "modbus",
      "transport": { "type": "tcp", "host": "192.168.1.20", "port": 502 },
      "unitId": 1,
      "registers": [
        { "key": "pressure", "address": 0, "kind": "holding", "format": "float32", "wordOrder": "big", "scale": 1, "offset": 0 }
      ]
    },
    {
      "id": "opc1", "name": "OPC-UA server", "deviceId": "6557e8f4-…", "protocol": "opcua",
      "endpoint": "opc.tcp://192.168.1.30:4840",
      "nodes": [ { "key": "speed", "nodeId": "ns=2;s=Line1.Speed" } ]
    }
  ]
}
  • pollSeconds: 1 to 3600. Up to 100 sources, each publishing to the child device deviceId.
  • Modbus transport: tcp (host, port 502) or rtu (path of the serial port, baudRate 9600, parity none / even / odd). Registers: 0-based address, kind holding / input / coil / discrete, format int16 / uint16 / int32 / uint32 / float32 / bool, wordOrder for 32-bit formats, then value × scale + offset.
  • OPC-UA: security mode "None" only, optional username / password.

The gateway downloads its configuration from the ingestion service, see Ingestion.