Commands API
Commands API provides HTTP API for the end user to run commands.
Execute Command
POST /commands/v1/execute
Cause execution of a specified command.
Request
$ curl 'http://enapter-gateway.local/api/commands/v1/execute?show_progress=true' -X POST \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}' \
-d '{
"device_id": "123e4567-e89b-12d3-a456-426614174000",
"command_name": "ping",
"arguments": {"count": 5}
}'
Path Parameters
show_progress
boolean#Enable command in-progress responses streaming.
Body Parameters
device_id
stringrequired#Device ID.
command_name
stringrequired#Command name, same as specified in the blueprint manifest for this device.
arguments
object#Command arguments according to arguments specified in the blueprint manifest for this device. This is an object whose keys and values are arguments' names and values respectively.
Request body must be a valid JSON object.
Response
If streaming is disabled, response is a single valid JSON object with a terminal state or array of errors:
state
string#Command execution state (see below). Included only if command was executed or is currently being executed.
payload
object#Payload depends on
state
(see below). Included only if command is taken for execution.
errors
array#If error occurred before running the command, response contains an array of errors. See common error format for more details.
{
"state": "succeeded",
"payload": {
"value": 112.3
}
}
{
"errors": [...]
}
If streaming is enabled, successful response will set Transfer-Encoding
header to chunked
and return a stream of individual JSON payloads:
{"state": "started"}
{"state": "device_in_progress", "payload": {"state": "downloading"}}
{"state": "succeeded", "payload": {"value": 112.3}}
Terminal states:
succeeded
: device replied with successful completion state.error
: device replied with an error state, payload contains unchanged fields from payload reported by device.platform_error
: internal error happened during command execution, payload contains code, message and any additional code-specific fields.
Transitional states:
started
: command request is processed and taken for execution.device_in_progress
: device replied with any non-terminal state, payload contains unchanged state and payload reported by device.