Creates a product.
Usage notes
If a Thing Specification Language (TSL) model is required to create a product, you must set the AliyunCommodityCode parameter to iothub_senior and specify the DataFormat parameter. For more information, see the Request parameters section of this topic.
QPS limits
You can call this operation up to 50 times per second per account.
The Resource Access Management (RAM) users of an Alibaba Cloud account share the quota of the account.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
Action | String | Yes | CreateProduct | The operation that you want to perform. Set the value to CreateProduct. |
NodeType | Integer | Yes | 0 | The node type of the product. Valid values:
|
ProductName | String | Yes | Light | The name of the product. The name must be 4 to 30 characters in length, and can contain letters, digits, and underscores (_). Each Chinese character is counted as two characters. Important Each product name must be unique within the current instance. |
IotInstanceId | String | No | iot-***-v64*** | The ID of the instance. You can view the ID of the instance on the Overview page in the IoT Platform console. Important
For more information, see Overview. |
DataFormat | Integer | No | 1 | The data format. Valid values:
|
Description | String | No | Product test | The description of the product. The description can be up to 100 characters in length. |
AliyunCommodityCode | String | No | iothub_senior | The edition of the product.
Important For products of the Basic Edition, you cannot use the online debugging feature in the IoT Platform console. |
Id2 | Boolean | No | false | You do not need to specify this parameter. |
ProtocolType | String | No | modbus | The protocol that the devices of the product use to connect to the gateway. If AliyunCommodityCode is set to iothub_senior and a gateway is required to connect the devices of the product to IoT Platform, you must specify this parameter. Valid values:
|
NetType | String | No | WIFI | The network connection method. This parameter is required if the devices of the products are gateways or directly connected devices. Valid values:
Default value: WIFI. |
JoinPermissionId | String | No | 8*** | You do not need to specify this parameter. |
ResourceGroupId | String | No | rg-acfmxazb4ph*** | The ID of the resource group. Important
|
AuthType | String | No | secret | The authentication method that is used to connect the devices of the product to IoT Platform. You do not need to specify this parameter. The default value secret is automatically used. For more information, see Establish MQTT connections over TCP. |
CategoryKey | String | No | Lighting | The identifier of the product category. If you specify this parameter, a TSL model of the product category is used. Otherwise, no TSL model is used. You can call the ListThingTemplates operation to query the details of product categories that are predefined by IoT Platform and obtain category keys. |
PublishAuto | Boolean | No | false | Specifies whether to publish the TSL model after the product is created. Valid values:
Default value: true. |
ValidateType | Integer | No | 1 | The level of the data verification. By default, if you do not specify this parameter, weak verification is performed. Valid values:
|
In addition to the preceding operation-specific request parameters, you must configure common request parameters when you call this operation. For more information about common request parameters, see Common parameters.
Response parameters
Parameter | Type | Example | Description |
Code | String | 200 | The error code returned if the request failed. For more information, see Error codes. |
Data | Struct | The product information returned if the request is successful. | |
AliyunCommodityCode | String | iothub_senior | Indicates whether a TSL model is used for the product. Valid values:
|
AuthType | String | secret | The authentication method that is used to connect the devices of the product to IoT Platform. |
DataFormat | Integer | 1 | The data format. Valid values:
Note This parameter is returned only when AliyunCommodityCode is set to iothub_senior. |
Description | String | Product test | The description of the product. |
Id2 | Boolean | false | Indicates whether ID²-based authentication is enabled. Valid values:
|
NodeType | Integer | 0 | The node type of the product. Valid values:
Note This parameter is returned only when AliyunCommodityCode is set to iothub_senior. |
ProductKey | String | a1FlqIQ**** | The ProductKey of the product. A ProductKey is a GUID issued by IoT Platform to a product. Note Keep the ProductKey confidential. The ProductKey is required when you perform specific operations. |
ProductName | String | Test | The name of the product. |
ProductSecret | String | U5tW7i44uilc**** | The ProductSecret of the product. |
ProtocolType | String | modbus | The protocol that the devices of the product use to connect to the gateway. Note This parameter is returned only when AliyunCommodityCode is set to iothub_senior. |
ErrorMessage | String | A system exception occurred. | The error message returned if the request failed. |
ProductKey | String | a1FlqIQ**** | The ProductKey of the product. A ProductKey is a GUID that is issued by IoT Platform to a product. |
RequestId | String | E55E50B7-40EE-4B6B-8BBE-D3ED55CCF565 | The ID of the request. |
Success | Boolean | true | Indicates whether the request was successful. Valid values:
|
Examples
Sample requests
https://iot.cn-shanghai.aliyuncs.com/?Action=CreateProduct
&AliyunCommodityCode=iothub_senior
&AuthType=secret
&DataFormat=1
&Description=Product test
&NodeType=0
&ResourceGroupId=rg-acfmxazb4ph****
&ProductName=Test
&ProtocolType=modbus
&CategoryKey=Lighting
&PublishAuto=false
&<Common request parameters>
Sample success responses
XML
format
<CreateProductResponse>
<Data>
<Description>Product test</Description>
<DataFormat>1</DataFormat>
<ProtocolType>modbus</ProtocolType>
<ProductKey>a1FlqIQ****</ProductKey>
<ProductSecret>U5tW7i44uilc****</ProductSecret>
<NodeType>0</NodeType>
<ProductName>Test</ProductName>
<AliyunCommodityCode>iothub_senior</AliyunCommodityCode>
<AuthType>secret</AuthType>
<ResourceGroupId>rg-acfmxazb4ph****</ResourceGroupId>
</Data>
<ProductKey>a1FlqIQ****</ProductKey>
<RequestId>E55E50B7-40EE-4B6B-8BBE-D3ED55CCF565</RequestId>
<Success>true</Success>
</CreateProductResponse>
JSON
format
{
"Data": {
"Description": "Product test",
"DataFormat": 1,
"ProtocolType": "modbus",
"ProductKey": "a1FlqIQ****",
"ProductSecret": "U5tW7i44uilc****",
"NodeType": 0,
"ProductName": "Test",
"AliyunCommodityCode": "iothub_senior",
"AuthType": "secret",
"ResourceGroupId": "rg-acfmxazb4ph****"
},
"ProductKey": "a1FlqIQ****",
"RequestId": "E55E50B7-40EE-4B6B-8BBE-D3ED55CCF565",
"Success": true
}
Error codes
For a list of error codes, see Service error codes.