All Products
Search
Document Center

Key Management Service:ListTagResources

Last Updated:Mar 12, 2026

Queries the tags of a key or a secret.

Operation description

For more information about the access policy required by a RAM user or RAM role to call this API, see Resource Access Management.

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

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID of the resource.

Note

You can call the DescribeRegions to query the most recent region list.

cn-hangzhou

NextToken

string

No

The pagination token that is used in the next request to retrieve a new page of results.

Note

If the call does not return all result entries, the value of the NextToken parameter is returned. By default, 200 rows are returned. You can call this operation again and set the value of the parameter to the value of the parameter that is returned in the last call to implement paged query.

caeba0bbb2be03f84eb48b699f0a4883

ResourceType

string

Yes

The type of resource whose tags you want to query. Valid value:

  • key

  • secret

key

ResourceId

array

No

A list of resource IDs for which you want to query tags. You can enter a maximum of 50 resource IDs.

Enter multiple resource IDs in the ["ResourceId. 1","ResourceId. 2",...] format.

string

No

The resource IDs for which you want to query tags. You can enter a maximum of 50 resource IDs.

Enter multiple resource IDs in the ["ResourceId. 1","ResourceId. 2",...] format.

key-hzz62f1cb66fa42qo****

Tag

array<object>

No

A list of tags that you want to query. Valid values of N: 1 to 20.

object

No

Key

string

No

The key of the tag. A tag consists of a key-value pair.

You can enter up to 20 tags. Enter multiple tags in the [{"Key":"key1","Value":"value1"},{"Key":"key2","Value":"value2"},..] format.

Note

The key cannot start with aliyun or acs:.

disk-encryption

Value

string

No

The value of the tag. A tag consists of a key-value pair.

You can enter up to 20 tags. Enter multiple tags in the [{"Key":"key1","Value":"value1"},{"Key":"key2","Value":"value2"},..] format.

true

Response elements

Element

Type

Description

Example

object

NextToken

string

A pagination token. It can be used in the next request to retrieve a new page of results.

  • If NextToken is empty ("NextToken": ""), no next page exists.

  • If NextToken is not empty, the next query is required, and the value is the token used to start the next query.

e71d8a535bd9cc11

RequestId

string

The request ID.

00827261-20B7-4562-83F2-4DF39876A45A

TagResources

object

TagResource

array<object>

A list of tags.

object

ResourceType

string

The type of the resource.

key

TagValue

string

The value of the tag.

true

ResourceId

string

The resource ID.

key-hzz62f1cb66fa42qo****

TagKey

string

The key of the tag.

disk-encryption

Examples

Success response

JSON format

{
  "NextToken": "e71d8a535bd9cc11",
  "RequestId": "00827261-20B7-4562-83F2-4DF39876A45A",
  "TagResources": {
    "TagResource": [
      {
        "ResourceType": "key",
        "TagValue": "true",
        "ResourceId": "key-hzz62f1cb66fa42qo****",
        "TagKey": "disk-encryption"
      }
    ]
  }
}

Error codes

HTTP status code

Error code

Error message

Description

400 Duplicate.TagKey The specified tagKey is duplicate.
404 InvalidAccessKeyId.NotFound The Access Key ID provided does not exist in our records.
404 InvalidResourceId.NotFound The specified ResourceId is not found.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.