Releases one or more pay-as-you-go instances or expired subscription Elastic Compute Service (ECS) instances.

Usage notes

  • After an instance is released, all the physical resources used by the instance are recycled. Relevant data is erased and cannot be recovered.
  • Disk settings may affect their behavior when the instances they are attached to are released. Take note of the following items:
    • The disks for which DeleteWithInstance is set to false are retained as pay-as-you-go disks.
    • The disks for which DeleteWithInstance is set to true are released along with the instance.
    • Automatic snapshots of the disks for which DeleteAutoSnapshot is set to false are retained.
    • Automatic snapshots of the disks for which DeleteAutoSnapshot is set to true are released.
    • Manual snapshots of the disks are retained.
    • If OperationLocks in the response contains "LockReason" : "security" for an instance, the instance is locked for security reasons. For more information, see API behavior when an instance is locked for security reasons. Even if DeleteWithInstance is set to false for the data disks that are attached to the instance, this parameter is ignored and the data disks are released along with the instance.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

ParameterTypeRequiredExampleDescription
ActionStringYesDeleteInstances

The operation that you want to perform. Set the value to DeleteInstances.

DryRunBooleanNofalse

Specifies whether to perform a dry run. Default value: false. Valid values:

  • true: performs a dry run. The system checks the AccessKey pair, the permissions of the RAM user, and the required parameters. If the request fails the dry run, the corresponding error message is returned. If the request passes the dry run, the DRYRUN.SUCCESS error code is returned.
  • false: performs a dry run and sends the request. If the request passes the dry run, a 2XX HTTP status code is returned and the operation is performed.
ForceBooleanNofalse

Specifies whether to forcefully release the instance that is in the Running (Running) state. Default value: false. Valid values:

  • true: forcefully releases the instance in the Running (Running) state. When the Force parameter is set to true, this operation is equivalent to a power-off operation. Temporary data in the memory and storage of the instance is erased and cannot be restored.
  • false: normally releases the instance. This value is valid only for instances that are in the Stopped (Stopped) state.
TerminateSubscriptionBooleanNofalse

Specifies whether to release the expired subscription instance.

Default value: false.

ClientTokenStringNo123e4567-e89b-12d3-a456-426655440000

The client token that is used to ensure the idempotence of the request. You can use the client to generate the token, but you must make sure that the token is unique among different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence.

RegionIdStringYescn-hangzhou

The region ID of the instance. You can call the DescribeRegions operation to query the most recent region list.

InstanceId.NStringYesi-bp1g6zv0ce8oghu7****

The ID of instance N.

Response parameters

ParameterTypeExampleDescription
RequestIdString7B7813C6-57BF-41XX-B12B-F172F65A6046

The ID of the request.

Examples

Sample requests

http(s)://ecs.aliyuncs.com/?Action=DeleteInstances
&InstanceId.1=i-bp1g6zv0ce8oghu7****
&Force=false
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<DeleteInstancesResponse>
    <RequestId>7B7813C6-57BF-41XX-B12B-F172F65A6046</RequestId>
</DeleteInstancesResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "7B7813C6-57BF-41XX-B12B-F172F65A6046"
}

Error codes

HttpCodeError codeError messageDescription
400DRYRUN.SUCCESSThis request is a dryrun request with successful result.The error message returned because the validity of the request is checked and determined as valid.
400DependencyViolation.SLBConfiguringSpecified operation is denied as your instance is using by another product.The error message returned because the instance is referenced by a Server Load Balancer (SLB) instance that is being configured.
400DependencyViolation.RouteEntrySpecified instance is used by route entry.The error message returned because custom routing rules exist in the virtual private cloud (VPC) and the VPC cannot be deleted.
500InternalErrorThe request processing has failed due to some unknown error.The error message returned because an internal error has occurred. Try again later.
500InternalError%sThe error message returned because an internal error has occurred.
403InvalidOperation.DeletionProtection%sThe error message returned because the operation is invalid. Disable release protection for the instance first.
403InvalidOperation.EniLinked%sThe error message returned because the operation is not supported while the elastic network interface (ENI) of the instance is associated with other ENIs. You must disassociate the ENI from the other ENIs before you can detach the ENI from the instance.
403IncorrectInstanceStatus%sThe error message returned because the operation is not supported while the instance is in the current state.
403InstanceLockedForSecurityThe specified operation is denied as your instance is locked for security reasons.The error message returned because the instance is locked for security reasons.
404InvalidInstanceIds.NotFoundThe specified InstanceIds does not exist.The error message returned because the specified instance ID does not exist. Check whether the specified instance ID is valid. You can call the DescribeInstances operation to query the states of specific instances.
404InvalidInstanceId.NotFound%sThe error message returned because the specified InstanceId parameter does not exist.

For a list of error codes, see Service error codes.