Updated on 2025-08-20 GMT+08:00

Deleting ECSs

Function

This API is used to delete ECSs based on a specified ECS ID list.

This API is an asynchronous API. After the deletion request is successfully delivered, a job ID is returned. This does not mean the deletion is complete. You need to call the API by referring to Querying Job Execution Status to query the job status. The SUCCESS status indicates that the deletion is successful.

You can delete a single ECS or multiple ECSs in a batch. A maximum of 1,000 ECSs can be deleted in a batch.

Only ECSs billed in the pay-per-use mode can be deleted.

URI

POST /v1/{project_id}/cloudservers/delete

Table 1 describes the parameters in the URI.
Table 1 Parameter description

Parameter

Mandatory

Description

project_id

Yes

Specifies the project ID.

For details about how to obtain the ID, see Obtaining a Project ID.

Request

Table 2 describes the request parameters.
Table 2 Request parameters

Parameter

Mandatory

Type

Description

servers

Yes

Array of objects

Definition

Specifies the ECSs to be deleted. For details, see Table 3.

Constraints

A maximum of 1,000 ECSs can be deleted at a time.

Range

N/A

Default Value

N/A

delete_publicip

No

Boolean

Definition

Specifies whether to delete the EIP bound to the ECS when deleting the ECS. If you do not want to delete the EIP, the system only unbinds the EIP from the ECS and reserves the EIP.

Constraints

If delete_publicip is not specified, the delete_on_termination value of the EIP decides whether the EIP is released when the ECS is deleted.

  • If delete_on_termination is true and delete_public is null, the EIP is released when the ECS is deleted.
  • If delete_on_termination is false and delete_public is null, the EIP is only unbound from the ECS and will not be released when the ECS is deleted.

Range

  • true: When an ECS is deleted, the EIP bound to the ECS is also released regardless of whether delete_on_termination of the EIP is true or false.
  • false: When an ECS is deleted, the EIP is only unbound from the ECS and will not be released regardless of whether delete_on_termination of the EIP is true or false.

Default Value

false

delete_volume

No

Boolean

Definition

Specifies whether to delete the data disks attached to an ECS when deleting the ECS. If you set the parameter value to false, the system only detaches the disks from the ECS and reserves the disks.

Constraints

N/A

Range

  • true: indicates to delete the data disks attached to the ECS when deleting the ECS.
  • false: indicates only to detach the data disks attached to the ECS when deleting the ECS.

Default Value

false

Table 3 servers field description

Parameter

Mandatory

Type

Description

id

Yes

String

Definition

Specifies the ID of the ECS to be deleted.

Constraints

N/A

Range

N/A

Default Value

N/A

Response

See Responses (Task).

Example Request

  • Delete the ECS whose ID is 616fb98f-46ca-475e-917e-2563e5a8cd19, unbind the EIP, and detach data disks.
    POST https://{endpoint}/v1/{project_id}/cloudservers/delete
    
    {
        "servers": [
            {
                "id": "616fb98f-46ca-475e-917e-2563e5a8cd19"
            }
        ], 
        "delete_publicip": false, 
        "delete_volume": false
       }
  • Delete ECSs whose IDs are 616fb98f-46ca-475e-917e-2563e5a8cd19, 616fb98f-46ca-475e-917e-2563e5a8ef20, and 616fb98f-46ca-475e-917e-2563e5a8gh21 in batches.
    POST https://{endpoint}/v1/{project_id}/cloudservers/delete
    
    {
        "delete_publicip": false,
        "delete_volume": false,
        "servers": [
            {
                "id": "616fb98f-46ca-475e-917e-2563e5a8cd19"
            },
            {
                "id": "616fb98f-46ca-475e-917e-2563e5a8ef20"
            },
            {
                "id": "616fb98f-46ca-475e-917e-2563e5a8gh21"
            }
        ]
    }

Example Response

{
    "job_id": "ff80808288d415d80189901d8eb81cbb"
        }

Or

{
    "error": {
        "message": "request body is illegal.", 
        "code": "Ecs.0005"
        }
        }

Error Codes

See Error Codes.