You can call the ListTagResources operation to query tags that are attached to one or more resources.
- Tag.N is a resource tag consisting of a key-value pair: Tag.N.Key and Tag.N.Value.
- If you specify Tag.N and ResourceId.N simultaneously, ResourceId.N must match all input key-value pairs. If you specify multiple key-value pairs, the returned results are the resources that contain the specified key-value pairs.
- The query returns resource-tag associations that meet specified conditions. If there are no matching resource-tag associations, an empty list is returned.
- Users can query both user tags and visible system tags.
- In addition to specifying the required parameters, you must specify ResourceId.N to query tags that are attached to one or more resources in a region.
- In addition to specifying the required parameters, you must specify Tag.N.Key to query tags that are attached to one or more resources based on a specified key in a region.
- You must specify at least one of the ResourceId.N and Tag.N parameters.
- Tags can be of the same type or different types in a single operation.
- Users have all permissions on user tags, but only have query permissions on visible system tags.
Debugging
Request parameters
Name | Type | Required | Example | Description |
---|---|---|---|---|
NextToken | String | Yes | 1d2db86sca4384811e0b5e8707e68181f | The token for the next query. |
ResourceType | String | Yes | apiGroup | The type of the resource. Tags are bound to API groups, plug-ins, and applications. You can use tags to manage cloud resources by group. Valid values:
|
Tag.N.Key | String | Yes | env | The key of tag N. Valid values of N: |
Action | String | No | ListTagResources | The operation that you want to perform. Set the value to ListTagResources. |
ResourceId.N | RepeatList | No | 285bb759342649a1b70c2093a772e087 | The ID of resource N. Valid values of N: |
Tag.N.Value | String | No | product | The value of tag N. When Tag.N.Value is specified, Tag.N.Key must also be specified. Otherwise, an error is reported. Valid values of N: |
Response parameters
Name | Type | Example | Description |
---|---|---|---|
NextToken | String | 1d2db86sca4384811e0b5e8707e68181f | The token for the next query. If the NextToken parameter is set to -1, no next query exists. |
RequestId | String | 2D69A58F-345C-4FDE-88E4-BF5189484043 | The ID of the request. |
TagResources | Array | A collection of resources and tags, including resource IDs, resource types, and tag key-value pairs. | |
TagResource | A collection of resources and tags, including resource IDs, resource types, and tag key-value pairs. | ||
ResourceId | String | 285bb759342649a1b70c2093a772e087 | The ID of the resource. |
ResourceType | String | apiGroup | The type of the resource. |
TagKey | String | owner | The key of the tag. |
TagValue | String | zhangsan | The value of the tag. |
Examples
Sample requests
http(s)://apigateway.cn-qingdao.aliyuncs.com/? Action=ListTagResources&NextToken=1d2db86sca4384811e0b5e8707e68181f&ResourceType=apiGroup&Tag.1.Key=env&<Common request parameters>
Sample success responses
XML
format
<ListTagResourcesResponse> <RequestId>2D69A58F-345C-4FDE-88E4-BF5189484043</RequestId> <NextToken>1d2db86sca4384811e0b5e8707e68181f</NextToken> <TagResources> <TagResource> <ResourceId>285bb759342649a1b70c2093a772e087</ResourceId> <ResourceType>apiGroup</ResourceType> <TagKey>env</TagKey> <TagValue>product</TagValue> </TagResource> <TagResource> <ResourceId>285bb759342649a1b70c2093a772e087</ResourceId> <ResourceType>apiGroup</ResourceType> <TagKey>owner</TagKey> <TagValue>zhangsan</TagValue> </TagResource> </TagResources></ListTagResourcesResponse>
JSON
format
{“TagResources”:{“TagResource”:[{“ResourceType”:”apiGroup”,“TagValue”:”product”,“ResourceId”:”285bb759342649a1b70c2093a772e087”,“TagKey”:”env”},{“ResourceType”:”apiGroup”,“TagValue”:”zhangsan”,“ResourceId”:”285bb759342649a1b70c2093a772e087”,“TagKey”:”owner”}]},“NextToken”:”1d2db86sca4384811e0b5e8707e68181f”,“PageSize”:1,“RequestId”:”2D69A58F-345C-4FDE-88E4-BF5189484043”}
Error codes
For a list of error codes, visit the API Error Center.
</article>
</main>