tencent cloud

物联网通信

动态与公告
产品动态
产品简介
产品概述
产品功能
产品优势
应用场景
产品限制
基本概念
快速入门
快速开始
场景一:设备互通
场景二:设备状态上报与状态设置
MQTT.fx接入指南
控制台使用手册
产品管理
规则引擎
子账号访问IoT
固件升级
资源管理
证书管理
开发者手册
功能组件
签名方法
设备身份认证
设备接入协议
网关子设备
消息通信
设备影子
设备固件升级
设备远程配置
资源管理
设备日志上报
NTP服务
设备端接入手册
设备接入概述
基于C SDK接入
基于 Android SDK 接入
基于 Java SDK 接入
基于 Python SDK 接入
API 文档
History
Introduction
API Category
Making API Requests
Device Shadow APIs
Device APIs
CA Certificate APIs
Product APIs
Data Types
Error Codes
常见问题
一般性问题
设备接入和上报问题
规则引擎问题
控制台相关问题
IoT Hub 政策
隐私协议
数据处理和安全协议
词汇表

CreateDevice

PDF
聚焦模式
字号
最后更新时间: 2025-11-13 20:52:08

1. API Description

Domain name for API request: iotcloud.intl.tencentcloudapi.com.

This API is used to create an IoT Hub device.

A maximum of 20 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common Params. The value used for this API: CreateDevice.
Version Yes String Common Params. The value used for this API: 2021-04-08.
Region Yes String Common Params. For more information, please see the list of regions supported by the product.
ProductId Yes String Product ID, globally unique ID assigned by Tencent Cloud during product creation
DeviceName Yes String Device name. It is a string of 1 to 48 characters. Letters, digits, and :_- are allowed.
Attribute No Attribute Device attribute
DefinedPsk No String Whether to use custom PSK, no by default
Isp No Integer ISP, required for a NB-IoT product. 1: China Telecom; 2: China Mobile; 3: China Unicom
Imei No String IMEI, required for a NB-IoT product
LoraDevEui No String DevEUI of a LoRa device, required when you create a LoRa device
LoraMoteType No Integer MoteType of a LoRa device
Skey No String Skey, required when you create a LoRa device
LoraAppKey No String AppKey of a LoRa device
TlsCrt No String Private CA certificate

3. Output Parameters

Parameter Name Type Description
DeviceName String Device name
DevicePsk String Base64-encoded symmetric encryption key, which is returned if symmetric encryption is used
DeviceCert String Device certificate, which authenticates client identity during TLS connection establishment and is returned if asymmetric encryption is used
DevicePrivateKey String Device private key, which authenticates client identity during TLS connection establishment and is returned if asymmetric encryption is used. Tencent Cloud does not store the key. Please store it by yourself properly.
LoraDevEui String DevEUI of a LoRa device, which is returned for a LoRa device
LoraMoteType Integer MoteType of a LoRa device, which is returned for a LoRa device
LoraAppKey String AppKey of a LoRa device, which is returned for a LoRa device
LoraNwkKey String NwkKey of a LoRa device, which is returned for a LoRa device
RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

4. Example

Example1 Creating a device (symmetric encryption)

Input Example

https://iotcloud.intl.tencentcloudapi.com/?Action=CreateDevice
&ProductId=ABCDE12345
&DeviceName=test_device
&Attribute.Tags.0.Tag=note
&Attribute.Tags.0.Type=2
&Attribute.Tags.0.Value=test_note
&<Common request parameters>

Output Example

{
    "Response": {
        "DeviceName": "test_device",
        "DevicePsk": "xxxxxxxxxxxxx",
        "DeviceCert": "",
        "DevicePrivateKey": "",
        "LoraDevEui": "",
        "LoraMoteType": 1,
        "LoraNwkKey": "",
        "LoraAppKey": "xx",
        "RequestId": "54f75f05-a87c-45fc-9520-6b59e251e91c"
    }
}

Example2 Creating a device (asymmetric encryption)

Input Example

https://iotcloud.intl.tencentcloudapi.com/?Action=CreateDevice
&ProductId=ABCDE12345
&DeviceName=test_device
&<Common request parameters>

Output Example

{
    "Response": {
        "DeviceName": "test_device",
        "DevicePsk": "",
        "DeviceCert": "xxxxxxxxxxxxxxxxxxxx",
        "DevicePrivateKey": "xxxxxxxxxxxxxxxxxxxxxxx",
        "LoraDevEui": "",
        "LoraMoteType": 1,
        "LoraNwkKey": "",
        "LoraAppKey": "xx",
        "RequestId": "54f75f05-a87c-45fc-9520-6b59e251e91c"
    }
}

5. Developer Resources

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

Error Code Description
FailedOperation.AlreadyDistributionDevice This device has been transferred and cannot be created again.
FailedOperation.TidWhiteListNotOpen You cannot create devices as allowlist authentication is not enabled. IoT Hub will create devices automatically by the names carried during authentication.
InternalError Internal error.
InternalError.DBOperationError An internal database error occurred.
InvalidParameterValue Invalid parameter value.
InvalidParameterValue.DefinedPskNotBase64 Invalid format. DefinedPsk must be a Base64 string.
InvalidParameterValue.DeviceAlreadyExist The device already exists.
InvalidParameterValue.ProductTypeNotSupport Unsupported product type.
LimitExceeded.DeviceExceedLimit Device quantity exceeded the limit.
ResourceNotFound.ProductNotExist The product does not exist.
UnauthorizedOperation.ProductCantHaveLoRaDevice You cannot create a LoRa device under this product type.
UnauthorizedOperation.ProductCantHaveNormalDevice You cannot create a general device under a NB-IoT product.
UnauthorizedOperation.ProductCantHaveNotLoRaDevice You can create only LoRa devices under this product type.
UnauthorizedOperation.ProductIsForbidden This feature has been disabled for the product.
UnauthorizedOperation.ProductNotSupportPSK The product does not support key authentication.
UnsupportedOperation.SuiteTokenNoCreate You cannot create devices under a suite token product.

帮助和支持

本页内容是否解决了您的问题?

填写满意度调查问卷,共创更好文档体验。

文档反馈