Skip to main content

Commands

Send one-way commands to devices from your app. Commands are durably delivered — if a device is offline, the command will be delivered when it reconnects.

Access via app.command.

Command queue

Commands can be queued per command name. The number of commands you can queue depends on your plan.

API

send()

Send a command to one or more devices.

await app.command.send(params)
ParameterTypeDescription
namestringThe command name
device_identstring[]One or more device identifiers to send the command to
dataanyThe command payload

Returns an object keyed by device identifier with the send result for each

const result = await app.command.send({
name: "reboot",
device_ident: ["sensor_01", "sensor_02"],
data: { force: false },
});

Example response:

{
"sensor_01": { "sent": true },
"sensor_02": { "sent": true }
}

If a device identifier doesn't exist, the response will include an error for that device:

{
"sensor_01": { "sent": true },
"sensor_99": { "sent": false, "error": "Device not found" }
}

history()

Query the history of commands sent to devices.

await app.command.history(params)
ParameterTypeDescription
namestringThe command name
device_identsstring[]Device identifiers to query
startstringStart time (ISO 8601)
endstring(optional) End time (ISO 8601). Defaults to now

Returns an object keyed by device identifier, each containing an array of command records

const history = await app.command.history({
name: "reboot",
device_idents: ["sensor_01"],
start: "2026-03-01T00:00:00.000Z",
end: "2026-03-02T00:00:00.000Z",
});

history["sensor_01"].forEach((record) => {
console.log(`${JSON.stringify(record.value)} at ${record.timestamp}`);
});

Example response:

{
"sensor_01": [
{
"value": { "force": false },
"timestamp": 1774690309495
},
{
"value": { "reason": "firmware update", "delay_seconds": 5 },
"timestamp": 1774691371229
}
],
"sensor_02": [
{
"value": { "force": false },
"timestamp": 1774861743990
}
]
}

Each device identifier is its own key in the response. Each record contains the command value (the payload that was sent) and the timestamp in milliseconds.

If a device has no command history in the queried range, the array will be empty:

{
"sensor_01": []
}
History retention

History retention depends on your plan. For example, the free plan retains 3 days of history. Queries outside your retention window will return empty arrays.