Adds tags to keys or secrets.

You can add multiple tags to multiple keys or multiple secrets at a time.

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

ParameterTypeRequiredExampleDescription
ActionStringYesTagResources

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

RegionIdStringYescn-hangzhou

The ID of the region to which the resource belongs.

Note You can call the DescribeRegions operation to query a list of available regions of the current Alibaba Cloud account.
ResourceTypeStringYeskey

The type of the resource to which you want to add tags. Valid values:

  • key
  • secret
ResourceId.NStringNokey-hzz62f1cb66fa42qo****

The IDs of the resources to which you want to add tags. You can enter up to 50 resource IDs.

Enter multiple resource IDs in the ["ResourceId. 1","ResourceId. 2",...] format.

Tag.N.KeyStringNodisk-encryption

The tag key. A tag consists of a key-value pair.

You can enter up to 20 tags. Enter multiple tags in the [{"Key":"key1","Value":"value1"},{"Key":"key2","Value":"value2"},..] format.

Each tag key can be up to 128 characters in length and can contain letters, digits, forward slashes (/), backslashes (\), underscores (_), hyphens (-), periods (.), plus signs (+), equal signs (=), colons (:), and at signs (@).

Note The tag key cannot start with aliyun or acs:.
Tag.N.ValueStringNotrue

The tag value. A tag consists of a key-value pair.

You can enter up to 20 tags. Enter multiple tags in the [{"Key":"key1","Value":"value1"},{"Key":"key2","Value":"value2"},..] format.

Each tag value can be up to 128 characters in length and can contain letters, digits, forward slashes (/), backslashes (\), underscores (_), hyphens (-), periods (.), plus signs (+), equal signs (=), colons (:), and at signs (@).

Response parameters

ParameterTypeExampleDescription
RequestIdString598d0219-45cd-4477-84ad-85a52d9debcf

The request ID.

Examples

Sample requests

http(s)://[Endpoint]/?Action=TagResources
&RegionId=cn-hangzhou
&ResourceType=key
&ResourceId=["key-hzz62f1cb66fa42qo****"]
&Tag=[{"Key":"disk-encryption","Value":"true"}]
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<TagResourcesResponse>
    <RequestId>598d0219-45cd-4477-84ad-85a52d9debcf</RequestId>
</TagResourcesResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "598d0219-45cd-4477-84ad-85a52d9debcf"
}

Error codes

Http status codeError codeError messageDescription
400InvalidParameter.TagValueThe specified parameter is not valid.The specified tag value is invalid.
400InvalidParameter.TagKeyThe specified parameter is not valid.The specified tag key is invalid.
400Duplicate.TagKeyThe specified tagKey is duplicate.The specified tag value is a duplicate.
404InvalidAccessKeyId.NotFoundThe Access Key ID provided does not exist in our records.The specified AccessKey ID does not exist.
404InvalidResourceId.NotFoundThe specified ResourceId is not found.The specified resource ID is not found.

For a list of error codes, see Service error codes.