Creates and adds tags to Elastic Compute Service (ECS) resources.
Operation description
Usage notes
Before you add tags to a resource, Alibaba Cloud checks the number of existing tags of the resource. If the maximum number of tags is reached, an error message is returned. For more information, see Tag limits.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
ecs:TagResources |
create |
DedicatedHost
Disk
NetworkInterface
Image
Instance
KeyPair
LaunchTemplate
ReservedInstance
SecurityGroup
Snapshot
AutoSnapshotPolicy
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| RegionId |
string |
Yes |
The region ID of the resource. You can call the DescribeRegions operation to query the most recent list of regions. |
cn-hangzhou |
| RegionId |
string |
Yes |
The region ID of the resource. You can call the DescribeRegions operation to query the most recent list of regions. |
cn-hangzhou |
| ResourceType |
string |
Yes |
The type of the resource to which the tags are added. Valid values:
|
instance |
| ResourceId |
array |
Yes |
Resource IDs. You can specify up to 50 resource IDs. |
i-bp67acfmxazb4ph**** |
|
string |
No |
The ID of resource N. |
r-XXX |
|
| Tag |
array<object> |
Yes |
The tags of the reserved instance. You can specify up to 20 tags. If you specify multiple tags, the tag keys cannot be duplicated.`` |
|
|
object |
No |
Tag N. |
||
| Key |
string |
Yes |
The tag key cannot be null or an empty string. The tag key can be up to 128 characters in length and cannot start with |
TestKey |
| Value |
string |
Yes |
The value of tag N. The tag value cannot be null and can be an empty string. The tag key can be up to 128 characters in length and cannot contain |
TestValue |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| RequestId |
string |
The ID of the request. |
473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E |
Examples
Success response
JSON format
{
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | NumberExceed.ResourceIds | The ResourceIds parameter's number is exceed , Valid : 50. | The number of ResourceIds parameters specified exceeds the limit. |
| 400 | NumberExceed.Tags | The Tags parameter's number is exceed , Valid : 20. | The number of labels specified exceeds the limit. |
| 400 | Duplicate.TagKey | The Tag.N.Key contain duplicate key. | The specified tag key already exists. Tag keys must be unique. |
| 400 | InvalidTagKey.Malformed | The specified Tag.n.Key is not valid. | The specified Tag.N.Key parameter is invalid. |
| 400 | InvalidTagValue.Malformed | The specified Tag.n.Value is not valid. | The specified tag value is invalid. |
| 400 | OperationDenied.QuotaExceed | The quota of tags on resource is beyond permitted range. | |
| 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 number of specified tags exceeds the upper limit. |
| 400 | Invalid.Scope | The specified scope is invalid. | |
| 500 | ServiceUnavailable | The service is unavailable, please try again later. | |
| 403 | PermissionDenied.TagOwnerBid | The specified operator not have permission to set TagOwnerBid 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. | |
| 403 | NoPermissionKey.Scope | %s | |
| 403 | NoPermission.Tag | The operator is not permission for the tag. | You are not authorized to manage the tag. |
| 403 | QuotaExceed.Tags | %s | The number of specified tags exceeds the upper limit. %s is a variable. An error message is dynamically returned based on call conditions. |
| 403 | TagKey.Duplication | The TagKey has duplication with others, case-insensitive. | Duplicate values exist in the specified Tag.N.Key parameter. The value of this parameter is not case sensitive. Check whether duplicate parameter values are passed in. |
| 404 | InvalidRegionId.NotFound | The RegionId provided does not exist in our records. | Region information error |
| 404 | MissingParameter.ResourceIds | The parameter - ResourceIds.N should not be null. | |
| 404 | MissingParameter.TagOwnerUid | The parameter - TagOwnerUid should not be null. | |
| 404 | MissingParameter.TagOwnerBid | The parameter - TagOwnerBid should not be null. | |
| 404 | MissingParameter.ResourceType | The parameter - ResourceType should not be null. | The ResourceType parameter is required. |
| 404 | MissingParameter.Tags | The parameter - Tags should not be null. | |
| 404 | MissingParameter.RegionId | The parameter - RegionId should not be null. | |
| 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 does not exist. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.