All Products
Search
Document Center

Key Management Service:ListTagResources

Last Updated:Jul 29, 2025

Queries the tags of a key or a secret.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

There is currently no authorization information disclosed in the API.

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

The region ID of the resource.

Note You can call the DescribeRegions to query the most recent region list.
cn-hangzhou
NextTokenstringNo

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
ResourceTypestringYes

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

  • key
  • secret
key
ResourceIdarrayNo

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.

stringNo

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****
Tagarray<object>No

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

objectNo
KeystringNo

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
ValuestringNo

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 parameters

ParameterTypeDescriptionExample
object
NextTokenstring

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
RequestIdstring

The request ID.

00827261-20B7-4562-83F2-4DF39876A45A
TagResourcesarray<object>

A list of tags.

TagResourceobject
ResourceTypestring

The type of the resource.

key
TagValuestring

The value of the tag.

true
ResourceIdstring

The resource ID.

key-hzz62f1cb66fa42qo****
TagKeystring

The key of the tag.

disk-encryption

Examples

Sample success responses

JSONformat

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

Error codes

HTTP status codeError codeError message
400Duplicate.TagKeyThe specified tagKey is duplicate.
404InvalidAccessKeyId.NotFoundThe Access Key ID provided does not exist in our records.
404InvalidResourceId.NotFoundThe specified ResourceId is not found.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-05-30The Error code has changedView Change Details