Creates tags and adds the tags to specified resources.

Note You can add up to 20 tags to each instance. Before you add tags to a resource, Alibaba Cloud checks the number of existing tags of the resource. If the quota is reached, an error message is returned.

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 TagResources

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

RegionId String Yes cn-hangzhou

The ID of the region where the Classic Load Balancer (CLB) instance is created.

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

ResourceType String Yes instance

The type of the resource. Valid values:

  • instance: a CLB instance
  • certificate: a certificate
  • acl: a network access control list (ACL)
ResourceId.N String Yes lb-bp16qjewdsunr41m1****

The ID of the resource. You can specify at most 20 IDs.

Tag.N.Key String No FinanceDept

The key of the tag. You can specify at most 20 tag keys. The tag key cannot be an empty string.

It can be at most 64 characters in length, and cannot contain http:// or https://. It must not start with aliyun or acs:.

Tag.N.Value String No FinanceJoshua

The value of the tag. You can specify at most 20 tag values. The tag value can be an empty string.

It can be at most 128 characters in length, and cannot contain http:// or https://. It must not start with aliyun or acs:.

Response parameters

Parameter Type Example Description
RequestId String C46FF5A8-C5F0-4024-8262-B16B639225A0

The ID of the request.

Examples

Sample requests

http(s)://[Endpoint]/?Action=TagResources
&RegionId=cn-hangzhou
&ResourceType=instance
&ResourceId=["lb-bp16qjewdsunr41m1****"]
&Tag=[{"Key":"FinanceDept","Value":"FinanceJoshua"}]
&Common request parameters

Sample success responses

XML format

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

<TagResourcesResponse>
    <RequestId>C46FF5A8-C5F0-4024-8262-B16B639225A0</RequestId>
</TagResourcesResponse>

JSON format

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

{
  "RequestId" : "C46FF5A8-C5F0-4024-8262-B16B639225A0"
}

Error codes

HttpCode Error code Error message Description
400 TagTypeNotSame The category of tags in the same request must be the same. The error message returned because the specified tags in the request are of different types.
400 ResourceNotExist %s. The error message returned because the specified resource does not exist.
400 DeniedForNoneTagCreator %s. The error message returned because the system tag is not created by the current account.
400 DeniedForScopeNotEqual %s. The error message returned because the key of a system tag cannot have different Scope values.
400 QuotaLimitExceeds %s. The error message returned because the resource quota is exhausted.
400 InvalidParam.Scope The specified Scope is invalid. The error message returned because the specified Scope is invalid. Specify a valid value and try again.
400 InvalidParam.ResourceType The specified ResourceType is invalid. The error message returned because the specified resource type is invalid. Specify a valid value and try again.
400 InvalidParam.TagKey The specified TagKey is invalid. The error message returned because the specified tag key is invalid. Specify a valid value and try again.
400 InvalidParam.TagValue The specified TagValue is invalid. The error message returned because the specified tag value is invalid. Specify a valid value and try again.
400 InvalidParam.TagKeyOrValue The specified TagKey or TagValue is invalid. The error message returned because the specified tag key or tag value is invalid. Specify a valid value and try again.
400 InvalidParam.TagOwnerUid The specified TagOwnerUid is invalid. The error message returned because the TagOwnerUid parameter is invalid. Specify a valid value and try again.
400 InvalidParam.TagOwnerBid The specified TagOwnerBid is invalid. The error message returned because the TagOwnerBid parameter is invalid. Specify a valid value and try again.
400 MissingParam.TagKey The parameter TagKey is required. The error message returned because the tag key is not specified.
400 MissingParam.Scope The parameter Scope is required. The error message returned because the Scope parameter is not specified.
400 MissingParam.TagOwnerUid The parameter TagOwnerUid is required. The error message returned because the TagOwnerUid parameter is not specified.
400 MissingParam.TagOwnerBid The parameter TagOwnerBid is required. The error message returned because the TagOwnerBid parameter is not specified.
400 InvalidParameter.RegionId The specified RegionId does not exist. The error message returned because the specified region ID does not exist.
400 DeniedForOperateCustomTag %s. The error message returned because you cannot modify or delete the tag with the current account.
400 MissingParam.ResourceId The parameter ResourceId is required. The error message returned because the ResourceId parameter is not specified.
400 Duplicate.TagKey The param TagKey has duplicate value. The error message returned because the specified tag key already exists.
400 SizeLimitExceeded.ResourceId The maximum size of ResourceId is exceeded. The error message returned because the length of the specified resource ID exceeds the limit. Specify a valid value and try again.
400 SizeLimitExceeded.Tag The maximum size of Tag is exceeded. The error message returned because the length of the specified tag key exceeds the limit. Specify a valid value and try again.

For a list of error codes, visit the API Error Center.