Call this operation to register a device.

Description

Registering a device means creating a device for a product. After a device is successfully registered, Alibaba Cloud IoT Platform issues a globally unique ID (IotId) for the device. When you perform operations related to the device, you can provide the IotId to identify the device.

Note Besides IotId, you also can use the combination of ProductKey and DeviceName to identity a device. ProductKey is the identifier that IoT Platform issues for a product when it is created, and DeviceName is the device name that either you specify or the system randomly generates when the device is registered. The priority of IotId is higher than the combination of ProductKey and DeviceName.
  • If you want to register multiple devices for a product at a time and have the device names randomly generated by the system, you can call the BatchRegisterDevice operation. See BatchRegisterDevice.
  • If you want to register multiple devices with specified names, firstly, call BatchCheckDeviceNames to register names for the devices that you want to register and generate an application ID (ApplyId), and then call BatchRegisterDeviceWithApplyId to register devices. See BatchCheckDeviceNames and BatchRegisterDeviceWithApplyId.

Request parameters

Parameter Type Required Description
Action String Yes The operation that you want to perform. Set the value to RegisterDevice.
ProductKey String Yes The identifier of the product to which the device to be registered belongs.
DeviceName String No

The name of the device that you want to register. The device name must consist of 4 to 32 characters, including English letters, digits, and special characters, for example, hyphens (-), underscores (_), at signs (@), periods (.) , and colons (:).

DeviceName is used with ProductKey to identify a specified device.

Note If you do not specify this parameter, the system will generate a name for the device.
Nickname String No Add a nickname for the device. A nickname can be 4-64 characters in length, and can contain Chinese characters, English letters, numbers and underscores (_). A Chinese character counts as two characters.
Common Request Parameters - Yes For more information about common request parameters, see Common parameters.

Response parameters

Parameter Type Description
RequestId String The globally unique ID generated by Alibaba Cloud for the request.
Success Boolean Indicates whether the call is successful. A value of true indicates that the call is successful. A value of false indicates that the call has failed.
ErrorMessage String The error message returned when the call fails.
Code String The error code returned when the call fails. For more information about error codes, see Error codes.
Data Data The device information returned when the call is successful. For more information, see the following table DeviceInfo.
Table 1. DeviceInfo
Parameter Type Description
ProductKey String The identifier of the product that the device belongs to.
DeviceName String The device name.
Note Keep this information confidential.
DeviceSecret String

The device secret.

Note Keep this information confidential.
IotId String

The device ID issued by IoT Platform for the device as a unique identifier.

Note Keep this information confidential.
Nickname String The nickname of the device.

Examples

Request example

https://iot.cn-shanghai.aliyuncs.com/?Action=RegisterDevice
&ProductKey=a1rYuVF****
&DeviceName=device1
&Nickname=detectors_in_beijing
&Common request parameters

Response example

  • JSON format

    {
        "RequestId": "57b144cf-09fc-4916-a272-a62902d5b207", 
        "Success": true, 
        "Data": {
            "DeviceName": "device1", 
            "ProductKey": "a1rYuVF****", 
            "DeviceSecret": "tXHf4ezGEHcwdyMwoCDHGBmk9avi****", 
            "IotId": "CqXL5h5ysRTA4NxjABjj0010fa****", 
            "Nickname": "detectors_in_beijing"
        }
    }
  • XML format

    <?xml version='1.0' encoding='utf-8'?>
    <RegisterDeviceResponse>
        <RequestId>57b144cf-09fc-4916-a272-a62902d5b207</RequestId>
        <Success>true</Success>
        <Data>
            <DeviceName>device1</DeviceName>
            <ProductKey>a1rYuVF****</ProductKey>
            <DeviceSecret>tXHf4ezGEHcwdyMwoCDHGBmk9avi****</DeviceSecret>
            <IotId>CqXL5h5ysRTA4NxjABjj0010fa****</IotId>
            <Nickname>detectors_in_beijing</Nickname>
        </Data>
    </RegisterDeviceResponse>