Deletes a VPC.

API description

Note the following before you call this API action:

  • You must release or remove all resources in the VPC, such as VSwitches, cloud instances, and High-Availability Virtual IP Addresses (HaVips).
  • You can only delete the VPCs that are in the Available status.

Make the API call

You can use OpenAPI Explorer to make API calls, search for API calls, perform debugging, and generate SDK example code.

Request parameters

Parameter Type Required? Example value Description
Action String Yes DeleteVpc

The name of this action. Value: DeleteVpc

VpcId String Yes vpc-bp1m7v25emi1h5mtc****

The ID of the VPC to be deleted.

RegionId String Yes cn-hangzhou

The ID of the region to which the VPC belongs.

Response parameters

Parameter Type Example value Description
RequestId String 0ED8D006-F706-4D23-88ED-E11ED28DCAC0

The ID of the request.

Examples

Request example

https://vpc.aliyuncs.com/?Action=DeleteVpc
&VpcId=vpc-bp1m7v25emi1h5mtc****
&RegionId=cn-hangzhou
&<CommonParameters>

Response example

XML format

<DeleteVpcResponse>
      <RequestId>0ED8D006-F706-4D23-88ED-E11ED28DCAC0</RequestId>
</DeleteVpcResponse>

JSON format

{ 
    "RequestId": "0ED8D006-F706-4D23-88ED-E11ED28DCAC0"
}

Errors

HTTP status code Error code Error message Description
403 OperationDenied The operation is not supported in this status. This operation cannot be performed in this status.
403 OperationDenied The snapshot creation for the specified disk is not finished yet. The snapshot creation for the specified disk is not completed.
400 IncorrectVpcStatus Current VPC status does not support this operation. The VPC does not support the action in the current status.
400 DependencyViolation.RouteEntry Specified object has dependent resources Custom route rules still exist for the current VPC. VPC deletion failed.
400 DependencyViolation.Instance Specified object has dependent resources The specified object has associated resources.
400 DependencyViolation.VSwitch Specified object has dependent resources This VPC has existing VSwitches and cannot be deleted. Delete all VSwitches in the VPC first.
400 DependencyViolation.SecurityGroup Specified object has dependent resources SecurityGroup. This VPC has existing security groups and cannot be deleted. Delete all security groups in the VPC first.
404 InvalidVpcId.NotFound Specified VPC does not exist. The specified VPC does not exist.
400 DependencyViolation.RouteInterface Specified object has dependent route interface . The specified VSwitch is connected to a VRouter interface and cannot be deleted.
400 DependencyViolation.Tunnel Specified object has dependent tunnel. This specified object has an associated tunnel.
500 InternalError The request processing has failed due to some unknown error. The request failed to be processed due to unknown errors.
400 DependencyViolation.NatGateway Specified object has dependent resources NatGateway. This VPC has an existing NAT Gateway and cannot be deleted. Delete the NAT Gateway in the VPC first.
400 DependencyViolation.RouterInterface Specified object has dependent resources RouterInterface. The specified object has associated router interfaces.
400 Forbidden.VpcNotFound Specified VPC can not found. The specified VPC does not exist.
400 Forbbiden Active custom route in vpc. You must add a custom route entry in the VPC.

For a list of error codes, visit the API Error Center.