Task creation
HTTP Request URL: http(s)://api.thingboot.com/{AppID}/task/create/?sign={sign}&ts={ts}
About the sign and ts definition
Or
MQTT Publish Topic: api/{AppID}/task/create
The returned results are also received on the same topic.
Request parameters
Accept POST and JSON methods
| Name | Required | Type | Description |
|---|---|---|---|
| devices | Yes | string | The ID list of devices, groups, or tags for task control can be passed as an array or as a string separated by "," or "|".
Please note that if the device list includes not only devices but also groups or tags, you need to add corresponding prefixes to the IDs to distinguish their types: add "d_" before device IDs, "g_" before group IDs, and "t_" before tag IDs.
For example, if the task requires controlling devices with IDs 1001 and 1002, you can use {"devices":[1001,1002]} or devices="1001,1002".
To control the device with ID 1001 and the group with ID 100, you can use {"devices":["d_1001","g_100"]} or devices="d_1001,g_100". |
| type | Yes | string | Task strategy type, enumeration values, optional values are:
datetime: Execute at a fixed time
minute: Execute every minute
hour: Execute every hour
day: Execute every day
week: Execute every week
month: Execute every month
loop: Execute at intervals |
| times | No | int | Number of executions, an integer greater than or equal to 0; not required.
When the task type is "Fixed-time execution," times will be forcibly set to 1; for other task types, the default value is 0. |
| 策略参数 | Yes | string | After specifying the policy, please provide the corresponding parameters based on the policy type values listed above; refer to the instructions below for details. |
| 执行内容 | Yes | string | Content of task execution: can be a command or an action.
When it is a command: pass the value of commands, in JSON format.
When it is an action: pass the ID of the action, in integer format. |
| enable | No | int | Whether the task takes effect immediately can be set to one of the following values: 0 or 1, or left unspecified.
If left unspecified, it will take effect immediately. |
Return example
Return results
| Name | Type | Description |
|---|---|---|
| code | string | Return the status value: 200 indicates success, for other errors please refer to the "Global Error Codes" section on the API homepage. |
| data | string | Task ID of successfully created task |
| msg | string | Return status information |