All Products
Search
Document Center

ApsaraMQ for Kafka:CreateTopic

Last Updated:Mar 15, 2024

Creates a topic.

Operation description

  • 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 specification of the instance.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
alikafka:CreateTopicWrite
  • All Resources
    *
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
InstanceIdstringYes

The instance ID.

alikafka_pre-cn-mp919o4v****
TopicstringYes

The topic name.

  • The name can contain only letters, digits, hyphens (-), and underscores (_).
  • The name must be 3 to 64 characters in length. If the name that you specify contains more than 64 characters, the system automatically truncates the name.
  • After a topic is created, you cannot change the name of the topic.
alikafka_topic_test
RemarkstringYes

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.
alikafka_topic_test
RegionIdstringYes

The region ID of the instance in which you want to create a topic.

cn-hangzhou
CompactTopicbooleanNo

The log cleanup policy that is used for the topic. This parameter is available only when LocalTopic is set to true. Valid values:

  • false: The topic uses the default log cleanup policy.
  • true: The topic uses the log compaction policy.
false
PartitionNumstringNo

The number of partitions in the topic.

  • Valid values: 1 to 360.
  • The system recommends the number of partitions based on the specification of the instance. You can view the recommended number in the Message Queue for Apache Kafka console. We recommend that you specify the number that is recommended by the system as the value of this parameter to reduce the risk of data skew.
12
LocalTopicbooleanNo

The type of storage that the topic uses. Valid values:

  • false: The topic uses cloud storage.
  • true: The topic uses local storage.
false
ReplicationFactorlongNo

The number of replicas for the topic.

  • This parameter is available only when LocalTopic is set to true, or the instance is of the Open Source Edition (Local Disk).****
  • Valid values: 1 to 3.
Note If you set this parameter to 1, data loss may occur. Exercise caution when you configure this parameter.
3
MinInsyncReplicaslongNo

The minimum number of in-sync replicas (ISRs).

  • This parameter is available only when LocalTopic is set to true, or the instance is of the Open Source Edition (Local Disk).****
  • The value of this parameter must be smaller than the value of ReplicationFactor.
  • Valid values: 1 to 3.
1
ConfigstringNo

The additional configurations.

  • The value of this parameter must be in JSON format.
  • The key must be replications. The value indicates the number of replicas for the topic. The value must be an integer that ranges from 1 to 3.
  • This parameter is available only when LocalTopic is set to true, or the instance is of the Open Source Edition (Local Disk).****
Note If you specify this parameter, ReplicationFactor does not take effect.
{"replications": 3}
Tagobject []No

The tags that you want to add to the topic.

KeystringYes

The tag key.

  • If you do not specify this parameter, the keys of all tags are matched.
  • The tag key must be 1 to 128 characters in length and cannot contain http:// or https://. The tag key cannot start with aliyun or acs:.
FinanceDept
ValuestringNo

The tag value.

  • You can leave this parameter empty.
  • The tag value must be 1 to 128 characters in length and cannot contain http:// or https://. The tag value cannot start with aliyun or acs:.
FinanceJoshua

Response parameters

ParameterTypeDescriptionExample
object
Codeinteger

The HTTP status code returned. The HTTP status code 200 indicates that the call is successful.

200
Messagestring

The message returned.

operation success
RequestIdstring

The request ID.

9C0F207C-77A6-43E5-991C-9D98510A****
Successboolean

Indicates whether the call was successful.

true

Examples

Sample success responses

JSONformat

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

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-01-06The internal configuration of the API is changed, but the call is not affectedsee changesets
Change itemChange content
The internal configuration of the API is changed, but the call is not affected.
2022-10-28The request parameters of the API has changedsee changesets
Change itemChange content
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: Tag
2021-11-17The request parameters of the API has changedsee changesets
Change itemChange content
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: ReplicationFactor
    Added Input Parameters: MinInsyncReplicas
    Added Input Parameters: Config