• Virtual Private Cloud

vpc
  1. Help Center
  2. Virtual Private Cloud
  3. API Reference
  4. APIs
  5. VPC Tag Management
  6. Batch Creating or Deleting VPC Tags

Batch Creating or Deleting VPC Tags

Function

This interface is used to add multiple tags to or delete multiple tags from a VPC at a time. In the URI, project_id indicates the project ID, and vpc_id indicates the target VPC ID.

This API is idempotent.

If there are duplicate keys in the request body when you add tags, an error is reported.

During tag creation, duplicate keys are not allowed. If a key exists in the database, its value will be overwritten.

When tags are being deleted and some tags do not exist, the operation is considered 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.

URI

POST /v2.0/{project_id}/vpcs/{vpc_id}/tags/action

Request Message

Request parameter

Table 1 Request parameter

Parameter

Type

Mandatory

Description

tags

List<resource_tag>

Yes

Specifies the tag list.

action

String

Yes

Specifies the operation to perform. The value can be create or delete.

Table 2 resource_tag field description

Name

Mandatory

Type

Constraint

Description

key

Yes

String

  • Cannot be left blank.
  • Can contain a maximum of 36 characters.
  • Can contain only the following character types:
    • Uppercase letters
    • Lowercase letters
    • Digits
    • Special characters, including hyphens (-) and underscores (_)

Specifies the tag key.

The tag key of a VPC must be unique.

value

(This parameter is mandatory when action is set to create and optional when action is set to delete.)

String

  • Can contain a maximum of 43 characters.
  • Can contain only the following character types:
    • Uppercase letters
    • Lowercase letters
    • Digits
    • Special characters, including hyphens (-) and underscores (_)

Specifies the tag value list.

Example request

POST /v2.0/{project_id}/vpcs/{vpc_id}/tags/action

Request Body

{
    "action": "create",
    "tags": [
        {
            "key": "key1",
            "value": "value1"
        },
        {
            "key": "key2",
            "value": "value3"
        }
    ]
}
{
    "action": "delete",
    "tags": [
        {
            "key": "key1",
            "value": "value1"
        },
        {
            "key": "key2",
            "value": "value3"
        }
    ]
}

Response Message

Response parameter

None

Example response

None

Status Codes

Returned Value

Description

204

No Content

Error Codes

For details, see section VPC Tag Error Codes.