All Products
Search
Document Center

IoT Platform:CreateProductTopic

Last Updated:Dec 13, 2023

Creates a custom topic category for a product.

QPS limits

You can call this operation up to one time per second per account.

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 CreateProductTopic

The operation that you want to perform. Set the value to CreateProductTopic.

Operation String Yes PUB

The permissions of a device on the custom topic category. Valid values:

  • SUB: Subscribe.
  • PUB: Publish.
  • ALL: Publish and Subscribe.
ProductKey String Yes aldDEin****

The ProductKey of the product for which you want to create the custom topic category.

TopicShortName String Yes submit

The name of the custom topic category.

A topic category consists of several fields. Separate the fields with forward slashes (/). The name can contain letters, digits, and underscores (_). Each level name of the topic category cannot be empty.

Note If you set Operation to SUB, you can specify the plus sign (+) and number sign (#) wildcard characters in the name of a topic category to allow devices to subscribe to multiple topics at a time. For more information about how to use wildcard characters, see Custom topics with wildcard characters.
  • If you use a cloud gateway product, no prefix is automatically specified. You must specify a custom value for the parameter. You can use ${deviceName} to specify a DeviceName.
  • If you use a non-cloud gateway product, /${productKey}/${deviceName}/user/ is automatically specified as the prefix of the value of TopicShortName. You need to only specify a custom name for the topic category.
IotInstanceId String No iot_instc_pu****_c*-v64********

The ID of the instance. You can view the ID of the instance on the Overview tab 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 your instance does not have an ID, you do not need to configure the parameter.

For more information about instances, see Overview.

Desc String No submit a test topic

The description of the custom topic category. The description can be up to 100 characters in length.

EnableProxySubscribe Boolean No false

If you set Operation to SUB or ALL, you can enable the delegated subscription feature.

Valid values:

  • true: enables the delegated subscription feature.
  • false: disables the delegated subscription feature.

If you enable the delegated subscription feature for a topic, IoT Platform obtains the details of the topic and helps a device subscribe to the topic when you connect the device to IoT Platform.

Codec String No compress

Specifies whether to enable the data compression or decompression feature for a custom topic. This parameter is available only if you use a Standard or Exclusive Enterprise Edition instance.

Valid values:

  • compress: enables data compression.
  • decompress: enables data decompression.

For more information, see Data compression.

Important If you specify a value that contains wildcard characters, including the plus sign (+) and number sign (#), for TopicShortName, you cannot configure Codec. If the data compression or decompression feature is enabled when you use the wildcard characters to create a topic category, the call fails.

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 iot.system.SystemException

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

ErrorMessage String A system exception occurred.

The error message returned if the call fails.

RequestId String FCC27691-9151-4B93-9622-9C90F30542EC

The ID of the request.

Success Boolean true

Indicates whether the call was successful. Valid values:

  • true: The call was successful.
  • false: The call failed.
TopicId Long 10000

The ID of the custom topic category. The ID is issued by IoT Platform if the call is successful.

Note Keep the custom topic category ID confidential. The custom topic category ID is required when you call specific operations that are related to the custom topic category.

Examples

Sample requests

https://iot.cn-shanghai.aliyuncs.com/?Action=CreateProductTopic
&ProductKey=aldDEin****
&TopicShortName=submit
&Operation=PUB
&Desc=submit a test topic
&<Common request parameters>

Sample success responses

XML format

<CreateProductTopicResponse>
      <RequestId>FCC27691-9151-4B93-9622-9C90F30542EC</RequestId>
      <Success>true</Success>
      <TopicId>10000</TopicId>
</CreateProductTopicResponse>

JSON format

{
    "RequestId":"FCC27691-9151-4B93-9622-9C90F30542EC",
    "Success":true,
    "TopicId":10000
}

Error codes

For a list of error codes, see Service error codes.