All Products
Search
Document Center

ApsaraMQ for RocketMQ:ListTagResources

Last Updated:Dec 12, 2025

Call the ListTagResources operation to query the tags attached to a resource.

Operation description

Important The OpenAPI provided by Alibaba Cloud is a control-plane API used to manage and query resources of Alibaba Cloud services. Integrate this API only on the control plane. Do not use this OpenAPI on the core data link to send or receive messages. Otherwise, threats may occur on the data link.

When you call the ListTagResources operation, specify at least one of the tag key Tag.N.Key or the resource ID ResourceId.N. You can query all tags for a resource. You can also query tag values and the resources to which the tags are attached based on a specified tag key.

  • If you specify the tag key Tag.N.Key, you can query the tag value Tag.N.Value and the ID of the attached resource ResourceId.N.

  • If you specify the resource ID ResourceId.N, you can query all tag information for the specified resource, including the tag key Tag.N.Key and the tag value Tag.N.Value.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

mq:ListTagResources

get

*All Resource

*

None
  • mq:QueryInstanceBaseInfo

Request parameters

Parameter

Type

Required

Description

Example

InstanceId

string

No

The ID of the instance where the tagged resource is located.

Note

If you query tags for a topic or group, you must specify this parameter.

MQ_INST_188077086902****_BXSuW61e

ResourceType

string

Yes

The resource type. This is an enumeration. Valid values:

  • INSTANCE

  • TOPIC

  • GROUP

TOPIC

NextToken

string

No

The token that is used to start the next page of a paginated query.

caeba0****be03f84eb48b699f0a4883

Tag

array<object>

No

A list of tags. The list can contain a maximum of 20 elements.

object

No

Key

string

No

The tag key of the resource.

  • If you specify this parameter, its value cannot be an empty string.

  • The value can be up to 128 characters in length. It cannot start with aliyun or acs:. It cannot contain http:// or https://.

CartService

Value

string

No

The tag value of the resource.

  • If you specify this parameter, its value can be an empty string.

  • The value can be up to 128 characters in length. It cannot start with aliyun or acs:. It cannot contain http:// or https://.

ServiceA

ResourceId

array

No

A list of resource IDs.

TopicA

string

No

The ID of the resource to query.

  • If the resource type is instance, set this parameter to the instance ID.

  • If the resource type is topic, set this parameter to the topic name.

  • If the resource type is group, set this parameter to the group ID.

test

Response elements

Element

Type

Description

Example

object

NextToken

string

The token that is used to start the next page of a paginated query.

caeba0****be03f84eb48b699f0a4883

RequestId

string

The ID of the request. This is a common parameter. Each request has a unique ID. You can use this ID to locate and troubleshoot issues.

301D2CBE-66F8-403D-AEC0-82582478****

TagResources

array<object>

A collection of resources and their tags. The collection contains information such as resource IDs, resource types, and tag key-value pairs.

object

ResourceType

string

The resource type.

  • ALIYUN::MQ::INSTANCE: The resource is an instance.

  • ALIYUN::MQ::TOPIC: The resource is a topic.

  • ALIYUN::MQ::GROUP: The resource is a group.

ALIYUN::MQ::TOPIC

InstanceId

string

The instance ID.

MQ_INST_188077086902****_BXSuW61e

TagValue

string

The tag value.

ServiceA

ResourceId

string

The resource ID.

TopicA

TagKey

string

The tag key.

CartService

Examples

Success response

JSON format

{
  "NextToken": "caeba0****be03f84eb48b699f0a4883",
  "RequestId": "301D2CBE-66F8-403D-AEC0-82582478****",
  "TagResources": [
    {
      "ResourceType": "ALIYUN::MQ::TOPIC",
      "InstanceId": "MQ_INST_188077086902****_BXSuW61e",
      "TagValue": "ServiceA",
      "ResourceId": "TopicA",
      "TagKey": "CartService"
    }
  ]
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.