Creates a VPN gateway.

Usage notes

The CreateIpv4Gateway operation is asynchronous. After you send the request, the system returns a request ID. However, the operation is still being performed in the system background. You can call DescribeVpnGateway to query the status of a VPN gateway.

  • If a VPN is in the provisioning state, the VPN gateway is being created.
  • If a VPN gateway is in the active state, the VPN gateway has been created.


OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes CreateVpnGateway

The operation that you want to perform. Set the value to CreateVpnGateway.

RegionId String Yes cn-hangzhou

The region ID of the VPN gateway. You can call the DescribeRegions operation to query the most recent region list.

Name String No MYVPN

The name of the VPN gateway. The default value is the ID of the VPN gateway.

The name must be 2 to 100 characters in length, and can contain digits, underscores (_), and hyphens (-). It must start with a letter.

VpcId String Yes vpc-bp1ub1yt9cvakoelj****

The ID of the virtual private cloud (VPC) where you want to create the VPN gateway.

InstanceChargeType String No Example value for the Alibaba Cloud China site: PREPAY. Example value for the Alibaba Cloud International site: POSTPAY.

The billing method of the VPN gateway. Set the value to POSTPAY, which specifies the pay-as-you-go billing method.

Note This parameter is required when you create a VPN gateway.
Period Integer No 1

The subscription duration. Unit: months. Valid values: 1 to 9, 12, 24, and 36.

AutoPay Boolean No false

Specifies whether to enable automatic payment for the VPN gateway. Valid values:

  • true: yes
  • false (default): no
Bandwidth Integer Yes 5

The public bandwidth of the VPN gateway. Unit: Mbit/s.

Valid values: 5, 10, 20, 50, 100, and 200.

EnableIpsec Boolean No true

Specifies whether to enable the IPsec-VPN feature. Valid values:

  • true (default): yes
  • false: no
EnableSsl Boolean No false

Specifies whether to enable the SSL-VPN feature for the VPN gateway. Valid values:

  • true: yes
  • false (default): no
SslConnections Integer No 5

The maximum number of clients that can be connected at the same time. Valid values: 5, 10, and 20.

VSwitchId String No vsw-bp1j5miw2bae9s2vt****

The ID of the vSwitch to which the VPN gateway belongs.

VpnType String No Normal

The type of the VPN gateway. Valid values:

  • Normal (default): standard
  • NationalStandard: ShangMi (SM)
ClientToken String No 02fb3da4****

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

You can use the client to generate the value, but you must make sure that it is unique among different requests. The client token can contain only ASCII characters.

Note If you do not set this parameter, the system automatically uses RequestId as ClientToken. RequestId of each API request may be different.
NetworkType String No public

The network type of the VPN gateway. Valid values:

  • public (default): public VPN gateway
  • private: private VPN gateway

Response parameters

Parameter Type Example Description
VpnGatewayId String vpn-uf68lxhgr7ftbqr3p****

The ID of the VPN gateway.

RequestId String EB2C156A-41F8-49CC-A756-D55AFC8BFD69

The ID of the request.

Name String MYVPN

The name of the VPN gateway.

OrderId Long 208240895400460

The ID of the order.

If automatic payment is disabled, you must manually complete the payment for the VPN gateway in the Alibaba Cloud Management console.


Sample requests

&Common request parameters

Sample success responses

XML format

HTTP/1.1 200 OK


JSON format

HTTP/1.1 200 OK

  "VpnGatewayId" : "vpn-uf68lxhgr7ftbqr3p****",
  "RequestId" : "EB2C156A-41F8-49CC-A756-D55AFC8BFD69",
  "Name" : "MYVPN",
  "OrderId" : 208240895400460

Error codes

HttpCode Error code Error message Description
400 Resource.QuotaFull The quota of resource is full The error message returned because the resource quota is reached.

For a list of error codes, visit the Error Center.