tencent cloud


Creating a Topic

Last updated: 2019-11-29 17:55:28

    1. API Description

    This API (CreateTopic) is used to create a new topic under the user's account.

    Domain for public network API request: cmq-topic-region.api.qcloud.com

    Domain for private network API request: cmq-topic-region.api.tencentyun.com

    Note: Whenever (including during alpha test) any public network downstream traffic is generated from the use of a public network domain, a fee will be charged. It is strongly recommended that users whose services are on the Tencent Cloud use private network domains, because no fee will be charged for the traffic consumed in the private network.

    • region should be replaced with a specific region: gz (Guangzhou), sh (Shanghai), or bj (Beijing). The region value in the common parameters should be consistent with the region value of the domain. If there is an inconsistency, the request will be sent to the region specified by the domain.
    • Public network domain requests support both http and https. Private network requests only support http.
    • Some of the input parameters are optional. If not specified, the default value will be taken.
    • All the output parameters will be returned to the user when the request is successful; otherwise, at least code, message, and requestId will be returned.

    2. Input Parameters

    The following request parameter list only provides API request parameters. For other parameters, refer to Common Request Parameters.

    Parameter Name Required Type Description
    topicName Yes String Topic name. It is unique under the same account in one region. The topic name is a string of no more than 64 characters, which can contain letters, numbers, and hyphens (-) and must begin with a letter.
    maxMsgSize No Int Maximum message length. Value range is 1024-65536 Bytes (1-64 K). Default is 65536.
    filterType No Int It is used to specify a message matching policy for a topic:
    filterType = 1 or null indicates that filterTag is used to filter messages for all the subscriptions under the topic;
    filterType = 2 indicates that bindingKey is used for filtering.
    Note: This parameter cannot be changed once configured.
    ## 3. Output Parameters
    Parameter Name Type Description
    code Int 0: Succeeded, others: Error. See the table below for specific errors.
    message String Error message.
    requestId String Request ID generated by server. When there is an internal error on the server, users can submit this ID to the backend to locate the problem.
    topicId String Unique ID of a topic. Please note that Cloud APIs are called through name instead of ID.

    4. Error Codes

    Error Code Module Error Code Error Message Description
    4460 10550 topic is already existed A topic with the same name exists under the same account.
    4000 10590 topic name format error The format of the topic name is incorrect.
    4450 10610 number of topics has reached the limit The number of topics has reached the limit. Currently, the limit is 1,000.
    6040 10660 It will take some time to release resources of previous topic before you can create a new topic with the same name. Please try later. Failed to create a topic with the same name. It will take some time to release resources of the previous topic with the same name. Currently, to ensure data consistency of CMQ, it is not allowed to create a new topic with the same name within ten seconds after a topic is deleted.

    Note: The error codes listed in the above table are specific to this API.

    5. Example


     &<Common Request Parameters>


    "code" : 0,
    "message" : "",
    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