Registers a device under a product.

Usage notes

If you call this operation to register a device under a product, the device is added to the product in the IoT Platform console. After the device is registered, IoT Platform issues the IotId parameter to the device. This parameter is a globally unique identifier (GUID) of the device. To perform operations on a device, you must use the IotId parameter to identify the device.

You can also use a combination of the ProductKey and DeviceName parameters to identify a device. A ProductKey is issued by IoT Platform to a product when you create the product. A DeviceName is specified or randomly generated when you create a device. The IotId parameter has a higher priority than a combination of the ProductKey and DeviceName parameters.

For information about how to register multiple devices under a product at the same time, see BatchRegisterDeviceWithApplyId.

Limits

Each Alibaba Cloud account can run a maximum of 30 queries per second (QPS).

Note RAM users of an Alibaba Cloud account share the quota of the account.

Debugging

Alibaba Cloud provides OpenAPI Explorer to simplify API usage. OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes RegisterDevice

The operation that you want to perform. Set the value to RegisterDevice.

ProductKey String Yes a1BwAGV****

The ProductKey of the product to which the device belongs. A ProductKey is a GUID that is issued by IoT Platform to a product.

You can use the IoT Platform console or call the QueryProductList operation to view the information about all products within the current account.

IotInstanceId String No iot_instc_pu****_c*-v64********

The ID of the instance. You can view the instance ID on the Overview page in the IoT Platform console.

Notice
  • If your instance has an ID, you must configure this parameter. If you do not set this parameter, the call fails.
  • If your instance has no Overview page or ID, you do not need to set this parameter.

For more information, see Overview.

DeviceName String No light

The DeviceName of the device. The name must be 4 to 32 characters in length, and can contain letters, digits, hyphens (-), underscores (_), at signs (@), periods (.), and colons (:).

You can use a combination of the DeviceName and ProductKey parameters to identify a device.

Note If you do not specify this parameter, IoT Platform randomly generates a DeviceName.
DevEui String No e8SDdgeIlk3nED****

The DevEUI of the LoRaWAN device.

This parameter is required when you create a LoRaWAN device.

Nickname String No Campus light

The alias of the device. The alias must be 4 to 64 characters in length, and can contain letters, digits, and underscores (_).

Note If you do not specify this parameter, IoT Platform does not generate an alias for the device.
PinCode String No DIe80dfeg*****

The PIN code of the LoRaWAN device. This parameter is used to verify the DevEUI.

When you create a LoRaWAN device, set LoraNodeType to ALIYUNDEFINED. This parameter is required.

JoinEui String No Ede4tde8erth****

The JoinEUI of the LoRaWAN device.

When you create a LoRaWAN device, set LoraNodeType to USERDEFINED. This parameter is required.

AppKey String No 674f***

The AppKey of the LoRaWAN device.

When you create a LoRaWAN device, set LoraNodeType to USERDEFINED. This parameter is required.

LoraNodeType String No ALIYUNDEFINED

The type of the LoRaWAN device. Valid values:

  • ALIYUNDEFINED: The device is issued by Alibaba Cloud. You must specify DevEui and PinCode.
  • USERDEFINED: The device is user-defined. You must specify DevEui, JoinEui, and AppKey.

In addition to the preceding operation-specific request parameters, you must specify common request parameters when you call this operation. For more information, see Common request parameters.

Response parameters

Parameter Type Example Description
Code String iot.system.SystemException

The error code returned if the call fails. For more information, see Error codes.

Data Struct

The device information returned if the call is successful.

DevEui String e8SDdgeIlk3nED****

The DevEUI of the LoRaWAN device. This parameter is returned only when you create a LoRaWAN device.

DeviceName String light

The DeviceName of the device.

Notice Keep the information confidential.
DeviceSecret String mz2Canp4GB7qRVf1OYPNtRqB2anu****

The DeviceSecret of the device.

Notice Keep the information confidential.
IotId String 1O4YPNtRqB2anumz2Canp4GB7q****

The ID of the device. The ID is the unique identifier that is issued by IoT Platform to the device.

Notice Keep the information confidential.
JoinEui String Ede4tde8erth****

The JoinEUI of the LoRaWAN device. This parameter is returned only when you create a LoRaWAN device.

Nickname String Campus light

The alias of the device.

If you do not specify an alias for the device, this parameter is empty.

ProductKey String a1BwAGV****

The ProductKey of the product to which the device belongs.

ErrorMessage String A system exception occurred.

The error message returned if the call fails.

RequestId String E55E50B7-40EE-4B6B-8BBE-D3ED55CCF565

The ID of the request.

Success Boolean true

Indicates whether the call was successful.

  • true: The call was successful.
  • false: The call failed.

Examples

Sample requests

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

Sample success responses

XML format

<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>

JSON format

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

Error codes

For a list of error codes, visit the API Error Center.