tencent cloud

CreateTopic
Last updated: 2025-11-25 10:53:40
CreateTopic
Last updated: 2025-11-25 10:53:40

1. API Description

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

This API is used to add a message topic in the specified partition and type.

A maximum of 25 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: CreateTopic.
Version Yes String Common Params. The value used for this API: 2020-02-17.
Region Yes String Common Params. For more information, please see the list of regions supported by the product. This API only supports: ap-bangkok, ap-beijing, ap-chengdu, ap-chongqing, ap-guangzhou, ap-hongkong, ap-jakarta, ap-nanjing, ap-seoul, ap-shanghai, ap-shanghai-fsi, ap-shenzhen-fsi, ap-singapore, ap-tokyo, eu-frankfurt, na-ashburn, na-siliconvalley.
EnvironmentId Yes String Environment (namespace) name.
TopicName Yes String Topic name, which can contain up to 64 letters, digits, hyphens, and underscores.
Partitions Yes Integer The input parameter is 1, which means creating a non-partitioned topic with no partition. if the input parameter is greater than 1, it indicates the number of partitions for a partitioned topic, and the maximum cannot exceed 32.
ClusterId Yes String Pulsar cluster ID
Remark No String Remarks (up to 128 characters).
TopicType No Integer This input parameter will be disused soon. You can use PulsarTopicType instead.
0: General message;
1: Globally sequential message;
2: Partitionally sequential message;
3: Retry letter topic;
4: Dead letter topic.
PulsarTopicType No Integer Pulsar topic type.
0: Non-persistent and non-partitioned
1: Non-persistent and partitioned
2: Persistent and non-partitioned
3: Persistent and partitioned
MsgTTL No Integer Retention period for unconsumed messages in seconds. value ranges from 60 seconds to 15 days.
UnackPolicy No String Default if not passed is native policy. DefaultPolicy means when the subscription reaches the maximum unacknowledged messages of 5000, the server will stop pushing messages to all consumers under the current subscription. DynamicPolicy means dynamically adjust the maximum unacknowledged messages of the subscription, with the specific quota being the maximum between 5000 and the number of consumers multiplied by 20. the default maximum unacknowledged message count per consumer is 20. exceeding this limit only affects that consumer and does not affect other consumers.
IsolateConsumerEnable No Boolean Whether exception consumer isolation is enabled.
AckTimeOut No Integer Specifies the consumer Ack timeout period in seconds. value range: 60-(3600*24).

3. Output Parameters

Parameter Name Type Description
EnvironmentId String Environment (namespace) name.
TopicName String Topic name.
Partitions Integer Valid value: 0 or 1. Non-partitioned topic: No partitions. A value greater than 1: The partition count of a partitioned topic. 0 is returned for existing non-partitioned topics, and 1 is returned for incremental non-partitioned topics.
Remark String Remarks, within 128 characters.
TopicType Integer 0: standard message.
Global sequential message.
2: local ordered messages.
Specifies the retry queue.
4: dead letter queue.
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 Create topics.

Create topics.

Input Example

POST / HTTP/1.1
Host: tdmq.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateTopic
<Common request parameters>

{
    "EnvironmentId": "devNs",
    "TopicName": "devTopic",
    "Partitions": 1,
    "Remark": "devTest",
    "TopicType": 1,
    "ClusterId": "pulsar-5r59xd4vnx",
    "PulsarTopicType": 0,
    "MsgTTL": 1
}

Output Example

{
    "Response": {
        "EnvironmentId": "default",
        "TopicName": "test_topic",
        "Partitions": 2,
        "TopicType": 0,
"Remark": "Ordinary message queue with 2 partitions"
        "RequestId": "d9686bf9-8d7d-4e78-bb44-5140d70a1ffa"
    }
}

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
AuthFailure.UnauthorizedOperation CAM authentication failed.
FailedOperation Operation failed.
FailedOperation.CloudService Third-Party cloud service exception. try again later.
FailedOperation.CreateTopic Failed to create the topic.
FailedOperation.IsolateConsumerEnable Settings not supported for this parameter in the current cluster.
FailedOperation.OperateLater Task in progress. please try again later.
FailedOperation.ReplicationDestCheckFailedError Cross-Region replication validation failed.
FailedOperation.ReplicationSourceCheckFailedError Cross-Region replication verification failed.
InternalError.SystemError System error.
InvalidParameterValue The parameter value is incorrect.
InvalidParameterValue.AckTime AckTime parameter error.
InvalidParameterValue.InvalidParams The parameter value is out of the value range.
LimitExceeded.Topics The number of topics under the instance exceeds the limit.
MissingParameter.NeedMoreParams A required parameter is missing.
ResourceInUse The resource is in use.
ResourceInUse.Topic A topic with the same name already exists.
ResourceNotFound.BrokerCluster The service cluster does not exist.
ResourceNotFound.Cluster The cluster does not exist.
ResourceNotFound.Environment The environment does not exist.
ResourceUnavailable.FundRequired You must top up before proceeding.
UnknownParameter.Policy Policy parameter error.
UnsupportedOperation.TopicUnack Unack operation is not supported in the current cluster.
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback