All Products
Search
Document Center

Key Management Service:TagResources

Last Updated:Jul 29, 2025

Adds tags to keys or secrets.

Operation description

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

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

There is currently no authorization information disclosed in the API.

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

The region ID of the resource.

Note You can call the DescribeRegions to query the most recent region list.
cn-hangzhou
ResourceTypestringYes

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

  • key
  • secret
key
ResourceIdarrayYes

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

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

stringYes

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

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

key-hzz62f1cb66fa42qo****
Tagarray<object>Yes

A list of tags. You can enter up to 20 tags.

A tag consists of a key-value pair. Enter multiple tags in the [{"Key":"key1","Value":"value1"},{"Key":"key2","Value":"value2"},..] format.

objectYes
KeystringNo

The key of the tag. 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 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 key cannot start with aliyun or acs:.
disk-encryption
ValuestringNo

The value of the tag. 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 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 (@).

true

Response parameters

ParameterTypeDescriptionExample
object

Schema of Response

RequestIdstring

The request ID.

598d0219-45cd-4477-84ad-85a52d9debcf

Examples

Sample success responses

JSONformat

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

Error codes

HTTP status codeError codeError message
400InvalidParameter.TagValueThe specified parameter is not valid.
400InvalidParameter.TagKeyThe specified parameter is not valid.
400Duplicate.TagKeyThe specified tagKey is duplicate.
404InvalidAccessKeyId.NotFoundThe Access Key ID provided does not exist in our records.
404InvalidResourceId.NotFoundThe specified ResourceId is not found.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-05-30The Error code has changedView Change Details