Creating a Topic or Deleting Topics in Batches
Function
This API is used to create a topic or delete topics in batches.
URI
POST /v2/{project_id}/instances/{instance_id}/topics
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
project_id |
Yes |
String |
Definition Project ID. For details about how to obtain it, see Obtaining a Project ID. Constraints N/A Range N/A Default Value N/A |
|
instance_id |
Yes |
String |
Definition Instance ID. You can call the API for querying all instances to obtain the instance ID. The instance ID is in the response body. Constraints N/A Range N/A Default Value N/A |
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
name |
No |
String |
Definition Topic name. Constraints Enter 3 to 64 characters. Use only letters, digits, percent (%), vertical bars (|), hyphens (-), and underscores (_). Mandatory for topic creation. Range N/A Default Value N/A |
|
brokers |
No |
Array of strings |
Associated broker. This parameter is mandatory only for RocketMQ 4.8.0 instances. |
|
queue_num |
No |
Number |
Total number of queues. The range is 1–50. |
|
queues |
No |
Array of queues objects |
Queue. This parameter is mandatory only for RocketMQ 4.8.0 instances. |
|
permission |
No |
String |
Permission. This parameter is mandatory only for RocketMQ 4.8.0 instances. Options: |
|
message_type |
No |
String |
Message type (This parameter is mandatory only for RocketMQ 5.x instances). Options: |
|
topics |
No |
Array of strings |
Topic list. This parameter is used when topics are deleted in batches. |
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
id |
String |
Topic name. |
|
job_id |
String |
Job ID for deleting topics. |
Example Requests
-
For RocketMQ 4.8.0 instances: Creating a topic associated with broker-0 with 3 queues
POST https://{endpoint}/v2/{project_id}/instances/{instance_id}/topics { "name" : "topic-test", "permission" : "all", "queues" : [ { "broker" : "broker-0", "queue_num" : 3 } ] } -
Deleting topics of a RocketMQ 5.x instance in a batch
POST https://{endpoint}/v2/{project_id}/instances/{instance_id}/topics?action=delete { "topics" : [ "topic01", "topic02" ] }
Example Responses
Status code: 200
Topic created.
Status Codes
|
Status Code |
Description |
|---|---|
|
200 |
Topic created. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.