All Products
Search
Document Center

Virtual Private Cloud:DeleteVpc

Last Updated:Jun 19, 2026

Calls the DeleteVpc operation to delete a Virtual Private Cloud (VPC).

Operation description

When calling this operation to delete a VPC, note the following:

  • Before deleting a VPC, you must release or migrate all resources in the VPC, including vSwitches, cloud product instances, and high-availability virtual IP addresses (HAVIPs).

  • Only VPCs in the Available state can be deleted.

  • The DeleteVpc operation is asynchronous. After a request is sent, a request ID is returned, but the VPC is not immediately deleted. The deletion task continues in the background. You can call the DescribeVpcAttribute operation to query the deletion status of the VPC:

    • When the VPC is in the Deleting state, the VPC is being deleted.

    • When the specified VPC cannot be found, the VPC is deleted.

  • The DeleteVpc operation does not support concurrent deletion of the same VPC.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

vpc:DeleteVpc

delete

*VPC

acs:vpc:{#regionId}:{#accountId}:vpc/{#VpcId}

  • vpc:tag
None

Request parameters

Parameter

Type

Required

Description

Example

VpcId

string

Yes

The ID of the VPC to be deleted.

vpc-bp1m7v25emi1h5mtc****

RegionId

string

No

The region ID of the VPC to be deleted.

You can call the DescribeRegions operation to query region IDs.

cn-hangzhou

ForceDelete

boolean

No

Specifies whether to forcefully delete the VPC. Valid values:

  • true: forcefully deletes the VPC.

  • false (default): does not forcefully delete the VPC.

The VPC can be forcefully deleted only when the following resources exist in the VPC:

  • The VPC contains only an IPv4 gateway and routes pointing to the IPv4 gateway.

  • The VPC contains only an IPv6 gateway and routes pointing to the IPv6 gateway.

false

DryRun

boolean

No

Specifies whether to perform a dry run. Valid values:

  • true: performs a dry run without actually deleting the VPC. The system checks whether the required parameters are set, the request format is valid, and business restrictions are met. If the check fails, the corresponding error is returned. If the check succeeds, the error code DryRunOperation is returned.

  • false (default): performs a dry run and sends the request. If the check succeeds, an HTTP 2xx status code is returned, and the VPC is directly deleted.

false

ClientToken

string

No

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 ClientToken value can contain only ASCII characters.

Note

If you do not specify this parameter, the system uses the RequestId of the API request as the ClientToken. The RequestId may be different for each API request.

123e4567-e89b-12d3-a456-426655440000

Response elements

Element

Type

Description

Example

object

The request ID.

RequestId

string

The request ID.

0ED8D006-F706-4D23-88ED-E11ED28DCAC0

Examples

Success response

JSON format

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

Error codes

HTTP status code

Error code

Error message

Description

400 IncorrectStatus.VpcDhcpStatus The DhcpOptionsSet status of vpc does not support this operation. You cannot delete the VPC when the DHCP options set of the VPC is in the current state.
400 DependencyViolation.GatewayEndpoint The VPC contains endpoints and cannot be deleted. The VPC contains endpoints and cannot be deleted. Delete the endpoints in the VPC and then delete the VPC.
400 IncorrectVpcStatus Current VPC status does not support this operation.
400 DependencyViolation.RouteEntry Specified object has dependent resources The VPC cannot be deleted because custom routes exist in the VPC.
400 DependencyViolation.Instance Specified object has dependent resources
400 DependencyViolation.VSwitch Specified object has dependent resources vSwitches exist in the VPC and the VPC cannot be deleted. Delete the vSwitches and try again.
400 DependencyViolation.RouteInterface Specified object has dependent route interface .
400 DependencyViolation.Tunnel Specified object has dependent tunnel.
400 DependencyViolation.NatGateway Specified object has dependent resources NatGateway. NAT gateways exist in the VPC and the VPC cannot be deleted. Delete the NAT gateways and try again.
400 DependencyViolation.RouterInterface Specified object has dependent resources RouterInterface.
400 DependencyViolation.SecurityGroup Specified object has dependent resources SecurityGroup. Security groups exist in the VPC and the VPC cannot be deleted. Delete the security groups and try again.
400 Forbidden.VpcNotFound Specified VPC can not found. The specified VPC does not exist.
400 Forbbiden Active custom route in vpc.
400 TaskConflict The eip operate too frequent, TaskConflict. Operations are too frequent and tasks conflict with each other.
400 InvalidAction The VPC has been connected to the classic network ECS. Please cancel the connection before proceeding.
400 IncorrectStatus.cbnStatus Current CBN status does not support this operation. The status of the CEN instance is invalid.
400 DependencyViolation.RouteTable Specified object has dependent custom routeTable.
400 DependencyViolation.NetworkAcl Specified object has dependent resources network acl. The specified object is associated with a network ACL.
400 DependencyViolation.ClassicLinkInstance Specified object has active classicLink instance.
400 System.ServiceBusy System is busy, please try later.
400 DependencyViolation.DhcpOptionsSet The VPC cannot be deleted when it is associated with dhcpOptionsSet. The VPC cannot be deleted when it is associated with dhcpOptionsSet.
400 InvalidRegionId.NotFound The specified region is not found. The specified region does not exist.
400 DependencyViolation.CustomRouteTable CustomRouteTable already exists.
400 DependencyViolation.Ipv4Gateway The VPC cannot be deleted when it has ipv4Gateway. The VPC cannot be deleted because an IPv4 gateway exists in the VPC.
400 DependencyViolation.GatewayRouteTable Specified object has dependent resources gatewayRouteTable.
400 OperationDenied.VpcPeerExists The operation is not allowed because the VpcPeer exists. The VPC has a VPC peering connection.
400 DependencyViolation.AppAccess Specified object has dependent resources app access. The VPC has a reverse access and cannot be deleted.
400 DependencyViolation.OppositeRouterInterface Failed to delete the VPC because it has peer router interfaces. The VPC failed to be deleted because a peer router interface exists in the VPC.
400 DependencyViolation.TransitRouter Specified object has attached to Transit Router. The specified resource is dependent on other resources and the current operation is not allowed.
400 DependencyViolation.Ipv6Gateway The VPC contains IPv6Gateway and cannot be deleted.
400 DependencyViolation.CloudServiceResource The VPC contains CloudServiceResource and cannot be deleted.
400 IncorrectStatus.VpcDnsHostnameStatus The DnsHostname status of vpc does not support this operation. The private domain name status of the current VPC does not support this operation.
400 OperationDenied.AttachedToECR The operation is not allowed because the VPC is attached to ECR %s. The operation is not allowed because the VPC is attached to ECR %s.
500 InternalError The request processing has failed due to some unknown error.
403 OperationDenied The operation is not supported in this status.
404 InvalidVpcId.NotFound Specified VPC does not exist.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.