All Products
Search
Document Center

Virtual Private Cloud:AssociateRouteTable

Last Updated:Oct 26, 2026

Associates a custom route table with a vSwitch in the same VPC.

Operation description

The AssociateRouteTable operation is asynchronous. The system returns a request ID, but the route table is not immediately associated. The association task continues in the background. You can call DescribeVSwitchAttributes to query the association status of the route table:

  • If the vSwitch is in the Pending state, the route table is being associated.

  • If the vSwitch is in the Available state, the route table is successfully associated.

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

update

*VSwitch

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

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID of the VPC to which the route table to be associated with the vSwitch belongs.

You can call the DescribeRegions operation to query the region ID.

cn-hangzhou

RouteTableId

string

Yes

The ID of the route table to associate with the vSwitch.

vtb-bp145q7glnuzdvzu2****

VSwitchId

string

Yes

The ID of the vSwitch to associate with the route table.

vsw-25ncdvfaue4****

ClientToken

string

No

The client token that is used to ensure the idempotence of the request.

You can generate a parameter value on your client to ensure that the value is unique across different requests. The ClientToken parameter supports only ASCII characters.

Note

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

02fb3da4-130e-11e9-8e44-0016e04115b

RegionId

string

Yes

The region ID of the VPC to which the route table that you want to associate with a vSwitch belongs.

You can call DescribeRegions to query the region ID.

cn-hangzhou

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

DC668356-BCB4-42FD-9BC3-FA2B2E04B634

Examples

Success response

JSON format

{
  "RequestId": "DC668356-BCB4-42FD-9BC3-FA2B2E04B634"
}

Error codes

HTTP status code

Error code

Error message

Description

400 OperationDenied.CloudBoxVbrEntryExist The operation is not allowed because the routing table has a route entry for the next hop to the cloud box VBR. The specified operation is not allowed because the route table contains a route entry whose next hop points to a CloudBox VBR.
400 OperationDenied.OtherCloudBoxVbrEntryExist The operation is not allowed because the routing table has a route entry for the next hop that points to a VBR other than this cloud box. The specified operation is not allowed because the route table contains a route entry whose next hop points to a VBR outside the current CloudBox.
400 ResourceAlreadyAssociated.RouteTable The resource has already associated with a routetable.
400 OperationDenied.AssociateGatewayRouteTable The operation is not allowed because gateway route tables cannot be bound to a vSwitch. The vSwitch cannot be associated with a gateway route table.
400 OperationDenied.SwitchToSystemRouteTable The associated route tables cannot be directly changed to system route tables. Failed to switch from the associated route table to the system route table.
400 ResourceNotFound.VSwitch The specified resource of VSwitch is not found. The specified vSwitch does not exist.
400 InvalidRouteTableId.NotFound Specified route table does not exist.
400 OperationDenied.LocalRouteEntryModified The next hop of a local route is modified. The next hop of the local type route has been modified.
400 MissingParam.VSwitchId The parameter VSwitchId is missing. The parameter VSwitchId is missing.
400 InvalidRegionId.NotFound Specified value of RegionId is not supported.
400 InvalidParameter.Action This vpc feature is not supported in this region
400 IncorrectVSwitchStatus The current status of the virtual switch does not support this operation.
400 Forbidden.VSwitchAlreadyAssociatedRouteTable The specified virtual switch already associates route table.
400 Forbidden.NotInSameVpc The specified virtual switch and route table are not in the same VPC.
400 IncorrectStatus.RouteTable The status of the specified route table is incorrect.
404 InvalidRouteTableId.NotFound Specified route table does not exist.
404 InvalidVSwitchId.NotFound Specified VSwitch does not exist.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.