All Products
Search
Document Center

Key Management Service:TagResources

Last Updated:Mar 12, 2026

Adds tags to one or more keys or secrets.

Operation description

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

For more information about the access policy required by a RAM user or RAM role to call this API, see Resource Access Management.

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

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID of the resource.

Note

You can call the DescribeRegions to query the most recent region list.

cn-hangzhou

ResourceType

string

Yes

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

  • key

  • secret

key

ResourceId

array

Yes

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.

string

No

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****

Tag

array<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.

object

No

Key

string

No

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

Value

string

No

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 elements

Element

Type

Description

Example

object

Schema of Response

RequestId

string

The request ID.

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

Examples

Success response

JSON format

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

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidParameter.TagValue The specified parameter is not valid.
400 InvalidParameter.TagKey The specified parameter is not valid.
400 Duplicate.TagKey The specified tagKey is duplicate.
404 InvalidAccessKeyId.NotFound The Access Key ID provided does not exist in our records.
404 InvalidResourceId.NotFound The specified ResourceId is not found.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.