Adds tags to the resources of various Alibaba Cloud services.
Usage notes
Tags are used to identify cloud resources. Tags allow you to categorize, search for, and aggregate cloud resources that have the same characteristics from different dimensions. This facilitates resource management. For more information, see Tag overview.
This topic provides an example on how to call the API operation to add the tags k1:v1
and k2:v2
to the virtual private cloud (VPC) vpc-bp19dd90tkt6tz7wu****
in the cn-hangzhou
region.
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 resources. |
Tags | String | Yes | null |
The key-value pairs of tags. You can specify 1 to 10 key-value pairs. If you specify multiple tags, the system adds all the tags to the specified resources. Limits:
|
ResourceARN.N | String | Yes | arn:acs:vpc:cn-hangzhou:123456789****:vpc/vpc-bp19dd90tkt6tz7wu**** |
The Alibaba Cloud Resource Names (ARNs) of the resources. For more information about supported resource types and ARN examples, see Types of resources that support Tag API operations. Valid values of N: 1 to 50. Example: ResourceARN.1 = arn:acs:${Service}:${Region}:${Account}:${ResourceType}/${ResourceId}. Note You can set ${Region} or ${Account} to an asterisk (*) to indicate the current region
or the current Alibaba Cloud account.
|
For more information about common request parameters, see Common parameters.
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
RequestId | String | 72086426-9F8C-4A60-852B-864048FD1199 |
The ID of the request. |
FailedResources | Array of FailedResource |
The information of the resources to which tags fail to be added. Note
|
|
FailedResource | |||
ResourceARN | String | arn:acs:vpc:cn-hangzhou:123456789****:vpc/vpc-bp19dd90tkt6tz7wu**** |
The ARN of the resource. |
Result | Object |
The information of the error. |
|
Code | String | InvalidResourceId.NotFound |
The error code. |
Message | String | The specified ResourceIds are not found in our records. |
The error message. |
Examples
Sample requests
https://tag.aliyuncs.com/?Action=TagResources
&RegionId=cn-hangzhou
&Tags={"k1":"v1","k2":"v2"}
&ResourceARN.1=arn:acs:vpc:cn-hangzhou:123456789****:vpc/vpc-bp19dd90tkt6tz7wu****
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<?xml version="1.0" encoding="UTF-8" ?>
<TagResourcesResponse>
<RequestId>72086426-9F8C-4A60-852B-864048FD1199</RequestId>
<FailedResources></FailedResources>
</TagResourcesResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "72086426-9F8C-4A60-852B-864048FD1199",
"FailedResources" : {
"FailedResource" : [ ]
}
}
Error codes
HTTP status code | Error code | Error message | Description |
---|---|---|---|
400 | InvalidParameter.Tags | The specified value of parameter Tags is not valid. | The error message returned because the value of the Tags parameter is invalid. |
403 | Duplicate.TagKey | The Tag.N.Key contains duplicate keys. | The error message returned because duplicate tag keys are specified. |
403 | InvalidParameter.Category | The specified Category is invalid. Valid values are Custom and System. | The error message returned because the value of the Category parameter is invalid. The value can be Custom or System. |
403 | MissingParameter.Createby | You must specify Createby. | The error message returned because the Createby parameter is not specified. |
403 | MissingParameter.ResourceIds | You must specify ResourceIds. | The error message returned because the ResourceIds parameter is not specified. |
403 | NoPermission.Operator | The user is not authorized to operate on the specified resource. | The error message returned because you are not authorized to perform the operation. |
403 | NoPermissionKey.Category | Some keys cannot be modified because the user does not have permission. | The error message returned because you are not authorized to perform operations on some tag keys. |
403 | NoPermissionKey.Operator | You are not authorized to operate the tag key. | The error message returned because you are not authorized to perform operations on the tag key. |
403 | NumberExceed.ResourceIds | The maximum number of ResourceIds is exceeded. | The error message returned because the maximum value of the ResourceIds parameter has been reached. |
403 | NumberExceed.Tags | The maximum number of Tags is exceeded. | The error message returned because the maximum value of the Tags parameter has been reached. |
403 | QuotaExceed.TagsPerResource | The maximum number of tags for each resource is exceeded. | The error message returned because the maximum number of tags for a resource has been reached. |
403 | Invalid.ResourceIdARN | The parameter ResourceIdARN is invalid. | The error message returned because the value of the ResourceARN.N parameter is invalid. |
403 | InvalidParameter.ResourceType | The ResourceType parameter is invalid. | The error message returned because the value of the ResourceType parameter is invalid. |
403 | InvalidParameter.TagKey | The Tag.N.Key parameter is invalid. | The error message returned because the value of the TagKey parameter is invalid. |
403 | InvalidParameter.TagValue | The Tag.N.Value parameter is invalid. | The error message returned because the value of the TagValue parameter is invalid. |
404 | Missing.TagKey | Tag.N.Value has been specified and you must specify Tag.N.Key. | The error message returned because the key of a tag is not specified. |
404 | MissingParameter.AliUid | You must specify AliUid. | The error message returned because the AliUid parameter is not specified. |
404 | MissingParameter.Bid | You must specify Bid. | The error message returned because the Bid parameter is not specified. |
404 | MissingParameter.TagKey | You must specify TagKey. | The error message returned because the TagKey parameter is not specified. |
For a list of error codes, visit the API Error Center.