You can call this operation to create a topic.

This operation is usually called when you need to create new topics to publish new applications or implement service logic.

By default, only Alibaba Cloud accounts can call this operation. Resource Access Management (RAM) users can call this operation only after being authorized.

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 OnsTopicCreate

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

InstanceId String Yes MQ_INST_111111111111_DOxxxxxx

The ID of the Message Queue for Apache RocketMQ instance corresponding to the topic that you want to create.

MessageType Integer Yes 0

The type of messages in the topic. Valid values:

  • 0: normal message
  • 1: partitionally ordered message
  • 2: globally ordered message
  • 4: transactional message
  • 5: scheduled or delayed message
Topic String Yes test

The name of the topic that you want to create.

  • "CID" and "GID" are reserved for group IDs and therefore cannot be the start of a topic name.
  • If a namespace is configured for the Message Queue for Apache RocketMQ instance for which the topic is created, the topic name must be unique in the Message Queue for Apache RocketMQ instance, but can be duplicated across other Message Queue for Apache RocketMQ instances.
  • If no namespace is configured for the Message Queue for Apache RocketMQ instance for which the topic is created, the topic name must be globally unique across all Message Queue for Apache RocketMQ instances and regions.
Remark String No test

The description of the topic.

Response parameters

Parameter Type Example Description
RequestId String B6949B58-223E-4B75-B4FE-7797C15E2D1F

The ID of the request. This is a common parameter that facilitates troubleshooting and fault locating.

Examples

Sample requests

http(s)://[Endpoint]/? Action=OnsTopicCreate
&InstanceId=MQ_INST_111111111111_DOxxxxxx
&MessageType=0
&Topic=test
&<Common request parameters>

Sample success responses

XML format

<OnsTopicCreateResponse>
  <RequestId>B6949B58-223E-4B75-B4FE-7797C15E2D1F</RequestId>
</OnsTopicCreateResponse>

JSON format

{
	"RequestId": "B6949B58-223E-4B75-B4FE-7797C15E2D1F"
}

Error codes

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