Queries the tags of a key or a secret.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

ParameterTypeRequiredExampleDescription
ActionStringYesListTagResources

The operation that you want to perform. Set the value to ListTagResources.

RegionIdStringYescn-hangzhou

The ID of the region to which the resource belongs.

Note You can call the DescribeRegions operation to query a list of available regions of the current Alibaba Cloud account.
NextTokenStringNocaeba0bbb2be03f84eb48b699f0a4883

The token that is returned for the next query.

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.
ResourceTypeStringYeskey

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

  • key
  • secret
ResourceId.NStringNokey-hzz62f1cb66fa42qo****

The IDs of the resources whose tags you want to query. You can enter up to 50 resource IDs.

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

Tag.N.KeyStringNodisk-encryption

The tag key. 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 tag key cannot start with aliyun or acs:.
Tag.N.ValueStringNotrue

The tag value. 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.

Response parameters

ParameterTypeExampleDescription
NextTokenStringe71d8a535bd9cc11

The token that is returned for this call. The value is used to determine whether the token is available to start the next query.

  • If the value of this parameter is empty ("NextToken": ""), all results are returned, and the next query is not required.
  • If the value of this parameter is not empty, the next query is required, and the value is the token that is used to start the next query.
RequestIdString00827261-20B7-4562-83F2-4DF39876A45A

The request ID.

TagResourcesArray of TagResource

The tags returned.

TagResource
ResourceTypeStringkey

The resource type.

TagValueStringtrue

The tag value.

ResourceIdStringkey-hzz62f1cb66fa42qo****

The resource ID.

TagKeyStringdisk-encryption

The tag key.

Examples

Sample requests

http(s)://[Endpoint]/?Action=ListTagResources
&RegionId=cn-hangzhou
&NextToken=caeba0bbb2be03f84eb48b699f0a4883
&ResourceType=key
&ResourceId=["key-hzz62f1cb66fa42qo****"]
&Tag=[{"Key":"disk-encryption","Value":"true"}]
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<ListTagResourcesResponse>
    <NextToken>e71d8a535bd9cc11</NextToken>
    <RequestId>00827261-20B7-4562-83F2-4DF39876A45A</RequestId>
    <TagResources>
        <ResourceType>key</ResourceType>
        <TagValue>true</TagValue>
        <ResourceId>key-hzz62f1cb66fa42qo****</ResourceId>
        <TagKey>disk-encryption</TagKey>
    </TagResources>
</ListTagResourcesResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

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

Error codes

Http status codeError codeError messageDescription
400Duplicate.TagKeyThe specified tagKey is duplicate.The specified tag value is a duplicate.
404InvalidAccessKeyId.NotFoundThe Access Key ID provided does not exist in our records.The specified AccessKey ID does not exist.
404InvalidResourceId.NotFoundThe specified ResourceId is not found.The specified resource ID is not found.

For a list of error codes, see Service error codes.