Adds specified tags to one or more ApsaraDB for Redis instances.
If you have a large number of instances, you can create multiple tags and add these tags to the instances. Then, you can filter these instances by tag.
- A tag consists of a key and a value. Each key must be unique in a region for an Alibaba Cloud account. Different keys can be mapped to the same value.
- If the tag that you specify does not exist, this tag is automatically created and added to the specified instance.
- If the key of the specified tag is the same as that of an existing tag, the specified tag overwrites the existing tag.
- You can add up to 20 tags to each instance.
- You can add tags to up to 50 instances in each call.
You can also add tags to instances in the ApsaraDB for Redis console. For more information, see Create a tag.
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 instance. |
ResourceType | String | Yes | INSTANCE |
The resource type. Set the value to INSTANCE. |
ResourceId.N | String | Yes | r-bp1zxszhcgatnx**** |
The ID of instance N. You can specify multiple IDs. Note N specifies the serial number of the instance. For example, ResourceId.1 specifies the ID of the first instance and ResourceId.2 specifies the ID of the second instance.
|
Tag.N.Key | String | Yes | demokey |
The key of tag N. Note
|
Tag.N.Value | String | Yes | demovalue |
The value of tag N. Note N specifies the serial number of the tag. For example, Tag.1.Value specifies the value of the first tag and Tag.2.Value specifies the value of the second tag.
|
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
RequestId | String | 4BD4E308-A3D8-4CD1-98B3-0ADAEE38**** |
The ID of the request. |
Examples
Sample requests
http(s)://[Endpoint]/?Action=TagResources
&RegionId=cn-hangzhou
&ResourceId.1=r-bp1zxszhcgatnx****
&ResourceId.2=r-bp1zxszhcgatnx****
&ResourceType=INSTANCE
&Tag.1.Key=demokey1
&Tag.1.Value=demovalue1
&Tag.2.Key=demokey2
&Tag.2.Value=demovalue2
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<TagResourcesResponse>
<RequestId>4BD4E308-A3D8-4CD1-98B3-0ADAEE38****</RequestId>
</TagResourcesResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "4BD4E308-A3D8-4CD1-98B3-0ADAEE38****"
}
Error codes
For a list of error codes, visit the API Error Center.