Attaches a tag 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
Action String Yes TagResources

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

RegionId String Yes cn-hangzhou

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

ResourceType String Yes instance

The type of the resource. Valid values:

  • INSTANCE
  • TOPIC
  • CONSUMERGROUP
Note The value of this parameter is not case-sensitive.
ResourceId.N String Yes alikafka_post-cn-v0h1fgs2****

The ID of the resource to which you want to attach a tag. Take note of the following rules when you specify a resource ID:

  • The resource ID of an instance is the value of the instanceId parameter.
  • The resource ID of a topic is the value of the Kafka_alikafka_instanceId_topic parameter.
  • The resource ID of a group is the value of the Kafka_alikafka_instanceId_consumerGroup parameter.

For example, the resources whose tags you want to query include the alikafka_post-cn-v0h1fgs2xxxx instance, the test-topic topic, and the test-consumer-group group. In this case, their resource IDs are alikafka_post-cn-v0h1fgs2xxxx, Kafka_alikafka_post-cn-v0h1fgs2xxxx_test-topic, and Kafka_alikafka_post-cn-v0h1fgs2xxxx_test-consumer-group.

Tag.N.Key String Yes FinanceDept

The key of the tag that is added to the resource.

  • Valid values of N: 1 to 20.
  • This parameter is required.
  • The tag key can be up to 128 characters in length and cannot start with aliyun or acs:. The tag key cannot contain http:// or https://.
Tag.N.Value String No FinanceJoshua

The value of the tag that is added to the resource.

  • Valid values of N: 1 to 20.
  • This parameter can be left empty.
  • The tag key can be up to 128 characters in length and cannot start with aliyun or acs:. The tag key cannot contain http:// or https://.

Response parameters

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

The ID of the request.

Example

Sample requests

http(s)://alikafka.cn-hangzhou.aliyuncs.com/?Action=TagResources
&RegionId=cn-hangzhou
&ResourceId.1=alikafka_post-cn-v0h1fgs2****
&ResourceType=INSTANCE
&Tag.1.Key=FinanceDept
&<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, visit the API Error Center.