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 configure the DataFormat parameter. For more information, see the "Request parameters" section of this topic.

QPS limits

Each Alibaba Cloud account can run up to 50 queries per second (QPS).

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

Debugging

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

  • 0: device. Sub-devices cannot be attached to a device. A device can be directly connected to IoT Platform or connected to IoT Platform as a sub-device of a gateway. If you use the device as a sub-device, you must also configure the ProtocolType parameter.
  • 1: gateway. Sub-devices can be attached to a gateway. A gateway can manage sub-devices, maintain topological relationships with sub-devices, and synchronize topological relationships to IoT Platform.
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.

Note Each product name must be unique within the current Alibaba Cloud account.
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
  • If your instance has an ID, you must specify the ID for this parameter. Otherwise, the call fails.
  • If no Overview page or ID is generated for your instance, you do not need to configure this parameter.

For more information, see Overview.

DataFormat Integer No 1

The data format.

If the AliyunCommodityCode parameter is set to iothub_senior, you must configure this parameter.

Valid values:

  • 0: custom data format.
  • 1: Alink JSON format.
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.

  • If you do not configure this parameter, a product of the Basic Edition is automatically created. You cannot use a TSL model to define the product.
  • If you want to configure this parameter, set the value to iothub_senior. A product that supports TSL models is created. You must also configure the DataFormat parameter.
Id2 Boolean No. false

You do not need to configure this parameter.

ProtocolType String No modbus

The protocol used by the devices of the product to connect to the gateway.

If the AliyunCommodityCode parameter is set to iothub_senior and a gateway is required to connect the devices of the product to IoT Platform, you must configure this parameter.

Valid values:

  • modbus: Modbus.
  • opc-ua: Open Platform Communication Unified Architecture (OPC UA).
  • customize: custom protocol.
  • ble: Bluetooth Low Energy (BLE).
  • zigbee: ZigBee.
NetType String No WIFI

The network connection method.

If the AliyunCommodityCode parameter is set to iothub_senior and the devices of the product are directly connected devices or gateways, you must configure this parameter.

Valid values:

  • WIFI: Wi-Fi.
  • CELLULAR: cellular network.
  • ETHERNET: Ethernet.
  • OTHER: other networks.

Default value: WIFI.

JoinPermissionId String No 8***

You do not need to configure this parameter.

ResourceGroupId String No rg-acfmxazb4ph***

The ID of the resource group to which the product belongs. If you specify a value for this parameter, the product is added to the resource group.

You can log on to the Resource Management console to view the ID of the resource group.

Important

You can specify a value for this parameter only if you have activated Resource Management.

AuthType String No secret

The verification method that is used to connect the devices of the product to IoT Platform. Valid values:

You do not need to configure this parameter. secret: uses DeviceSecrets to verify the devices. Default value: secret. For more information, see MQTT connections over TCP.

CategoryKey String No Lighting

The identifier of the product category. If you configure 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.

  • true: publishes the TSL model after the product is created.
  • false: does not publish the TSL model after the product is created.

Default value: true.

ValidateType Integer No 1

The level of data verification. If you do not configure this parameter, the default value is used. Valid values:

  • 1: weak verification. Default value: 1. IoT Platform verifies only the identifier and dataType fields of the data. All data is forwarded.

    In the IoT Platform console, the data is displayed on the TSL Data tab of the Device Details page. The data that fails the verification is not displayed.

    You can view the data that failed the verification in the checkFailedData parameter of the forwarded data. For more information, see Data formats.

  • 2: no verification. IoT Platform does not verify the data. All data is forwarded.

    In the IoT Platform console, the data is not displayed on the TSL Data tab of the Device Details page.

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

Response parameters

Parameter Type Example Description
Code String 200

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

Data Struct

The product information returned if the call is successful.

AliyunCommodityCode String iothub_senior

The edition of the product.

  • iothub_senior: A TSL model was used.
  • iothub: No TSL model was used.
AuthType String secret

The verification method that is used to connect the devices of the product to IoT Platform. Valid values:

  • secret: uses DeviceSecrets to verify the devices.
  • id2: uses IoT Internet Device ID to verify the devices.
  • x509: uses X.509 certificates to verify the devices.
DataFormat Integer 1

The data format.

  • 0: custom data format.
  • 1: Alink JSON format.
Note This parameter is returned only if the AliyunCommodityCode parameter is set to iothub_senior.
Description String Product test

The description of the product.

Id2 Boolean false

Indicates whether IoT Internet Device ID was enabled.

  • true: IoT Internet Device ID was enabled.
  • false: IoT Internet Device ID was disabled.
NodeType Integer 0

The node type of the product. Valid values:

  • 0: device. Sub-devices cannot be attached to a device. A device can be directly connected to IoT Platform or connected to IoT Platform as a sub-device of a gateway.
  • 1: gateway. Sub-devices can be attached to a gateway. A gateway can manage sub-devices, maintain topological relationships with sub-devices, and synchronize topological relationships to IoT Platform.
Note This parameter is available only if the AliyunCommodityCode parameter is set to iothub_senior.
ProductKey String a1FlqIQ****

The ProductKey of the product. A ProductKey is a globally unique identifier (GUID) that is issued by IoT Platform to a new 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 used by the devices of the product to connect to the gateway.

Note This parameter is available only if the AliyunCommodityCode parameter is set to iothub_senior.
ErrorMessage String A system exception occurred.

The error message returned if the request fails.

ProductKey String a1FlqIQ****

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

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

The ID of the request.

Success Boolean true

Indicates whether the call was successful. Valid values:

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

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
}