tencent cloud



Last updated: 2023-08-09 14:43:26

1. API Description

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

This API is used to create a subscription to a topic.

A maximum of 200 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: CreateSubscription.
Version Yes String Common Params. The value used for this API: 2020-02-17.
Region No String Common Params. This parameter is not required for this API.
EnvironmentId Yes String Environment (namespace) name.
TopicName Yes String Topic name.
SubscriptionName Yes String Subscriber name, which can contain up to 128 characters.
IsIdempotent Yes Boolean Whether the creation is idempotent; if not, you cannot create subscriptions with the same name.
Remark No String Remarks (up to 128 characters).
ClusterId No String Pulsar cluster ID
AutoCreatePolicyTopic No Boolean Whether to automatically create a dead letter topic and a retry letter topic. true: yes (default value); false: no.
PostFixPattern No String Naming convention for dead letter and retry letter topics. LEGACY indicates to use the legacy naming convention, and COMMUNITY indicates to use the naming convention in the Pulsar community.

3. Output Parameters

Parameter Name Type Description
Result Boolean Creation result.
RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

4. Example

Example1 Creating a subscription

Input Example

Host: tdmq.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateSubscription
<Common request parameters>

    "EnvironmentId": "default",
    "Remark": "Create a subscription",
    "IsIdempotent": "true",
    "TopicName": "cloud_test",
    "SubscriptionName": "cloud_sub",
    "AutoCreatePolicyTopic": "true"

Output Example

    "Response": {
        "Result": true,
        "RequestId": "15288803-dadb-4499-9b5b-ff2f631ca68e"

5. Developer Resources


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.CreateSubscription Failed to create the subscription.
FailedOperation.GetTopicPartitionsFailed Failed to get the number of topic partitions.
InternalError.Retry You can try again.
InternalError.SystemError System error.
InvalidParameterValue.InvalidParams The parameter value is out of the value range.
LimitExceeded.Subscriptions The number of subscribers under the instance exceeds the limit.
LimitExceeded.Topics The number of topics under the instance exceeds the limit.
ResourceInUse.Subscription A subscription with the same name already exists.
ResourceNotFound.BrokerCluster The service cluster does not exist.
ResourceNotFound.Cluster The cluster does not exist.
ResourceNotFound.Topic The topic does not exist.
ResourceUnavailable.FundRequired You must top up before proceeding.
Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support