Creates a product.

Usage notes

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

Note 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 connect to IoT Platform directly or as a sub-device of a gateway.

1: gateway. Sub-devices can be attached to a gateway. A gateway can manage sub-devices, maintain the topological relationships with sub-devices, and synchronize the topological relationships to IoT Platform.

ProductName String Yes Light

The name of the product.

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

Note Each product name must be unique within the current account.
IotInstanceId String No iot_instc_pu****_c*-v64********

The ID of the instance.

You do not need to specify this parameter.

DataFormat Integer No 1

The data format. Valid values:

  • 0: custom data format
  • 1: Alink JSON
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. You can create only the products that use the Thing Specification Language (TSL) model. Set the value to iothub_senior.

Id2 Boolean No false

Specifies whether to enable IoT Internet Device ID.

Valid values:

  • true: enables IoT Internet Device ID
  • false: disables IoT Internet Device ID

Default value: false

Note IoT Internet Device ID is available only in the China (Shanghai) region. If the Id2 parameter is set to true but the AuthType parameter is not set to id2, the value of the AuthType parameter is used.
ProtocolType String No modbus

The protocol that the devices of the product use to connect to gateways.

You must specify this parameter if the AliyunCommodityCode parameter is set to iothub_senior and a gateway is required to connect the devices of the product to IoT Platform.

Valid values:

  • modbus: Modbus
  • opc-ua: OPC UA
  • customize: custom protocol
  • ble: BLE
  • zigbee: ZigBee
NetType String No WIFI

The network connection method.

You must specify this parameter if the AliyunCommodityCode parameter is set to iothub_senior and the devices of the product are directly connected to IoT Platform.

Valid values:

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

Default value: WIFI

JoinPermissionId String No 8***

The ID of the network access credential. This parameter is required if the NetType parameter is set to LORA.

ResourceGroupId String No rg-acfmxazb4ph****

The ID of the resource group to which the product belongs. If this parameter is specified, new products are added to the resource group.

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

AuthType String No secret

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

  • secret: uses DeviceSecrets to authenticate the devices. For more information, see TCP-based MQTT connections.
  • id2: uses IoT Internet Device ID to authenticate the devices.
    Note IoT Internet Device ID is available only in the China (Shanghai) region. IoT Internet Device ID is unavailable if the NetType parameter is set to LORA. If you want to use IoT Internet Device ID, you must activate the service.
  • x509: uses X.509 certificates to authenticate the devices.
    Note X.509 certificates are available only in the China (Shanghai) region. X.509 certificates are unavailable if the NetType parameter is set to LORA.

Default value: secret

CategoryKey String No Lighting

The identifier of the product category. If you specify this parameter, a TSL model of the category is used. Otherwise, no TSL model is used.

You can call the ListThingTemplates operation to query the details of 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 the data verification. If you do not specify this parameter, a week verification is performed by default. Valid values:

  • 1: week verification 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 fails the verification in the checkFailedData parameter of the forwarded data. For more information, see Data formats.

  • 2: verification-free 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 specify 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 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 authentication method that was used to connect the devices of the product to IoT Platform. Valid values:

  • secret: DeviceSecrets were used to authenticate the devices.
  • id2: IoT Internet Device ID was used to authenticate the devices.
  • x509: X.509 certificates were used to authenticate the devices.
DataFormat Integer 1

The data format.

  • 0: custom data format
  • 1: Alink JSON
Note This parameter is available 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 connect to IoT Platform directly or as a sub-device of a gateway.
  • 1: gateway. Sub-devices can be attached to a gateway. A gateway can manage sub-devices, maintain the topological relationships with sub-devices, and synchronize the topological relationships to IoT Platform.
Note This parameter is available 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 some 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 used to connect with gateways.

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

The error message returned if the call fails.

ProductKey String a1FlqIQ****

The ProductKey of the product. The ProductKey is the 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.

  • true: The call 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
}

Error codes

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