You can call this operation to add or modify the tags of a CMK.

Description

A CMK can have more than one tag. A tag is defined by a pair of tag key and tag value.

Note You can add up to 10 tags for each CMK.

For more information about tag keys and tag values, see Tag description.

Request format

KeyId="string"&Tags=[{ "TagKey": "string","TagValue": "string"} ]

Request parameters

Parameter Type Required? Example Description
KeyId String Yes external key id The GUID of the key.
Tags JSON Yes [{"TagKey": "Project", "TagValue": "Test"}]

One or more tags. Format: tag array. Each Tag consists of a pair of:

  • TagKey: the tag key.
  • TagValue: the tag value.

For more information about tag keys and tag values, see Tag description.

Tag description

Parameter Type Required? Example Description
TagKey String Yes Project

The tag key.

It must be 1 to 128 characters in length.

It can contain uppercase and lowercase letters, digits, forward slashes (/), underscores (_), hyphens (-), periods (.), plus signs (+), equal signs (=), at signs (@), and semicolons (:).

TagValue String Yes Test

The tag value.

It can be up to 256 characters in length.

It can contain uppercase and lowercase letters, digits, forward slashes (/), underscores (_), hyphens (-), periods (.), plus signs (+), equal signs (=), at signs (@), and semicolons (:).

Note Tag keys of a CMK must be unique. When you call TagResource and specify an existing tag key, the current specified tag value will overwrite the original tag value.

Sample requests

https://kms.cn-hangzhou.aliyuncs.com/?Action=TagResource
&KeyId=<external key id>
&Tags=<tags> 
&<Common request parameters>

Response parameters

Parameter Type Example Description
RequestId String 4162a6af-bc99-40b3-a552-89dcc8aaf7c8 The request ID.

Sample responses

JSON format

{
    "RequestId": "4162a6af-bc99-40b3-a552-89dcc8aaf7c8"
}

XML format

<KMS> 
  <RequestId>4162a6af-bc99-40b3-a552-89dcc8aaf7c8</RequestId> 
</KMS>