Creates tags and adds the tags to specified Resource Orchestration Service (ROS) resources.

This topic provides an example on how to create a tag and add the tag to a resource in a stack. In this example, the resource ID is 7fee80e1-8c48-4c2f-8300-0f6dc40b****, the tag key is FinanceDept, and the tag value is FinanceJoshua.

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 Yes TagResources

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

RegionId String Yes cn-hangzhou

The region ID of the tag. You can call the DescribeRegions operation to query the most recent region list.

ResourceType String Yes stack

The type of the resource to which you want to add the tag. Valid values:

  • stack: stack
  • stackgroup: stack group
  • template: template
  • TemplateScratch: scenario
ResourceId.N String Yes 7fee80e1-8c48-4c2f-8300-0f6dc40b****

The ID of resource N. You can specify up to 50 resource IDs.

Note If you set the ResourceType parameter to stackgroup, you must use the name of the stack group as the resource ID.
Tag.N.Key String Yes FinanceDept

The key of tag N that you want to add to the resource. You can specify up to 20 tag keys.

The tag key can be up to 128 characters in length, and cannot contain http:// or https://. The tag value cannot start with aliyun or acs:.

Tag.N.Value String Yes FinanceJoshua

The value of tag N that you want to add to the resource. You can specify up to 20 tag values.

The tag value can be up to 128 characters in length, and cannot contain http:// or https://. The tag value cannot start with aliyun or acs:.

For more information about common request parameters, see Common parameters.

Response parameters

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

The ID of the request.

Examples

Sample requests

http(s)://ros.aliyuncs.com/?Action=TagResources
&RegionId=cn-hangzhou
&ResourceId.1=7fee80e1-8c48-4c2f-8300-0f6dc40b****
&ResourceType=stack
&Tag.1.Key=FinanceDept
&Tag.1.Value=FinanceJoshua
&<Common request parameters>

Sample success responses

XML format

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

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

JSON format

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

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

Error codes

For a list of error codes, see Service error codes.

HTTP status code

Error code

Error message

Description

400

InvalidParameter

The specified parameter ResourceType is invalid, {reason}.

The error message returned because the specified ResourceType parameter is invalid. reason indicates the cause of the error.

400

InvalidParameter

The specified parameter ResourceIds is invalid, {reason}.

The error message returned because the specified resource IDs do not exist, or failed to be validated. reason indicates the cause of the error.

400

InvalidParameter

The specified parameter Tags is invalid, {reason}.

The error message returned because the specified Tag.N parameter is invalid. reason indicates the cause of the error.

400

Duplicate.TagKey

The Tag.N.Key contain duplicate key.

The error message returned because the specified tag key already exists. Specify a unique tag key.