All Products
Search
Document Center

Virtual Private Cloud:AssociateRouteTable

Last Updated:Aug 28, 2026

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

Operation description

AssociateRouteTable is asynchronous. After you send a request, the system returns a request ID and runs the task in the background. Call DescribeVSwitchAttributes to query the task status:

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

  • If the vSwitch is in the Available state, the route table is associated with the 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

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID of the VPC to which the route table belongs.

Call DescribeRegions to query the most recent region list.

cn-hangzhou

RouteTableId

string

Yes

The ID of the route table.

vtb-bp145q7glnuzdvzu2****

VSwitchId

string

Yes

The ID of the vSwitch.

vsw-25ncdvfaue4****

ClientToken

string

No

The client token that ensures the idempotence of the request.

You can use the client to generate the token, but it must be unique among requests. The token can contain only ASCII characters.

Note

If you do not specify this parameter, the system uses the request ID as the client token. The request ID may differ for each request.

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

RegionId

string

Yes

The region ID of the VPC to which the route table belongs.

Call DescribeRegions to query the most recent region list.

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.
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.
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.