Register Sub-device

Last Updated on : 2024-02-28 03:29:39download

Register a manufacturer's sub-device in Tuya's ecosystem.

API address

POST: /v1.0/iot-03/3rdcloud/devices/{third_cloud_device_id}/sub/register

Request parameter

Parameter nameTypeINRequiredDescription
third_cloud_device_idStringuritrueThe unique ID of a manufacturer's device. It can be a unique readable identifier of the specified device, such as device SN, MAC address, or IMEI. It contains no more than 64 characters, including only numbers, uppercase letters, and lowercase letters.

Description of body

Parameter nameTypeINRequiredDescription
device_nameStringbodytrueThe name of the specified device, with no more than 50 characters.
product_idStringbodytrueThe ID of the specified Tuya-enabled device.
gateway_idStringbodytrueThe ID of the specified Tuya-enabled gateway device.
optionsObjectbodyfalseThe extension information about the specified device. Valid values:
  • installLocation: the installation location.
  • outProjectId: the project ID of the device in the manufacturer's cloud.
  • mac: the MAC address.
  • extendData: in JSON format, for example, {"roomNo":"16"}, where roomNo is the hotel room number.
group_idStringbodyfalseThe binding ID, which can be the home ID or asset ID.
If you want to bind a device with a user, you can select either the group_id field or the has_qrcode field.
has_qrcodeBooleanbodyfalseSpecifies whether or not to generate a short URL for device pairing. If this parameter is selected, the short URL for device pairing will be returned in the response result. The manufacturer can generate a QR code based on the returned short URL and paste it on the device. After getting the device, a user can use a Tuya-enabled app to scan the QR code on the device, and thus bind the device with the user.
If you want to bind a device with a user, you can select either the group_id field or the has_qrcode field.

Return parameter

Parameter nameTypeDescription
resultObjectThe response result.
codeStringThe response code. It is empty if the request is successful.
msgStringThe message that is returned if the request fails. It is empty if the request is successful.
successBooleanIndicates whether the operation is successful. Valid values:
  • true: success.
  • false: failure.
tLongThe 13-digit timestamp of a response.

Description of result

Parameter nameTypeDescription
device_idStringThe ID of the specified Tuya-enabled device.
short_urlStringThe short URL for device pairing.

Request example

POST: /v1.0/iot-03/3rdcloud/devices/A18007210830****/sub/register
{
  "device_name": "Test Device",
  "product_id": "xz0uukkq5oce****",
  "gateway_id": "26f4b7ef5f6511cafb****",
  "options": {
    "mac": "48ea63fd****",
    "installLocation": "****Jiangdun Road, Xihu District, Hangzhou City",
  }
}

Return example

{
    "result": {
        "device_id": "6cf4171005d11e2ca7****"
    },
    "t": 1561456817168,
    "success": true
}

Error code

For more information, see error code.