All Products
Search
Document Center

Key Management Service:TagResource

更新時間:Jun 14, 2024

Adds tags to a key, secret, or certificate.

You can add up to 10 tags to a key, secret, or certificate.

In the following example, a key whose ID is key-hzz630494463ejqjx**** is used.The [{"TagKey":"S1key1","TagValue":"S1val1"},{"TagKey":"S1key2","TagValue":"S2val2"}] tags are added to the key.

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 TagResource

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

KeyId String No key-hzz630494463ejqjx****

The ID, alias, or Alibaba Cloud Resource Name (ARN) of the key. For more information, see Manage a key alias.

Note
  • When you access a key within another Alibaba Cloud account, you must enter the ARN of the key. The key ARN is in the acs:kms:${region}:${account}:key/${keyid} format.
  • You can configure only one of the following parameters: KeyId, SecretName, or CertificateId.
Tags String Yes [{"TagKey":"S1key1","TagValue":"S1val1"},{"TagKey":"S1key2","TagValue":"S2val2"}]

One or more tags that you want to add. The value is in the array format.

Tag attributes:

  • TagKey: the tag key.
  • TagValue: the tag value.
SecretName String No MyDbC****

The secret name.

Note You can configure only one of the following parameters: KeyId, SecretName, or CertificateId.
CertificateId String No 770dbe42-e146-43d1-a55a-1355db86****

The certificate ID.

Note You can configure only one of the following parameters: KeyId, SecretName, or CertificateId.

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

Response parameters

Parameter

Type

Example

Description

RequestId String 4162a6af-bc99-40b3-a552-89dcc8aaf7c8

The request ID.

Examples

Sample requests

http(s)://[Endpoint]/?Action=TagResource
&KeyId=key-hzz630494463ejqjx****
&Tags=[{"TagKey":"S1key1","TagValue":"S1val1"},{"TagKey":"S1key2","TagValue":"S2val2"}]
&SecretName=MyDbC****
&CertificateId=770dbe42-e146-43d1-a55a-1355db86****
&Common request parameters

Sample success responses

XML format

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

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

JSON format

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

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

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidParameter The specified parameter is not valid. The specified parameter is invalid.

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