All Products
Search
Document Center

Virtual Private Cloud:ListTagResources

Last Updated:Dec 02, 2025

Queries the tags that are associated with resources.

Operation description

Usage notes

  • You must specify at least ResourceId.N or Tag.N (Tag.N.Key and Tag.N.Value) in a request to identify the resources to query.

  • Tag.N is a resource tag that consists of a key-value pair. If you specify only Tag.N.Key, all tag values associated with the tag key are returned. An error is returned if you specify only Tag.N.Value.

  • If you specify both Tag.N and ResourceId.N, the query returns only the resources that are specified by ResourceId.N and are associated with all the specified tag key-value pairs.

  • If you specify multiple tag key-value pairs, the query returns only resources that are associated with all the specified key-value pairs.

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

vpc:ListTagResources

list

Ipam

acs:vpc:{#regionId}:{#accountId}:ipam/{#IpamId}

IpamPool

acs:vpc:{#regionId}:{#accountId}:ipampool/{#IpamPoolId}

IpamScope

acs:vpc:{#regionId}:{#accountId}:ipamscope/{#IpamScopeId}

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID of the resource.

cn-hangzhou

ResourceId

array

No

The resource IDs.

string

No

The resource ID. You can specify up to 50 resource IDs.

Note

You must specify ResourceId.N or Tag.N (Tag.N.Key and Tag.N.Value).

ipam-ccxbnsbhew0d6t****

ResourceType

string

Yes

The resource type. Valid values:

  • IPAM: IPAM

  • IPAMSCOPE: IPAM scope

  • IPAMPOOL: IPAM address pool

IPAM

Tag

array<object>

No

The tags.

object

No

The tags.

Key

string

No

The tag key. You can specify up to 20 tag keys. The tag key cannot be an empty string.

The tag key can be up to 64 characters in length. It must start with a letter or a Chinese character and can contain digits, periods (.), underscores (_), and hyphens (-). The tag key cannot start with aliyun or acs: and cannot contain http:// or https://.

Note

You must specify ResourceId.N or Tag.N (Tag.N.Key and Tag.N.Value).

FinanceDept

Value

string

No

The tag value. You can specify up to 20 tag values. The tag value can be an empty string.

The tag value can be up to 128 characters in length and cannot contain http:// or https://.

Note

You must specify ResourceId.N or Tag.N (Tag.N.Key and Tag.N.Value).

FinanceJoshua

NextToken

string

No

The token that is used for the next query. Valid values:

  • You do not need to specify this parameter for the first query.

  • For a subsequent query, set this parameter to the NextToken value returned from the last API call.

FFmyTO70tTpLG6I3FmYAXGKPd****

MaxResults

integer

No

The number of entries to return on each page. Valid values: 1 to 50. Default value: 10.

20

Response elements

Element

Type

Description

Example

object

The response.

TagResources

array<object>

The details of the resources and their tags.

object

The details of the resources and their tags.

TagKey

string

The tag key.

FinanceDept

TagValue

string

The tag value.

FinanceJoshua

ResourceId

string

The resource ID.

ipam-uq5dcfc2eqhpf4****

ResourceType

string

The resource type. Valid values:

  • IPAM: IPAM

  • IPAMSCOPE: IPAM scope

  • IPAMPOOL: IPAM address pool

IPAM

NextToken

string

The token that is used for the next query. Valid values:

  • If NextToken is empty, no more results are returned.

  • If a value is returned for NextToken, the value is the token that is used for the next query.

FFmyTO70tTpLG6I3FmYAXGKPd****

RequestId

string

The request ID.

672053AB-90C9-5693-AB96-458F137A5ED6

Examples

Success response

JSON format

{
  "TagResources": [
    {
      "TagKey": "FinanceDept",
      "TagValue": "FinanceJoshua",
      "ResourceId": "ipam-uq5dcfc2eqhpf4****",
      "ResourceType": "IPAM"
    }
  ],
  "NextToken": "FFmyTO70tTpLG6I3FmYAXGKPd****",
  "RequestId": "672053AB-90C9-5693-AB96-458F137A5ED6"
}

Error codes

HTTP status code

Error code

Error message

Description

400 IllegalParamSize.ResourceIds The number of Param ResourceIds exceeded the limit. The number of ResourceIds parameters passed in exceeds the limit.
400 IllegalParamSize.Tags The number of Parameter Tags exceeded the limit. The number of ResourceIds parameters passed in exceeds the limit.
400 MissingParameter.ResourceIds The input parameter ResourceIds that is mandatory for processing this request is not supplied. Parameter ResourceIds not passed in.
400 MissingParameter.ResourceType The input parameter ResourceType that is mandatory for processing this request is not supplied. Parameter ResourceType not passed in.
400 MissingParameter.TagsAndResourceIds The input parameter Tags and ResourceIds that is mandatory for processing this request is not supplied. The Tags and ResourceIds parameters are not passed in.
400 MissingParameter.Tags The input parameter Tags that is mandatory for processing this request is not supplied. Parameter ResourceType not passed in.
400 DuplicatedParam.TagKey TagKey duplicate. TagKey parameter duplicate
400 IllegalParam.TagKey The input parameter TagKey is invalid. Illegal parameter TagKey.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.