Creates tags and adds the tags to 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 added to 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

ParameterTypeRequiredExampleDescription
ActionStringYesTagResources

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

RegionIdStringYescn-hangzhou

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

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

ResourceTypeStringYesinstance

The type of the resource. Valid values:

  • instance: a CLB instance
  • certificate: a certificate
  • acl: an access control list (ACL)
  • listener: a listener
  • vservergroup: a vServer group
  • masterslaveservergroup: a primary/secondary server group
ResourceId.NStringNolb-bp16qjewdsunr41m1****

The resource ID. You can specify up to 20 IDs.

Note If you want to specify the ID of a listener, set ResourceId to a value in the LoadBalancerId_Listener protocol_Port format, where LoadBalancerId specifies the ID of the CLB instance, and Port specifies the listener port. Example: lb-bp1snb10sbml4_http_80.
Tag.N.KeyStringNoFinanceDept

The key of tag N to add to the resource. You can specify up to 20 tag keys. The tag key cannot be an empty string.

The tag key can be up to 64 characters in length, and cannot contain http:// or https://. The tag key cannot start with aliyun or acs:.

Tag.N.ValueStringNoFinanceJoshua

The value of tag N to add to the resource. You can specify up to 20 tag values. The tag value can be an empty string.

The tag value can be up to 128 characters in length, and cannot contain http:// or https://. The tag value cannot start with aliyun or acs:.

Response parameters

ParameterTypeExampleDescription
RequestIdStringC46FF5A8-C5F0-4024-8262-B16B639225A0

The request ID.

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

HttpCodeError codeError messageDescription
400TagTypeNotSameThe category of tags in the same request must be the same.The specified tags in the request are of different types.
400ResourceNotExist%s.The specified resource is not found.
400DeniedForNoneTagCreator%s.The system tag is not created by the current account.
400DeniedForScopeNotEqual%s.The key of a system tag cannot have different Scope values.
400InvalidParam.ScopeThe specified Scope is invalid.Scope is set to an invalid value. Specify a valid value and try again.
400InvalidParam.ResourceTypeThe specified ResourceType is invalid.The specified resource type is invalid. Specify a valid resource type and try again.
400InvalidParam.TagKeyThe specified TagKey is invalid.The specified tag key is invalid. Specify a valid tag key and try again.
400InvalidParam.TagValueThe specified TagValue is invalid.The specified tag value is invalid. Specify a valid tag value and try again.
400InvalidParam.TagKeyOrValueThe specified TagKey or TagValue is invalid.The specified tag key or tag value is invalid. Specify a valid key-value pair and try again.
400InvalidParam.TagOwnerUidThe specified TagOwnerUid is invalid.TagOwnerUid is set to an invalid value. Specify a valid value and try again.
400InvalidParam.TagOwnerBidThe specified TagOwnerBid is invalid.TagOwnerBid is set to an invalid value. Specify a valid value and try again.
400MissingParam.TagKeyThe parameter TagKey is required.TagKey is not specified.
400MissingParam.ScopeThe parameter Scope is required.Scope is not specified.
400MissingParam.TagOwnerUidThe parameter TagOwnerUid is required.TagOwnerUid is not specified.
400MissingParam.TagOwnerBidThe parameter TagOwnerBid is required.TagOwnerBid is not specified.
400InvalidParameter.RegionIdThe specified RegionId does not exist.The specified region ID is not found.
400DeniedForOperateCustomTag%s.You cannot modify or delete the tag with the current account.
400MissingParam.ResourceIdThe parameter ResourceId is required.ResourceId is not specified.
400Duplicate.TagKeyThe param TagKey has duplicate value.The specified tag key already exists.
400SizeLimitExceeded.ResourceIdThe maximum size of ResourceId is exceeded.The length of the specified resource ID exceeds the limit. Specify a valid resource ID and try again.
400SizeLimitExceeded.TagThe maximum size of Tag is exceeded.The length of the specified tag exceeds the limit. Specify a valid tag and try again.

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