Control the Device and Issue Commands to It
HTTP Request URL: http(s)://api.thingboot.com/{AppID}/device/control/?sign={sign}&ts={ts}
About the sign and ts definition
Or
MQTT Publish Topic: api/{AppID}/device/control
The returned results are also received on the same topic.
Request parameters
When the parameters are relatively long, it is recommended to use the POST method.
| Name | Required | Type | Description |
|---|---|---|---|
| gateway | No | string | When sending a order to a device that must be forwarded by its associated gateway, you must specify the gateway’s device ID—the unique ID found on the gateway housing and in the management console.
To include multiple gateways, separate their IDs with a comma (,) or vertical bar (|); up to five gateways can be specified at once. |
| device | Yes | string | Device ID, Unique Device ID (Found on the device housing and console)
When specifying multiple devices, connect them with a separator (, or |).When specifying multiple devices, these devices do not need to belong to the same product category, but they must support the same command. |
| order | Yes | string | Command: JSON String (Recommended) or Direct Parameter Transmission
Simple Commands: Can be sent via GET or POST directly in the format: Device Attribute Name=Attribute Value
Complex or Long Commands: Please send via POST in the format: {"order":{"Command Content"}}
In some business scenarios, it is necessary to carry specific information (e.g., order number) in the command.You can add an extra field to the order object. For example:{"power":1,"extra":"T25030700001"}
This specific information will be returned as-is in the asynchronous message push corresponding to this command.
Note: The extra field only supports uppercase/lowercase letters (a-zA-Z) and numbers (0-9), with a maximum length of 32 characters. |
Return example
Return results
It should be noted that a status code of 200 only indicates that the platform has received a valid device ID and parameter name, and has successfully sent a command to the device.
However, the device may be offline, or there may be errors in the
| Name | Type | Description |
|---|---|---|
| code | int | 200: Command issued successfully.
501: No Device ID specified. The Device ID must be a single integer, or multiple integers separated by "|" or ",". This ID is available in the Device List API and can also be viewed in the Device List section of this console.
502: Device does not exist or no available devices. All provided Device IDs are invalid. Please check if the Device IDs are correct and whether the devices have been deleted.
503: Excessive devices specified. A maximum of 100 Device IDs can be specified at one time.
504: Multiple Device IDs specified, but some are unavailable (non-existent, no permission, or deleted).
50xx: Please refer to "Global Error Codes". |
Return example