Creates and adds tags to specified Elastic Compute Service (ECS) resources.
Usage notes
Before you add tags to a resource, Alibaba Cloud checks the number of existing tags on the resource. If the maximum number of tags is reached, an error message is returned. For more information, see the "Tag limits" section in Limits.
Debugging
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 region ID of the resource. You can call the DescribeRegions operation to query the most recent region list. |
ResourceType | String | Yes | instance | The type of the resource. Valid values:
|
ResourceId.N | String | Yes | r-XXX | The ID of resource N. Valid values of N: 1 to 50. |
Tag.N.Key | String | Yes | TestKey | The key of tag N to add to the resource. Valid values of N: 1 to 20. The tag key cannot be an empty string. The tag key can be up to 128 characters in length and cannot contain |
Tag.N.Value | String | Yes | TestValue | The value of tag N to add to the resource. Valid values of N: 1 to 20. The tag value can be an empty string. The tag value can be up to 128 characters in length and cannot contain |
Response parameters
Parameter |
Type |
Example |
Description |
RequestId | String | 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E | The ID of the request. |
Examples
Sample requests
https://ecs.aliyuncs.com/?Action=TagResources
&RegionId=cn-hangzhou
&ResourceId.1=i-bp1j6qtvdm8w0z1o0****
&ResourceId.2=i-bp1j6qtvdm8w0z1oP****
&ResourceType=instance
&Tag.1.Key=TestKey
&<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
HTTP status code |
Error code |
Error message |
Description |
400 | Duplicate.TagKey | The Tag.N.Key contain duplicate key. | The tag key already exists. Tag keys must be unique. |
400 | InvalidTagKey.Malformed | The specified Tag.n.Key is not valid. | Invalid Tag.N.Key value. |
400 | InvalidTagValue.Malformed | The specified Tag.n.Value is not valid. | Invalid Tag.N.Value value. |
400 | OperationDenied.QuotaExceed | The quota of tags on resource is beyond permitted range. | The maximum number of tags is exceeded. |
400 | InvalidTag.Mismatch | The specified Tag.n.Key and Tag.n.Value are not match. | The specified Tag.N.Key and Tag.N.Value parameters do not correspond to each other. |
400 | InvalidTagCount | The specified tags are beyond the permitted range. | The maximum number of tags is exceeded. |
400 | Invalid.Scope | The specified scope is invalid. | Invalid Scope value. |
403 | PermissionDenied.TagOwnerUid | The specified operator not have permission to set TagOwnerUid value. | You are not authorized to specify the TagOwnerUid parameter. |
403 | PermissionDenied.Scope | The specified operator not have permission to set Scope value. | You are not authorized to specify the Scope parameter. |
403 | InvalidResourceId.NotSupported | The specified ResourceId does not support tagging. | The specified resource does not support tagging. |
403 | NoPermission.Tag | The operator is not permission for the tag. | You are not authorized to manage the tag. |
403 | QuotaExceed.Tags | %s | The maximum number of tags is exceeded. %s is a variable. An error message is dynamically returned based on call conditions. |
404 | InvalidRegionId.NotFound | %s | The specified region ID does not exist. |
404 | MissingParameter.ResourceType | The parameter - ResourceType should not be null. | ResourceType is required. |
404 | InvalidResourceId.NotFound | The specified ResourceIds are not found in our records. | The specified resource does not exist. Check whether the ResourceId parameter is correct. |
404 | InvalidResourceType.NotFound | The ResourceType provided does not exist in our records. | The specified resource type is not found. |
404 | InvalidRegionId.NotFound | The specified RegionId does not exist. | The specified region ID does not exist. |
500 | ServiceUnavailable | The service is unavailable, please try again later. | The service is temporarily unavailable. Try again later. |
For a list of error codes, see Service error codes.