Updated on 2025-11-10 GMT+08:00

Batch Creating or Deleting Security Group Tags

Function

This API is used to add multiple tags to or delete them from a security group at a time.

The API is idempotent.

If the request body contains duplicate keys, an error is reported. During tag creation, duplicate keys are not allowed. If a key already exists in the database, its value will be overwritten by the new duplicate key.

During tag deletion, if the tags do not exist, the deletion is considered to be successful by default. The character set of the tags will not be checked. When you delete tags, the tag structure cannot be missing, and the key cannot be left blank or be an empty string.

Constraints

The API is idempotent.

If the request body contains duplicate keys, an error is reported. During tag creation, duplicate keys are not allowed. If a key already exists in the database, its value will be overwritten by the new duplicate key.

During tag deletion, if the tags do not exist, the deletion is considered to be successful by default. The character set of the tags will not be checked. When you delete tags, the tag structure cannot be missing, and the key cannot be left blank or be an empty string.

Debugging

You can debug this API through automatic authentication in API Explorer.

URI

POST /v2.0/{project_id}/security-groups/{security_group_id}/tags/action

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID

security_group_id

Yes

String

Security Group ID

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

action

Yes

String

  • Definition:

  • Range:

    • create: Batch creating resource tags

    • delete: Batch deleting resource tags

Operation identifier.

tags

Yes

Array of ResourceTag objects

Tag list.

Table 3 ResourceTag

Parameter

Mandatory

Type

Description

key

Yes

String

  • Definition: Tag key.

  • Constraints:

    • Cannot be left blank.

    • Can contain a maximum of 128 characters.

    • Must be unique for each resource.

    • Can contain letters, digits, underscores (_), and hyphens (-).

value

Yes

String

  • Definition: Tag value.

  • Constraints:

    • Can contain a maximum of 255 characters.

    • Can contain letters, digits, underscores (_), periods (.), and hyphens (-).

Response Parameters

Status code: 204

The response to the request is normal. For more status codes, see Status Codes.

None

Example Requests

  • Set action to create to batch create two tags for a security group.

    POST https://{Endpoint}/v2.0/{project_id}/security-groups/{security_group_id}/tags/action
    
    {
      "action" : "create",
      "tags" : [ {
        "key" : "key1",
        "value" : "value1"
      }, {
        "key" : "key2",
        "value" : "value3"
      } ]
    }
  • Set action to create to batch delete two tags for a security group.

    POST https://{Endpoint}/v2.0/{project_id}/security-groups/{security_group_id}/tags/action
    
    {
      "action" : "delete",
      "tags" : [ {
        "key" : "key1",
        "value" : "value1"
      }, {
        "key" : "key2",
        "value" : "value3"
      } ]
    }

Example Responses

None

Status Codes

Status Code

Description

204

The response to the request is normal. For more status codes, see Status Codes.

Error Codes

See Error Codes.