Asynchronous Tasks
Beyond reading data, the API can execute tasks on devices. Because tasks take time to complete on
physical devices, they run asynchronously. You execute a task, get a taskId back immediately, and
poll for completion.
A single task runs across one or more devices. The work on each individual device is a device task, and the overall task is done once every device task is completed.
This page describes the pattern. The per-task-type payload fields are documented in the API Reference.
POST /v1/tasks requires Admin or Operator permissions. To enable it for your account, please
contact our support team.
The lifecycle
-
Execute the task
Send
POST /v1/taskswith ataskTypeand the devices to run it on. For tasks that require configuration, usedefaultPayloadto apply the same configuration to every device, or set apayloadper device.Code -
Take the task ID
The response returns the ID of the created task.
Code -
Poll until every device task is completed
GET /v1/tasks/{id}returns one entry per device task.Code
status tells you whether a device task has finished (pending, running, completed), and
result tells you how it finished (succeeded, failed, rolledBack, aborted). result is
null until the device task completes, so always check both.
Add includeSteps=true to GET /v1/tasks/{id} to include the per-step breakdown of each device
task. Steps increase the response size considerably, so they are not returned by default. Request
them only when a device task fails and further information is required to investigate it.
Check availability first
Not every device supports every task. Device objects expose an availableTask map, so check it
before executing:
Code
