Documentation / API
Profiles & decoders
Device profiles (declared channels, timestamp field, position options, MQTT topic template), the decoder template library and the decoder test endpoint.
All paths are relative to https://apiv1.opensensorcloud.com/api/v1.
Endpoints
| Method and path | Role | Result |
|---|---|---|
GET /orgs/{orgId}/profiles |
member | array of profiles, each with deviceCount |
POST /orgs/{orgId}/profiles |
editor | 201, the profile |
PUT /orgs/{orgId}/profiles/{profileId} |
editor | the profile (full replacement) |
DELETE /orgs/{orgId}/profiles/{profileId} |
editor | 204 |
GET /decoders/templates |
signed in | the decoder template library |
POST /orgs/{orgId}/decoders/test |
member | the decoder output for a sample payload |
GET /transforms/templates |
signed in | the transform templates and sandbox helpers |
POST /orgs/{orgId}/transforms/test |
editor | the transform result for sample values and a device |
Changing topicTemplate requires admin (403 mqtt_topic_admin_only).
The profile object
{
"name": "Greenhouse probe",
"channels": [
{ "key": "temperature", "label": "Temperature", "unit": "°C", "type": "number", "min": -10, "max": 50 },
{ "key": "door", "label": "Door open", "unit": "", "type": "bool", "min": null, "max": null }
],
"decoder": null,
"transform": null,
"timestampKey": null,
"topicTemplate": null,
"locationFromChannels": false,
"networkLocationFallback": false
}
| Field | Rules |
|---|---|
name |
1 to 100 characters |
channels |
up to 100, unique key (^[A-Za-z0-9_.-]{1,64}$); label up to 100, unit up to 20, type number (default) / bool / string, optional min / max (expected range) |
decoder |
JavaScript source up to 20,000 characters, or null |
transform |
derived channels script transform(values, ctx), up to 20,000 characters, or null (an empty string means null) |
timestampKey |
field of flat JSON messages that holds the measurement time (ISO 8601 or epoch milliseconds), removed from the values; or null |
topicTemplate |
MQTT template such as pv/{controller}/{unit}/output_data: at least one {variable} (a whole level), first level literal, no osc/ or $; or null. Cannot change while a gateway uses it (409 profile_template_in_use) |
locationFromChannels |
the latitude / longitude points of a message move the device, if newer than its last position |
networkLocationFallback |
the Sigfox network location places a device that has no GPS or manual position |
Responses add id and deviceCount.
Decoders
A decoder defines decode(bytes, fPort, meta):
bytes: the payload as an array of byte values;fPort: LoRaWAN port, ornull;meta:{ topic }for MQTT;{ seqNumber, station, rssi, snr, duplicate, computedLocation, time }for Sigfox.
It returns { key: value }, or [{ ts, values }] for a batch. It runs in an isolated sandbox: 50 ms CPU, 32 MB memory, no network or file access. Its output goes through the same validation as an ingested message.
GET /decoders/templates
[ { "id": "int16-temp-uint8-hum", "name": "Temperature (int16 / 100) + humidity (uint8)", "sample": "08 6A 30", "code": "function decode(bytes, fPort) { … }" } ]
Templates: int16-temp-uint8-hum, json-text, tasmota-json, batch-timestamp-field, hidnseek, hidnseek-mini.
POST /orgs/{orgId}/decoders/test
{ "decoder": "function decode(bytes) { return { temperature: ((bytes[0] << 8) | bytes[1]) / 100, humidity: bytes[2] }; }",
"payloadHex": "08 6A 30", "fPort": null }
payloadHex: hexadecimal, spaces allowed (400 invalid_hex otherwise). Success:
{ "ok": true, "output": { "temperature": 21.54, "humidity": 48 },
"points": [ { "ts": "2026-11-13T10:30:00.000Z", "key": "temperature", "value": 21.54 },
{ "ts": "2026-11-13T10:30:00.000Z", "key": "humidity", "value": 48 } ] }
Failure (200 as well): { "ok": false, "error": "…" }, e.g. a JavaScript error, a timeout, or output rejected by ingestion: ….
Transforms (derived channels)
A profile's transform defines transform(values, ctx) and returns extra channels for each message, after the decoder (or on canonical JSON). Contract, helpers and templates: user guide, Profiles. An error rejects the message (transform_error; ingest-http answers 400 { "error": "transform_error", "detail": "transform: …" }).
GET /transforms/templates
{ "templates": [ { "id": "dew-point", "name": "Dew point", "sample": "{ \"temperature\": 21.5, \"humidity\": 60 }", "code": "function transform(values, ctx) { … }" } ],
"helpers": [ { "name": "math.dewPointC(tempC, rh)", "doc": "dew point in °C (Magnus formula), rh in %" } ] }
Templates: geofence-attribute, dew-point, power-ui, moved.
POST /orgs/{orgId}/transforms/test
{ "transform": "function transform(v) { return { dewPoint: math.round(math.dewPointC(v.temperature, v.humidity), 1) }; }",
"values": { "temperature": 20, "humidity": 50 }, "deviceId": "0c7f2d1e-…", "protocol": "http", "meta": {} }
values: flat object of channel values (validated like an ingested message); deviceId (optional): a device of the organization whose attributes, position and last values make ctx (another organization's device gives an empty device); protocol (default http) and meta (default {}) as the ingestion would pass them. Success:
{ "ok": true, "extra": { "dewPoint": 9.3 },
"points": [ { "ts": "…", "key": "temperature", "value": 20 }, { "ts": "…", "key": "humidity", "value": 50 }, { "ts": "…", "key": "dewPoint", "value": 9.3 } ] }
extra: the channels added or changed (dropped ones as null); points: the message as the ingestion would publish it. Failure (200 as well): { "ok": false, "error": "…" }.