Skip to main content

Commands

Send commands to devices. Commands are published to MQTT and their status is tracked.

Send Command

none
POST /devices/:id/commands
Send a command to a device.

Request Body

command
string
required
Command name (e.g., lock, unlock, reboot)
device_type
string
Device type. Defaults to the device’s configured type.
params
object
Command parameters

Available Commands

For iotee_device:
CommandDescriptionMQTT Payload
lockLock the device1
unlockUnlock the device0
rebootReboot the device1
curl -X POST https://api.example.com/devices/ABC123/commands \
  -H "X-API-Key: your-key" \
  -H "Content-Type: application/json" \
  -d '{"command": "lock"}'
{
  "command_id": "x1y2z3w4",
  "hardware_id": "ABC123",
  "device_id": "a1b2c3d4",
  "device_type": "iotee_device",
  "topic": "iotee/dev/ABC123/rls",
  "command": "lock",
  "status": "pending",
  "created_at": "2025-12-17T10:30:00.000Z"
}

Command Status Values

StatusDescription
pendingCreated, not yet published
publishedSent to MQTT broker
failedFailed to publish
acknowledgedDevice acknowledged
completedCommand executed
timeoutNo response

Get Device Commands

none
GET /devices/:id/commands
Get command history for a device.

Query Parameters

limit
number
default:"100"
Maximum records to return
curl -H "X-API-Key: your-key" https://api.example.com/devices/ABC123/commands

List All Commands

none
GET /commands
List all commands across all devices. Admin only 🔐

Query Parameters

limit
number
default:"100"
Maximum records to return
curl -H "X-API-Key: your-admin-key" https://api.example.com/commands

Get Command

none
GET /commands/:id
Get a command by ID.
curl -H "X-API-Key: your-key" https://api.example.com/commands/x1y2z3w4
Errors: 404 if command not found

Delete Command

none
DELETE /commands/:id
Delete a command. Admin only 🔐
curl -X DELETE -H "X-API-Key: your-admin-key" \
  https://api.example.com/commands/x1y2z3w4
{
  "success": true,
  "deleted": "x1y2z3w4"
}

Retry Command

none
POST /commands/:id/retry
Retry a failed command. Admin only 🔐
curl -X POST -H "X-API-Key: your-admin-key" \
  https://api.example.com/commands/x1y2z3w4/retry
{
  "success": true,
  "original_command_id": "x1y2z3w4",
  "new_command": {
    "command_id": "a9b8c7d6",
    "status": "pending"
  }
}

Purge Old Commands

none
POST /commands/purge
Delete commands older than specified days. Admin only 🔐

Request Body

older_than_days
number
required
Delete commands older than this many days
curl -X POST https://api.example.com/commands/purge \
  -H "X-API-Key: your-admin-key" \
  -H "Content-Type: application/json" \
  -d '{"older_than_days": 90}'
{
  "success": true,
  "cutoff_date": "2025-09-18T00:00:00.000Z",
  "deleted": 500
}