Updated on 2025-10-22 GMT+08:00

Modifying a Topic

Function

This API is used to modify a topic.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions. For details about the required permissions, see Permissions Policies and Supported Actions.

URI

PUT /v2/{project_id}/mqs/instances/{instance_id}/topics

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain a project ID, see "Appendix" > "Obtaining a Project ID" in this document.

instance_id

Yes

String

Instance ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token, which can be obtained by calling the IAM API (value of X-Subject-Token in the response header).

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

topics

Yes

Array of UpdateTopicObject objects

Topic list.

Table 4 UpdateTopicObject

Parameter

Mandatory

Type

Description

name

Yes

String

Topic name.

retention_time

No

Integer

Message retention period. The default value is 72. Value range: 1 to 168, in hours

sync_replication

No

Boolean

Whether synchronous replication is enabled.

sync_message_flush

No

Boolean

Whether synchronous flushing is enabled.

description

No

String

Description.

sensitive_word

No

String

Sensitive fields.

new_partition_numbers

No

Integer

Number of partitions after the modification.

Response Parameters

Status code: 204

No Content

Status code: 400

Table 5 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 403

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Example Requests

Modify configurations of a specified topic by changing the message retention time to 72 hours and enabling synchronous replication and flushing.

PUT https://{endpoint}/v2/{project_id}/mqs/instances/{instance_id}/topics

{
  "topics" : [ {
    "name" : "topic-test",
    "retention_time" : 72,
    "sync_replication" : true,
    "sync_message_flush" : true,
    "description" : "",
    "sensitive_word" : ""
  } ]
}

Example Responses

Status code: 400

Bad Request

{
  "error_code" : 400,
  "error_msg" : "Bad Request"
}

Status code: 403

Forbidden

{
  "error_code" : 403,
  "error_msg" : "Forbidden"
}

Status Codes

Status Code

Description

204

No Content

400

Bad Request

403

Forbidden

Error Codes

See Error Codes.