Help Center/ Config/ API Reference/ APIs/ Resource Tags/ Batch Adding Resource Tags
Updated on 2025-03-04 GMT+08:00

Batch Adding Resource Tags

Function

This API is idempotent and is used to batch add or delete tags for a specified resource. You can add up to 20 tags to a resource.

Note: This api supports only resource type of Config. Currently, resource_type supports only config:policyAssignments.

Calling Method

For details, see Calling APIs.

URI

POST /v1/resource-manager/{resource_type}/{resource_id}/tags/create

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

resource_type

Yes

String

Resource type.

resource_id

Yes

String

Resource ID.

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

tags

No

Array of ResourceTag objects

Specifies tags. For tenant permissions, this parameter is mandatory. For the op_service permission, choose either this parameter or sys_tags.

Array Length: 1 - 20

Table 3 ResourceTag

Parameter

Mandatory

Type

Description

key

Yes

String

Tag key. A tag key can contain up to 128 Unicode characters and must comply with the character set specifications in section 3.1.

Minimum: 1

Maximum: 128

value

Yes

String

Tag value. A tag value can contain up to 255 Unicode characters and must comply with the character set specifications in section 3.2.

Minimum: 0

Maximum: 255

Response Parameters

Status code: 400

Table 4 Response body parameters

Parameter

Type

Description

error_code

String

Specifies the error code.

error_msg

String

Specifies the error message.

Status code: 401

Table 5 Response body parameters

Parameter

Type

Description

error_code

String

Specifies the error code.

error_msg

String

Specifies the error message.

Status code: 403

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Specifies the error code.

error_msg

String

Specifies the error message.

Status code: 404

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Specifies the error code.

error_msg

String

Specifies the error message.

Status code: 500

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Specifies the error code.

error_msg

String

Specifies the error message.

Example Requests

Adding Tags to Specified Instances in Batches

POST https://{endpoint}/v1/resource-manager/{resource_type}/{resource_id}/tags/create

{
  "tags" : [ {
    "key" : "key1",
    "value" : "value1"
  }, {
    "key" : "key2",
    "value" : "value2"
  } ]
}

Example Responses

None

Status Codes

Status Code

Description

204

No content.

400

Invalid parameter.

401

Unauthorized.

403

Forbidden.

404

Resources not found.

500

Internal server error.

Error Codes

See Error Codes.