Updated on 2025-12-05 GMT+08:00

Adding a Resource Tag

Function

If there are a large number of cloud resources, you can use Tag Management Service (TMS) to manage cloud resources under your account and add resource tags.

URI

POST /v1/resources/{resource_id}/tags

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

resource_id

Yes

String

Definition

ID of the resource to which you want to add a tag.

Constraints

N/A

Range

N/A

Default value

N/A

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

tags

Yes

Array of TagResponse objects

Definition

The key-value pair of a tag.

Constraints

N/A

Range

N/A

Default value

N/A

Table 3 TagResponse

Parameter

Mandatory

Type

Description

key

Yes

String

Definition

Tag key.

Range

A tag key can contain up to 128 characters. It cannot start with sys or a space, and cannot end with a space. Only letters, digits, spaces, and the following special characters are allowed: _ . : = + - @

value

Yes

String

Definition

Tag value.

Range

A tag value can contain a maximum of 255 characters. It cannot start or end with a space. Only letters, digits, spaces, and the following special characters are allowed: _ . : / = + - @

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

data

data object

Description:

ID of the tag created.

Value range:

N/A

Table 5 data

Parameter

Type

Description

id

String

Definition

Tag ID.

Range

N/A

Status code: 400

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Definition

Error code.

Range

The value is a string. It contains 8 to 36 characters.

error_msg

String

Definition

Error description.

Range

The value is a string. It contains 2 to 512 characters.

Example Requests

Add a resource tag.

POST https://{Endpoint}/v1/resources/{resource_id}/tags

{
  "tags" : [ {
    "key" : "Test resource tag",
    "value" : "9999"
  } ]
}

Example Responses

Status code: 200

Resource tags are added.

{
  "data" : {
    "id" : "6805f787eac07d54601ab7d7"
  }
}

Status Codes

Status Code

Description

200

Resource tags are added.

400

The resource tag fails to be added.

Error Codes

See Error Codes.