Creates and attaches tags to resources.
Operation description
If you have a large number of instances, you can create multiple tags, add them to instances, and then filter instances by tag.
-
A tag consists of a key-value pair. Each key must be unique within a region for an Alibaba Cloud account. Different keys can be mapped to the same value.
-
If you specify a tag that does not exist, the tag is automatically created and added to the specified gateway.
-
If a tag to be added has the same key as an existing tag on the gateway, the new tag overwrites the existing tag.
-
You can attach up to 20 tags to each gateway.
-
You can attach tags to up to 50 gateways in an API request.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
hcs-sgw:TagResources |
update |
*All Resource
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| RegionId |
string |
Yes |
The region ID. Call the DescribeRegions operation to query region IDs. |
cn-hangzhou |
| ResourceRegionId |
string |
No |
The region ID of the resource. |
cn-hangzhou |
| ResourceType |
string |
Yes |
The type of the resource. Valid value: GATEWAY. |
GATEWAY |
| Tag |
array<object> |
Yes |
The tags. |
|
|
object |
No |
The tags. |
||
| Key |
string |
Yes |
The tag key. You can specify 1 to 20 tag keys for a gateway. The tag key cannot be an empty string. |
testkey1 |
| Value |
string |
No |
The tag value associated with the specified tag key. You can specify 1 to 20 tag values for a gateway. The tag value can be an empty string. |
testvalue1 |
| ResourceId |
array |
Yes |
The gateway IDs. You can specify 1 to 50 gateway IDs in a single request. |
|
|
string |
No |
The gateway ID. |
gw-uf6wjk5xxxxxxx |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| RequestId |
string |
The request ID. |
224DB9F7-3100-4899-AB9C-C938BCCB43E7 |
Examples
Success response
JSON format
{
"RequestId": "224DB9F7-3100-4899-AB9C-C938BCCB43E7"
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | MissingParameter.ResourceIds | The parameter - ResourceIds.N should not be null. | |
| 400 | MissingParameter.Tags | The parameter - Tags should not be null. | |
| 400 | Missing.TagKey | The Tag.N.Key parameter is blank. | |
| 400 | InvalidParameter.TagKey | The Tag.N.Key parameter is invalid. | |
| 400 | InvalidParameter.TagValue | The Tag.N.Value parameter is invalid. | |
| 400 | InvalidParameter.ResourceType | The ResourceType parameter is invalid. | |
| 400 | Duplicate.TagKey | The Tag.N.Key contain duplicate key. | |
| 400 | MissingParameter.TagOrResourceId | The specified Tags and ResourcesIds are not allow to both empty. | |
| 400 | NumberExceed.ResourceIds | The ResourceIds parameter's number is exceed , Valid : 50 | |
| 400 | NumberExceed.Tags | The Tags parameter's number is exceed , Valid : 20 | |
| 400 | QuotaExceed.TagsPerResource | The tags per resource number is exceed, Valid: 20 | |
| 403 | PermissionDenied.Scope | The specified operator not have permission to set Scope value. | |
| 403 | PermissionDenied.TagOwnerUid | The specified operator not have permission to set TagOwnerUid value. | |
| 403 | PermissionDenied.TagOwnerBid | The specified operator not have permission to set TagOwnerBid value. | |
| 403 | NoPermissionKey.Operator | These keys are not permission for this operator. | |
| 403 | NoPermissionKey.Scope | These keys are not permission for this scope. | |
| 403 | NoPermissionKey.Category | These keys are not permission for this category. | |
| 403 | NoPermission.SystemTag | The operator is not permission for the system tag. | |
| 403 | NoPermission.Operator | The operator is not permission for this operate. | |
| 404 | InvalidResourceType.NotFound | The ResourceType provided does not exist in our records. | |
| 404 | InvalidResourceId.NotFound | The specified ResourceId is not found in our records. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.