All Products
Search
Document Center

Virtual Private Cloud:CreateRouteEntries

Last Updated:Sep 07, 2026

Creates custom route entries in a route table of a vRouter in a VPC in a batch.

Operation description

  • CreateRouteEntries is an asynchronous operation. After you invoke this operation, the system returns an instance ID, but the route has not been created yet. The system is still running the creation task in the background. You can invoke DescribeRouteEntryList to query the creation status of the route:
    • If the route is in the Creating state, the route is being created.

    • If the route is in the Created state, the route has been created.

  • CreateRouteEntries does not support concurrent batch creation of custom route entries in the same VPC.

Take note of the following items when you use this operation to add custom route entries to a route table of a vRouter in a VPC:

  • A route table can contain a maximum of 200 custom route entries.

  • The destination CIDR block (DstCidrBlock) of a custom route entry cannot be the same as, contain, or be contained by the CIDR block of a vSwitch in the VPC.

  • The destination CIDR block (DstCidrBlock) of a custom route entry cannot point to 100.64.0.0/10 or be contained by 100.64.0.0/10.

  • The destination CIDR blocks (DstCidrBlock) of route entries in the same route table must be unique.

  • If the specified destination CIDR block (DstCidrBlock) is an IP address, the system processes it with a 32-bit mask.

  • Multiple custom route entries can point to the same next hop (NextHop).

  • The next hop (NextHop) of a custom route entry must be in the same VPC as the route table.

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

create

*RouteEntry

acs:vpc:{#regionId}:{#accountId}:routetable/{#RouteTableId}

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID of the route table.

You can call DescribeRegions to query the region ID.

cn-hangzhou

RouteEntries

array<object>

Yes

The list of route entry information.

object

No

The list of route entry information.

Description

string

No

The description of the custom route entry. You can specify up to 50 descriptions.

The description must be 1 to 256 characters in length and cannot start with http:// or https://.

test

DstCidrBlock

string

Yes

The destination CIDR block of the custom route entry. Both IPv4 and IPv6 destination CIDR blocks are supported. You can specify up to 50 destination CIDR blocks. The following requirements must be met:

  • The destination CIDR block cannot point to 100.64.0.0/10 or be contained by 100.64.0.0/10.

  • The destination CIDR blocks of different route entries in the same route table must be unique.

192.168.0.0/24

IpVersion

integer

No

The version of the IP protocol. You can specify up to 50 IP protocol versions. Valid values:

  • 4: IPv4.

  • 6: IPv6.

4

Name

string

No

The name of the custom route entry to add. You can specify up to 50 names.

The name must be 1 to 128 characters in length and cannot start with http:// or https://.

test

NextHop

string

Yes

The ID of the next-hop instance of the custom route entry. You can specify up to 50 instance IDs.

Note

If you set NextHopType to ECR, you can call DescribeExpressConnectRouterAssociation to obtain the AssociationId as the next-hop ID.

i-j6c2fp57q8rr4jlu****

NextHopType

string

Yes

The next hop type of the custom route entry. You can specify up to 50 next hop types. Valid values:

  • Instance (default): ECS instance.

  • HaVip: high-availability (HA) virtual IP address.

  • RouterInterface: vRouter interface.

  • NetworkInterface: elastic network interfaces (ENIs).

  • VpnGateway: VPN gateway.

  • IPv6Gateway: IPv6 gateway.

  • NatGateway: NAT gateway.

  • Attachment: transit router.

  • VpcPeer: VPC peering connection.

  • Ipv4Gateway: IPv4 gateway.

  • GatewayEndpoint: gateway endpoint.

  • CenBasic: CEN that does not support transit routers.

  • Ecr: Express Connect Router (ECR).

  • GatewayLoadBalancerEndpoint: Gateway Load Balancer endpoint (GWLBe).

  • RouteTargetGroup: load balancing target group.

RouterInterface

RouteTableId

string

Yes

The ID of the route table to which you want to add the custom route entry. You can specify up to 50 route table IDs.

vtb-bp145q7glnuzd****

DryRun

boolean

No

Specifies whether to perform a dry run. Valid values:

true: performs a dry run without sending a request to create route entries. The system checks the AccessKey pair, the authorization of the Resource Access Management (RAM) user, and the required parameters. If the check fails, the corresponding error is returned. If the check passes, the error code DryRunOperation is returned.

false (default): sends a normal request. If the check passes, a 2xx HTTP status code is returned and the route entries are created.

Response elements

Element

Type

Description

Example

object

The number of successful tasks.

FailedCount

integer

The number of route entries that failed to be added.

2

FailedRouteEntries

array<object>

The details of the route entries that failed to be added.

object

The details of the route entries that failed to be added.

DstCidrBlock

string

The destination CIDR block of the custom route entry that failed to be added.

192.168.0.0/24

FailedCode

string

The error code of the failure.

VPC_ROUTE_ENTRY_CIDR_BLOCK_DUPLICATE

FailedMessage

string

The error message of the failure.

Specified CIDR block is already exists, entry.cidrBlock=xxxx

NextHop

string

The ID of the next-hop instance of the custom route entry that failed to be added.

i-j6c2fp57q8rr4jlu****

RequestId

string

The request ID.

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

RouteEntryIds

array

The instance IDs returned for the custom route entries that were successfully added.

string

The instance ID returned for the custom route entry that was successfully added.

rte-sn6vjkioxte1gz83z****

SuccessCount

integer

The number of route entries that were successfully added.

2

Examples

Success response

JSON format

{
  "FailedCount": 2,
  "FailedRouteEntries": [
    {
      "DstCidrBlock": "192.168.0.0/24",
      "FailedCode": "VPC_ROUTE_ENTRY_CIDR_BLOCK_DUPLICATE",
      "FailedMessage": "Specified CIDR block is already exists, entry.cidrBlock=xxxx",
      "NextHop": "i-j6c2fp57q8rr4jlu****"
    }
  ],
  "RequestId": "0ED8D006-F706-4D23-88ED-E11ED28DCAC0",
  "RouteEntryIds": [
    "rte-sn6vjkioxte1gz83z****"
  ],
  "SuccessCount": 2
}

Error codes

HTTP status code

Error code

Error message

Description

400 DryRunOperation Request validation has been passed with DryRun flag set. The request passed the dry run.
400 InvalidCIDRBlock.Duplicate Specified CIDR block is already exists.
400 MissingParam.RouteTableId The parameter RouteTableId is missing. The required parameter RouteTableId is missing.
400 IncorrectStatus.PrefixListRelation The related prefix list relation is in an intermediate state and cannot perform the current operation. The associated prefix list association is in an intermediate state, and the current operation cannot be performed.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.