Create VPN
Updated at:2025-10-16
Description
Set up a VPN.
Request structure
Plain Text
1POST /v{version}/vpn?clientToken={clientToken} HTTP/1.1
2Host: bcc.bj.baidubce.com
3Authorization: authorization string
4 {
5 "vpcId": vpcId,
6 "vpnName": vpnName,
7 "subnetId": subnetId,
8 "type": type,
9 "description": description,
10 "eip": eip,
11 "billing": {
12 "paymentTiming": paymentTiming,
13 "reservation": {
14 "reservationLength": reservationLength,
15 "reservationTimeUnit": reservationTimeUnit
16 }
17 },
18 "tags": [
19 {
20 "tagKey": tagKey,
21 "tagValue": tagValue
22 }
23 ],
24 "maxConnection": maxConnection,
25 "resourceGroupId": resourceGroupId,
26 "deleteProtect": deleteProtect
27 }
Request headers
There are no special headers required beyond the common headers.
Request parameters
| Parameter name | Types | Required or not | Parameter location | Description |
|---|---|---|---|---|
| version | String | Yes | URL parameter | For API version No., the current value is 1 |
| clientToken | String | No | Query | Idempotence Token, which is an ASCII string with a length not exceeding 64 bits, for details, refer to ClientToken Idempotence. |
| vpcId | String | Yes | Request Body parameters | ID of the VPC to which it belongs |
| subnetId | String | No | Request Body parameters | ID of the subnet to which it belongs |
| vpnName | String | Yes | Request Body parameters | VPN name, which supports uppercase and lowercase letters, numbers, and special characters such as -, _, / and ., starting with a letter, with a length of 1-65. |
| type | String | No | Request Body parameters | VPN gateway type, with value "IPSec" indicating IPSec-VPN gateway and value "SSL" indicating SSL-VPN gateway, defaulted as "IPSec" |
| description | String | No | Request Body parameters | Description of VPN |
| eip | String | No | Request Body parameters | EIP bound to the VPN |
| tags | List<[TagModel](VPC/API Reference/Appendix.md#TagModel)> | No | Request Body parameters | Tags bound to VPN |
| resourceGroupId | String | Yes | Request Body parameters | Resource group bound to the VPN |
| billing | [Billing](VPC/API Reference/Appendix.md#Billing) | Yes | Request Body parameters | Charge type, supporting both prepay and postpay |
| maxConnection | Integer | No | Request Body parameters | Maximum count of client connections for SSL-VPN. Optional from [5, 10, 20, 50, 100, 200, 500, 1000]. This parameter is only required for SSL-VPN. |
| deleteProtect | Boolean | No | RequestBody | Option to enable release protection. By default, it is set to false, allowing deletion. |
Response headers
No special headers are required beyond the standard ones.
Response parameters
| Parameter name | Types | Description |
|---|---|---|
| vpnId | String | VPN ID |
Request example
Prepay
Plain Text
1POST /v1/vpn?clientToken=1849ef6b-f73c-4f5d-b88b-259ca47af849 HTTP/1.1
2Host: bcc.bj.baidubce.com
3Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2015-08-11T04:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de
4{
5 "vpcId": "vpc-IyWRtII7",
6 "vpnName": "vpnName",
7 "description": "description",
8 "eip": "",
9 "billing":{
10 "reservation":{
11 "reservationLength":1,
12 "reservationTimeUnit":"month"
13 },
14 "paymentTiming":"Prepaid"
15 },
16 "tags": [
17 {
18 "tagKey": "hikwnf",
19 "tagValue": "nwklwmflk"
20 },
21 {
22 "tagKey": "whfooef",
23 "tagValue": "haiwnwejf"
24 }
25 ],
26 "resourceGroupId": "RESG-UoMgbkuLNjj",
27 "deleteProtect":true
28 }
Postpay
Plain Text
1POST /v1/vpn?clientToken=1849ef6b-f73c-4f5d-b88b-259ca47af849 HTTP/1.1
2Host: bcc.bj.baidubce.com
3Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2015-08-11T04:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de
4{
5 "vpcId": "vpc-IyWRtII7",
6 "vpnName": "vpnName",
7 "description": "description",
8 "eip": "",
9 "billing":{
10 "paymentTiming":"Postpaid"
11 },
12 "tags": [
13 {
14 "tagKey": "hikwnf",
15 "tagValue": "nwklwmflk"
16 },
17 {
18 "tagKey": "whfooef",
19 "tagValue": "haiwnwejf"
20 }
21 ],
22 "resourceGroupId": "RESG-UoMgbkuLNjj",
23 "deleteProtect":true
24 }
Response example
Plain Text
1HTTP/1.1 200 OK
2x-bce-request-id: 1214cca7-4ad5-451d-9215-71cb844c0a50
3Date: Thu, 16 Mar 2017 06:29:48 GMT
4Content-Type: application/json;charset=UTF-8
5Server: BWS
6 {
7 "vpnId": "vpn-ku4cxya6nisq"
8 }
