Adds tags to a resource.

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
RegionId String Yes cn-hangzhou

The ID of the region in which the resource is located.

ResourceType String Yes INSTANCE

The resource type. Set the value to INSTANCE.

Action String Yes TagResources

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

Tag.N.Key String No color

The key of the tag that you want to add.

Tag.N.Value String No red

The value of the tag that you want to add.

ResourceId.N String Yes dm-hbgau1zp****

The ID of the resource.

Response parameters

Parameter Type Example Description
Success Boolean true

Indicates whether the request is successful.

RequestId String FE5D94E3-3C93-3594-95D9-AAED2A980915

The ID of the request.

Examples

Sample requests

http(s)://[Endpoint]/?RegionId=cn-hangzhou
&ResourceType=INSTANCE
&Action=TagResources
&Tag=[{"Key":"color","Value":"red"}]
&ResourceId=["dm-hbgau1zp****"]
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<TagResourcesResponse>
    <Success>true</Success>
    <RequestId>FE5D94E3-3C93-3594-95D9-AAED2A980915</RequestId>
</TagResourcesResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "Success" : true,
  "RequestId" : "FE5D94E3-3C93-3594-95D9-AAED2A980915"
}

Error codes

HttpCode Error code Error message Description
500 InternalError The request processing has failed due to some unknown error. The error message returned because an internal error has occurred and the request failed.

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