All Products
Search
Document Center

Resource Management:ListTagKeys

Last Updated:Mar 30, 2026

Queries tag keys.

Operation description

This topic provides an example on how to call the API operation to query the tag keys in the cn-hangzhou region. The response shows that the following tag keys exist: team, k1, and k2.

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

tag:ListTagKeys

get

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID.

For more information about region IDs, see Endpoints.

cn-hangzhou

RegionId

string

Yes

The region ID.

For more information about region IDs, see Endpoints.

cn-hangzhou

NextToken

string

No

The token that is used to start the next query.

caeba0bbb2be03f84eb48b699f0a****

PageSize

integer

No

The number of tag keys to return on each page.

Maximum value: 1000. Default value: 50.

50

Category

string

No

The type of the resource tags. This parameter specifies a filter condition for the query. Valid values:

  • all (default value)

  • custom

  • system

Note

The value of this parameter is not case-sensitive.

all

ResourceType

string

No

The resource type. This parameter specifies a filter condition for the query.

Format: ALIYUN::${ProductCode}::${ResourceType}. All letters in the value of this parameter must be in uppercase.

  • ProductCode: the service code. You can set this field to a value obtained from the response of the ListSupportResourceTypes operation.

  • ResourceType: the resource type. You can set this field to a value obtained from the response of the ListSupportResourceTypes operation.

ALIYUN::ECS::INSTANCE

QueryType

string

No

The category of the tags. This parameter specifies a filter condition for the query. Valid values:

  • ResourceTag: resource tags, including custom and system tags. This is the default value.

  • MetaTag: preset tags.

Note

The value of this parameter is not case-sensitive.

ResourceTag

FuzzyType

string

No

The type of the query. Valid values:

  • EQUAL (default): exact match

  • PREFIX: prefix-based fuzzy match

EQUAL

TagFilter.Key

string

No

The tag key for a fuzzy query.

This parameter is used together with the FuzzyType parameter.

team

Response elements

Element

Type

Description

Example

object

The response parameters.

NextToken

string

Indicates whether the next query is required. The value of this parameter may be empty.

  • 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 used to start the next query.

caeba0bbb2be03f84eb48b699f0a****

RequestId

string

The ID of the request.

DC09A6AA-2713-4E10-A2E9-E6C5C43A8842

Keys

object

Key

array<object>

The information of the tag keys.

object

The information of the tag keys.

Key

string

The tag key.

team

Category

string

The type of the resource tag. Valid values:

  • custom

  • system

custom

Description

string

The description of the tag key.

Business team

Examples

Success response

JSON format

{
  "NextToken": "caeba0bbb2be03f84eb48b699f0a****",
  "RequestId": "DC09A6AA-2713-4E10-A2E9-E6C5C43A8842",
  "Keys": {
    "Key": [
      {
        "Key": "team",
        "Category": "custom",
        "Description": "Business team"
      }
    ]
  }
}

Error codes

HTTP status code

Error code

Error message

Description

400 FuzzyQuery.NotSupport The fuzzy query is not supported.
403 Invalid.NextToken The parameter NextToken is invalid. The parameter NextToken is invalid.
403 NoPermission.Operator The user is not authorized to operate on the specified resource. The user is not authorized to operate on the specified resource.
403 InvalidParameter.Category The specified Category is invalid. Valid values are Custom and System. The specified Category is invalid. Valid values are Custom and System.
403 InvalidParameter.ResourceType The ResourceType parameter is invalid. The ResourceType parameter is invalid.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.