Register devices with IoT Platform before they go online.
Registration methods
IoT Platform supports two registration methods:
-
One Device, One Secret: Register the device on IoT Platform to obtain its device certificate (ProductKey, DeviceName, and DeviceSecret). Burn the certificate into device firmware. After the device connects, it can report data to IoT Platform. One Device, One Secret.
Supported registration protocols:
Device
Supported protocols
Device-side registration development
References
Directly connected device
MQTT
HTTPS
Gateway sub-device
MQTT
Registration and authentication for gateways and sub-devices
-
One Product, One Secret: Devices under the same product share one product certificate (ProductKey and ProductSecret). Enable dynamic registration for the product.
Dynamic registration methods:
-
Pre-registration: Register the device on IoT Platform first. The device obtains a DeviceSecret through dynamic registration.
-
Registration-free: Skip device registration on IoT Platform. The device obtains a ClientID and DeviceToken through dynamic registration.
NoteHTTPS does not support the registration-free method.
One Product, One Secret covers the full process. Gateway sub-devices support only the pre-registration method. Gateways and sub-devices.
Supported registration protocols:
Device
Supported protocols
Device-side registration development
Data format description
Directly connected device
MQTT
HTTPS
Gateway sub-device
MQTT
-
Dynamic MQTT registration for sub-devices
-
Request topic:
/sys/${productKey}/${deviceName}/thing/sub/register -
Response topic:
/sys/${productKey}/${deviceName}/thing/sub/register_reply
Request data format:
{
"id": "123",
"version": "1.0",
"sys":{
"ack":0
},
"params": [
{
"deviceName": "deviceName1234",
"productKey": "a1234******"
}
],
"method": "thing.sub.register"
}
Response data format:
{
"id": "123",
"code": 200,
"data": [
{
"iotId": "12344",
"productKey": "a1234******",
"deviceName": "deviceName1234",
"deviceSecret": "xxxxxx"
}
]
}
Parameters:
|
Parameter |
Type |
Description |
|
id |
String |
The message ID. Must be a unique numeric string per device. Valid values: 0 to 4294967295. |
|
version |
String |
The protocol version. The only valid value is 1.0. |
|
sys |
Object |
Extended feature parameters. Note
If you use a device-side SDK without setting extended features, this parameter is omitted and defaults apply. |
|
ack |
Integer |
Whether the cloud returns a response. A field under sys.
Important
Thing Specification Language model usage examples. If not configured, this parameter is omitted and a response is returned by default. |
|
params |
List |
Parameters for the dynamic registration of a sub-device. |
|
deviceName |
String |
The name of the sub-device. |
|
productKey |
String |
The ProductKey of the sub-device. |
|
iotId |
String |
The unique ID of the device. |
|
deviceSecret |
String |
The device secret. |
|
method |
String |
The request method. Set to |
|
code |
Integer |
The result code. |
Error codes:
|
Error code |
Message |
Description |
|
460 |
request parameter error |
The request parameters are invalid. |
|
6402 |
topo relation cannot add by self |
A device cannot be added as its own sub-device. |
|
401 |
request auth error |
Signature verification failed. |
Dynamic HTTPS registration for directly connected devices
-
URL template:
https://iot-auth.${YourRegionId}.aliyuncs.com/auth/register/device -
HTTP method: POST
Request data format:
POST /auth/register/device HTTP/1.1 Host: iot-auth.cn-shanghai.aliyuncs.com Content-Type: application/x-www-form-urlencoded Content-Length: 123 productKey=a1234******&deviceName=deviceName1234&random=567345&sign=adfv123hdfdh&signMethod=HmacMD5Response format:
{ "code": 200, "data": { "productKey": "a1234******", "deviceName": "deviceName1234", "deviceSecret": "adsfw******" }, "message": "success" }Parameters:
Parameter
Type
Description
Method
String
The request method. POST only.
Host
String
The dynamic HTTPS registration endpoint:
iot-auth.${YourRegionId}.aliyuncs.com.${YourRegionId}: The region ID of your IoT Platform instance.-
Supported regions: all regions except China (Beijing) and China (Shenzhen).
-
Region IDs: Supported regions.
Content-Type
String
The encoding format for device-to-cloud data.
productKey
String
The product identifier.
deviceName
String
The device name.
random
String
A random number.
sign
String
The signature.
Signing method:
-
Sort all parameters except sign and signMethod alphabetically, then concatenate names and values without delimiters.
-
Sign the concatenated string using the signMethod and the product's ProductSecret.
Signature example:
hmac_sha1(productSecret, deviceNamedeviceName1234productKeya1234******random123)signMethod
String
The signing algorithm. Valid values: hmacmd5, hmacsha1, hmacsha256.
code
Integer
The result code.
deviceSecret
String
The device secret.
-