You can call this operation to bind tags to one or more ApsaraDB for Redis instances.

If you have a large number of instances, you can classify them by creating multiple tags and binding these tags to your instances. Then, you can filter your 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 a specified tag does not exist, the tag is created and bound to the specified instances.
  • 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 bind up to 20 tags to an instance.
  • You can bind tags to up to 50 instances in each call.

You can also bind tags to instances in the console. For more information, see Create a tag.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String No TagResources

The operation that you want to perform. Set the value to TagResources.

RegionId String Yes cn-hangzhou

The ID of the region where the specified instance is located. You can call the DescribeRegions operation to query the latest regions.

ResourceId.N RepeatList Yes r-hp3xxxxxxxxxxxxx

The ID of the specified instance. You can specify multiple IDs.

Note For more information about how to specify multiple IDs, see the sample request.
ResourceType String Yes INSTANCE

The type of the specified resource. Set the value to INSTANCE.

Tag.N.Key String No demokey

The key of tag N.

Note For more information about how to specify the tag key, see the sample request.
Tag.N.Value String No demovalue

The value of tag N.

Note For more information about how to specify the tag value, see the sample request.

Response parameters

Parameter Type Example Description
RequestId String 4BD4E308-A3D8-4CD1-98B3-0ADAEE38B01B

The ID of the request.

Examples

Sample requests

https://r-kvstore.aliyuncs.com/
? Action=TagResources
&RegionId=cn-huhehaote
&ResourceId.1=r-hp1xxxxxxxxxxxxx
&ResourceId.2=r-hp2xxxxxxxxxxxxx
&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

<TagResourcesResponse>
      <RequestId>4BD4E308-A3D8-4CD1-98B3-0ADAEE38B01B</RequestId>
</TagResourcesResponse>

JSON format

{
	"RequestId": "4BD4E308-A3D8-4CD1-98B3-0ADAEE38B01B"
}

Error codes

For a list of error codes, visit the API Error Center.