Creates a topic.

  • Each user can send a maximum of one query per second (QPS).
  • The maximum number of topics that can be created in an instance depends on the instance type that you have purchased.

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 CreateTopic

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

InstanceId String Yes alikafka_pre-cn-mp919o4v****

The ID of the Message Queue for Apache Kafka instance on which you want to create the topic.

RegionId String Yes cn-hangzhou

The ID of the region where the instance is located.

Remark String Yes alikafka_topic_test

The description of the topic.

  • The description can contain only letters, digits, hyphens (-), and underscores (_).
  • The description must be 3 to 64 characters in length.
Topic String Yes alikafka_topic_test

The name of the topic.

  • The name can contain only letters, digits, hyphens (-), and underscores (_).
  • The name must be 3 to 64 characters in length. Names that contain more than 64 characters will be automatically truncated.
  • The name cannot be modified after the topic is created.
PartitionNum String No 12

The number of partitions in the topic.

  • Valid values: 1 to 360.
  • To reduce the risk of data skew, we recommend that you set the number of partitions to a multiple of 6.
  • If you require more than 360 partitions, submit a ticket.

Response parameters

Parameter Type Example Description
Code Integer 200

The response code. The HTTP 200 code indicates that the request was successful.

Message String operation success

The response message.

RequestId String 9C0F207C-77A6-43E5-991C-9D98510A****

The ID of the request.

Success Boolean true

Indicates whether the request was successful.

Examples

Sample requests

http(s)://[Endpoint]/? Action=CreateTopic
&InstanceId=alikafka_pre-cn-mp919o4v****
&RegionId=cn-hangzhou
&Remark=alikafka_topic_test
&Topic=alikafka_topic_test
&<Common request parameters>

Sample success responses

XML format

<CreateTopicResponse>
      <RequestId>9C0F207C-77A6-43E5-991C-9D98510A****</RequestId>
      <Message>operation success</Message>
      <Code>200</Code>
      <Success>true</Success>
</CreateTopicResponse>

JSON format

{
    "RequestId": "9C0F207C-77A6-43E5-991C-9D98510A****",
    "Message": "operation success",
    "Code": 200,
    "Success": true
}

Error codes

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