All Products
Search
Document Center

Virtual Private Cloud:DeleteVSwitch

Last Updated:Jun 19, 2026

Deletes a VSwitch.

Operation description

When you call this operation to delete a VSwitch, take note of the following items:

  • Before you delete a VSwitch, you must release or migrate all resources in the VPC, including VSwitches, cloud product instances, router interfaces, and HaVip resources.

  • Only VSwitches in the Available state can be deleted.

  • A VSwitch cannot be deleted if the VPC to which it belongs is creating or deleting a VSwitch or route entry.

  • The DeleteVSwitch operation is asynchronous. After you send a request, the system returns a request ID, but the VSwitch is not yet deleted. The deletion task is still running in the background. You can call DescribeVSwitchAttributes to query the deletion status of the VSwitch:

    • If the VSwitch is in the Pending state, the VSwitch is being deleted.

    • If the specified VSwitch cannot be found, the VSwitch is deleted.

  • The DeleteVSwitch operation does not support concurrent deletion of the same VSwitch.

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:DeleteVSwitch

delete

*VSwitch

acs:vpc:{#regionId}:{#accountId}:vswitch/{#VSwitchId}

None None

Request parameters

Parameter

Type

Required

Description

Example

VSwitchId

string

Yes

The ID of the VSwitch to delete.

vsw-asdfjlna****

RegionId

string

No

The region ID of the VSwitch to delete.

You can call the DescribeRegions operation to query region IDs.

cn-hangzhou

DryRun

boolean

No

Specifies whether to perform a dry run. Valid values:

  • true: Sends a check request without deleting the VSwitch. The check items include whether required parameters are specified, the request format, and service limits. If the check fails, the corresponding error is returned. If the check succeeds, the error code DryRunOperation is returned.

  • false (default): Sends a normal request. After the check succeeds, an HTTP 2xx status code is returned and the VSwitch is directly deleted.

false

Response elements

Element

Type

Description

Example

object

The response parameters.

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 OperationDenied.OtherSubnetProcessing other subnet is processing. You cannot delete the vSwitch because other subnets are being managed.
400 IncorrectVSwitchStatus vpc subnet is in middle status.
400 DependencyViolation Resources deployed in the vSwitch have not been deleted. Failed to delete the vSwitch because resources attached to the vSwitch are not released.
400 IncorrectRouteEntryStatus Some route entry status blocked this operation.
400 DependencyViolation.HaVip VSwitch cannot be deleted when there are some HaVip dependent with it. The vSwitch is associated with an HAVIP and the vSwitch cannot be deleted.
400 DependencyViolation.RouteTable VSwitch cannot be deleted when associated with route table
400 MissingParameter Miss mandatory parameter.
400 TaskConflict The operation is too frequent, TaskConflict. The system is unavailable. Try again later.
400 DependencyViolation.SNAT The vswitch cannot be deleted when used by snat. You cannot delete a vSwitch when SNAT is used.
400 DeleteVSwitch.IncorrectStatus.cbnStatus Current CBN status does not support this operation. You cannot delete the vSwitch when the CEN instance is in the current state.
400 AttrMismatching.NaclAndBindInstance The network acl and resource not in same vpc.
400 InvalidResource.NotBinding The resource has not been binded.
400 DependencyViolation.SnatEntry VSwitch cannot be deleted when snat entry exist.
400 DependencyViolation.NetworkAcl VSwitch cannot be deleted when network acl exist. You cannot delete the vSwitch because a network ACL exists in the vSwitch.
400 DependencyViolation.EnhancedNatgw VSwitch cannot be deleted when natgw exist. You cannot delete the vSwitch because a NAT gateway exists in the vSwitch.
400 DependencyViolation.ResourceShare VSwitch cannot be deleted when resource share exist.
400 OperationFailed.SystemBusy Operation failed because system is busy. The error message returned because the system is busy. Try again later.
400 DependencyViolation.MulticastDomain VSwitch cannot be deleted when associated with multicast domain. The vSwitch is added to a multicast domain and cannot be deleted.
400 DependencyViolation.VSwitchCidrReservation VSwitch cannot be deleted when vswitch cidr reservation exist. The error message returned because a CIDR block is reserved for the vSwitch and the vSwitch cannot be deleted.
400 DependencyViolation.CloudService VSwitch cannot be deleted when uesd by cloud service. The error message returned because the vSwitch is being used by a cloud service and cannot be deleted. Check the use scenario of the cloud service.
400 InvalidVSwitchId.NotFound VSwitch not exist.
400 OperationFailed.Ipv6InstanceExist Operation failed because vswitch has ipv6 instance. IPv6 instances exist in the vSwitch.
400 DependencyViolation.Ipv6Address The specified resource of %s depends on %s, so the operation cannot be completed. The specified resource is dependent on other resources and the current operation is not allowed.
400 DependencyViolation.%s The specified resource of [%s] depends on [%s], so the operation cannot be completed. The specified resource of [%s] depends on [%s], so the operation cannot be completed.
400 Forbidden.RegionNotFound Specified instance is not found during access authentication. The error message returned because the region is not supported.
400 IncorrectStatus Vswtich status not stable.
400 DependencyViolation.RouterInterface Specified object has dependent resources RouterInterface.
400 InvalidRegionId.NotFound The specified region is not found. The specified region does not exist.
404 IncorrectVSwitchId Specified vSwtich instance is not found during access authentication. The vSwitch is not found during the permission verification progress.
404 InvalidVSwitchId.NotFound VSwitch not exist.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.