Help Center/ Global Accelerator/ API Reference/ API/ Tag/ Adding Tags to a Resource
Updated on 2023-12-06 GMT+08:00

Adding Tags to a Resource

Function

This API is used to add tags to a resource.

Calling Method

For details, see Calling APIs.

URI

POST /v1/{resource_type}/{resource_id}/tags/create

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

resource_type

Yes

Object

Specifies the resource type.

resource_id

Yes

String

Specifies the resource ID.

Minimum: 1

Maximum: 36

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Specifies the user token. The token can be obtained by calling the IAM API. The value of X-Subject-Token in the response header is the user token.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

tags

Yes

Array of ResourceTag objects

Specifies the tags.

Array Length: 1 - 20

Table 4 ResourceTag

Parameter

Mandatory

Type

Description

key

Yes

String

Specifies the tag key. The key must meet the following requirements:

  • The key can contain 1 to 128 characters.

  • The key can contain UTF-8 letters, digits, spaces, and the following characters:_.:=+-@

  • Tags starting with _sys_ are system tags and cannot be entered by tenants.

Minimum: 1

Maximum: 128

value

Yes

String

Specifies the tag value. The value must meet the following requirements:

  • The value can contain 0 to 255 characters.

  • The key can contain UTF-8 letters, digits, spaces, and the following characters:_.:/=+-@

  • The value can be empty or null.

Minimum: 0

Maximum: 255

Response Parameters

Status code: 204

Table 5 Response body parameters

Parameter

Type

Description

request_id

String

Specifies the request ID.

Example Requests

Adding tags to a resource

POST https://{ga_endpoint}/v1/{resource_type}/{resource_id}/tags/create

{
  "tags" : [ {
    "key" : "tagKey",
    "value" : "tagValue"
  } ]
}

Example Responses

Status code: 204

Operation succeeded.

{
  "request_id" : "915a14a6-867b-4af7-83d1-70efceb146f9"
}

Status Codes

Status Code

Description

204

Operation succeeded.

Error Codes

See Error Codes.