Queries tag keys.

In this example, the tag keys in the cn-hangzhou region are queried. The returned result shows that the following tag keys exist: team, k1, and k2.

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

Parameter Type Required Example Description
Action String Yes ListTagKeys

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

RegionId String Yes cn-hangzhou

The region ID.

For more information about the region ID, see Endpoints.

NextToken String No caeba0bbb2be03f84eb48b699f0a****

The token that is used to start the next query.

PageSize Integer No 50

The number of tag keys to return on each page.

Maximum value: 1000. Default value: 50.

Category String No Custom

The type of the resource tags. Default value: All. Valid values:

  • All: all tags
  • Custom: custom tags
  • System: system tags
ResourceType String No ALIYUN::ECS::INSTANCE

The type of the resources. For more information about supported resource types, see Types of resources that support Tag API operations.

QueryType String No ResourceTag

The type of the tags. Default value: ResourceTag. Valid values:

  • ResourceTag: resource tags, including custom and system tags
  • MetaTag: preset tags

For more information about common request parameters, see Common parameters.

Response parameters

Parameter Type Example Description
Keys Array of Key

The information of the tag keys.

Key
Category String Custom

The type of the resource tags. Valid values:

  • Custom: custom tags
  • System: system tags
Description String Business team

The description of the tag key.

Key String team

The tag key.

NextToken String caeba0bbb2be03f84eb48b699f0a****

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.
RequestId String DC09A6AA-2713-4E10-A2E9-E6C5C43A8842

The ID of the request.

Examples

Sample requests

https://tag.aliyuncs.com/?Action=ListTagKeys
&RegionId=cn-hangzhou
&<Common request parameters>

Sample success responses

XML format

<ListTagKeysResponse>
      <NextToken></NextToken>
      <RequestId>DC09A6AA-2713-4E10-A2E9-E6C5C43A8842</RequestId>
      <Keys>
            <Key>
                  <Category>custom</Category>
                  <Key>team</Key>
            </Key>
            <Key>
                  <Category>custom</Category>
                  <Key>k1</Key>
            </Key>
            <Key>
                  <Category>custom</Category>
                  <Key>k2</Key>
            </Key>
      </Keys>
</ListTagKeysResponse>

JSON format

{
    "NextToken": "",
    "RequestId": "DC09A6AA-2713-4E10-A2E9-E6C5C43A8842",
    "Keys": {
        "Key": [
            {
                "Category": "custom",
                "Key": "team"
            },
            {
                "Category": "custom",
                "Key": "k1"
            },
            {
                "Category": "custom",
                "Key": "k2"
            }
        ]
    }
}

Error codes

HTTP status code Error code Error message Description
403 Invalid.NextToken The parameter NextToken is invalid. The error message returned because the value of the NextToken parameter is invalid.
403 NoPermission.Operator The user is not authorized to operate on the specified resource. The error message returned because you are not authorized to perform the operation.
403 InvalidParameter.Category The specified Category is invalid. Valid values are Custom and System. The error message returned because the value of the Category parameter is invalid. The value can be Custom or System.
403 InvalidParameter.ResourceType The ResourceType parameter is invalid. The error message returned because the value of the ResourceType parameter is invalid.

For a list of error codes, visit the API Error Center.