Help Center> Domain Name Service> API Reference> APIs> Tag Management> Adding a Tag to a Specific Resource
Updated on 2024-03-25 GMT+08:00

Adding a Tag to a Specific Resource

Function

This API is used to add a tag to a specific resource.

Calling Method

For details, see Calling APIs.

URI

POST /v2/{project_id}/{resource_type}/{resource_id}/tags

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID

resource_type

Yes

String

Resource type. The value can be DNS-public_zone, DNS-private_zone, DNS-public_recordset, DNS-private_recordset, or DNS-ptr_record.

resource_id

Yes

String

Resource ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token. It can be obtained by calling an 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

tag

Yes

tag object

Resource tag

Table 4 tag

Parameter

Mandatory

Type

Description

key

Yes

String

Tag key. A key can contain up to 36 Unicode characters. It cannot be left blank. A tag value cannot contain special characters (=*<>,|/) or start or end with spaces.

value

No

String

Tag value. A tag value contains a maximum of 43 Unicode characters and can be left blank. A tag value cannot contain special characters (=*<>,|/) or start or end with spaces.

Response Parameters

None

Example Requests

Adding a tag to a specified resource

POST https://{endpoint}/v2/{project_id}/{resource_type}/{resource_id}/tags

{
  "tag" : {
    "key" : "key1",
    "value" : "value1"
  }
}

Example Responses

None

Status Codes

Status Code

Description

204

Response to the request for adding a tag to a resource

Error Codes

See Error Codes.