Creates and attaches one or more tags to specified resources.

Limits

You can only bind up to 20 tags to an instance. Before you bind tags, Alibaba Cloud verifies the number of existing tags of the resource. If the number of tags bound exceeds 20, an error message will be returned.

Make the API call

You can use OpenAPI Explorer to make API calls, search for API calls, perform debugging, and generate SDK example code.

Request parameters

Parameter Type Required? Example value Description
Action String  Yes TagResources

The name of this action. Value: TagResources.

RegionId String  Yes cn-hangzhou

The ID of the region to which the resource belongs.

ResourceId.N RepeatList Yes vpc-bp16qjewdsunr41m1****

The ID of the resource. Value range of N: 1 to 20.

ResourceType String  Yes VPC

The type of the resource. Valid values:

  • VPC: Virtual Private Cloud (VPC).
  • VSWITCH: VSwitch.
  • ROUTETABLE: Route table.
  • EIP: Elastic IP address.
Tag.N.Key String No FinanceDept

The tag key of the resource. Value range of N: 1 to 20. This value cannot be a null string. It can be up to 64 characters in length and can contain numbers, periods (.), underscores (_), and hyphens (-). It must start with a letter and cannot start with aliyun or acs:. It cannot contain http:// or https://.

Tag.N.Value String No FinanceJoshua

The tag value of the resource. Value range of N: 1 to 20. This value can be a null string. It can be up to 128 characters in length and can contain letters, numbers, periods (.), underscores (_), and hyphens (-). It must start with a letter and cannot start with aliyun or acs:. It cannot contain http:// or https://.

Response parameters

Parameter Type Example value Description
RequestId String  C46FF5A8-C5F0-4024-8262-B16B639225A0

The ID of the request.

Examples

Request example

http(s)://vpc.aliyuncs.com/? Action=TagResources
&RegionId=cn-hangzhou
&ResourceId.1=vpc-bp16qjewdsunr41m1****
&ResourceType=VPC
&<CommonParameters>

Response example

XML format

<TagResourcesResponse>
      <RequestId>C46FF5A8-C5F0-4024-8262-B16B639225A0</RequestId>
</TagResourcesResponse>

JSON format

{
	"RequestId":"C46FF5A8-C5F0-4024-8262-B16B639225A0"
}

Errors

HTTP status code Error code Error message Description
403 Forbidden User not authorized to operate on the specified resource. You are not authorized to operate on this resource.

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