Creates a topic.
- Each Alibaba Cloud account can call this operation up to once per second.
- The maximum number of topics that you can create in an instance is determined by the specifications of the instance.
Debugging
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 in which you want to create a topic. |
| Topic | String | Yes | alikafka_topic_test |
The name of the topic.
|
| Remark | String | Yes | alikafka_topic_test |
The description of the topic.
|
| RegionId | String | Yes | cn-hangzhou |
The ID of the region where the Message Queue for Apache Kafka instance is deployed |
| CompactTopic | Boolean | No | false |
The log cleanup policy that is used for the topic. When you specify true as the value of the LocalTopic parameter, this parameter takes effect. Valid values:
|
| PartitionNum | String | No | 12 |
The number of partitions of the topic.
|
| LocalTopic | Boolean | No | false |
The storage engine of the topic. Valid values:
|
| ReplicationFactor | Long | No | 3 |
The number of replicas of the topic.
Note If you set the value of this parameter to 1, the risk of data loss increases. Make sure that you are fully aware of the impact
on your business.
|
| MinInsyncReplicas | Long | No | 1 |
The minimum number of in-sync replicas (ISRs).
|
| Config | Map | No | null |
Additional configurations.
Note If you specify this parameter, the ReplicationFactor parameter does not take effect.
|
Response parameters
| Parameter | Type | Example | Description |
|---|---|---|---|
| Code | Integer | 200 |
The HTTP status code returned. The HTTP status code 200 indicates that the request is successful. |
| Message | String | operation success |
The message returned. |
| RequestId | String | 9C0F207C-77A6-43E5-991C-9D98510A**** |
The ID of the request. |
| Success | Boolean | true |
Indicates whether the request is 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
HTTP/1.1 200 OK
Content-Type:application/xml
<CreateTopicResponse>
<RequestId>9C0F207C-77A6-43E5-991C-9D98510A****</RequestId>
<Message>operation success</Message>
<Code>200</Code>
<Success>true</Success>
</CreateTopicResponse>
JSON format
HTTP/1.1 200 OK
Content-Type:application/json
{
"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.