
# 批量创建VPN连接 - CreateVPNConnections
#### 功能介绍
批量创建VPN连接，在同一个网关下同时创建1-2条VPN连接。
#### 调用方法
请参见[如何调用API](https://support.huaweicloud.com/api-vpn/vpn_api_0008.html)。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权，具体权限要求请参见[权限和授权项](https://support.huaweicloud.com/api-vpn/vpn_api_0044.html)。
- 如果使用身份策略授权，需具备如下身份策略权限。
| 授权项                            | 访问级别  | 资源类型（\*为必须）      | 条件键                                                                                                                                                                                                                                                                                                                                                                                                                                                              | 别名 | 依赖的授权项                 |
|:---|:---|:---|:---|:---|:---|
| vpn:vpnConnections:batchCreate | write | vpnGateways      | - [g:EnterpriseProjectId](https://support.huaweicloud.com/usermanual-iam5/iam_01_0934.html#section2)  - [g:ResourceTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_0934.html#section2)   | -  | vpc:routeTables:update |
| vpn:vpnConnections:batchCreate | write | customerGateways | [g:ResourceTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_0934.html#section2)                                                                                                                                                                                                                                                                                                                                                           | -  | vpc:routeTables:update |
| vpn:vpnConnections:batchCreate | write | vpnConnections   | - [g:RequestTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_0934.html#section2)  - [g:TagKeys](https://support.huaweicloud.com/usermanual-iam5/iam_01_0934.html#section2)                | -  | vpc:routeTables:update |
   
#### URI
POST /v5/{project_id}/vpn-connections/batch-create
表1参数说明 
| 名称         | 类型     | 是否必选 | 说明                                                                                  |
|:---|:---|:---|:---|
| project_id | String | 是    | 项目ID，可以通过[获取项目ID](https://support.huaweicloud.com/api-vpn/vpn_api_0051.html)获取项目ID。 |
   
#### 请求消息
- 请求参数
  表2请求参数 
  | 名称              | 类型                                                                                                                                                | 是否必选 | 描述                        |
  |:---|:---|:---|:---|
  | vpn_connections | Array of [CreateVpnConnectionRequestBodyContent] object | 是    | vpn_connection对象数组，范围1-2。 |
     
   表3CreateVpnConnectionRequestBodyContent 
  | 名称                   | 类型                                                                          | 是否必选 | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
  |:---|:---|:---|:---|
  | name                 | String                                                                      | 否    | - 功能说明：VPN连接名称，不填时会自动生成格式为vpn-\*\*\*\*的名称。例如：vpn-13be。  - 取值范围：1-64个字符，支持数字、英文字母、中文（\\u4e00 - \\u9fa5）、_（下划线）、-（中划线）、.（点）。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
  | vgw_id               | String                                                                      | 是    | - 功能说明：VPN网关ID。  - 约束：36位UUID，当VPN网关的flavor配置为GM时，VPN网关必须已导入过VPN网关证书。创建2条连接时，vgw_id需相同。   可以通过[查询VPN网关列表](https://support.huaweicloud.com/api-vpn/vpn_api_0016.html)查看VPN网关的ID。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
  | vgw_ip               | String                                                                      | 是    | - 功能说明： - 当VPN网关的network_type配置为public时，vgw_ip为VPN网关EIP的ID。  - 当VPN网关的network_type配置为private时，vgw_ip为VPN网关使用的接入私网IP。    - 约束：36位UUID或点分十进制IPv4地址（如192.168.45.7）。   可以通过[查询VPN网关](https://support.huaweicloud.com/api-vpn/vpn_api_0015.html)查看VPN网关所使用的EIP的ID或接入私网IP。                                                                                                                                                                                                                                                   |
  | style                | String                                                                      | 否    | - 功能说明：连接模式。  - 取值范围： policy: 策略模式。 static: 静态路由模式。 bgp: bgp路由模式。 policy-template: 策略模板模式。   - 默认值：static。                                                                                                                                                                                                                                                                                                                                   |
  | cgw_id               | String                                                                      | 是    | - 功能说明：对端网关ID。  - 约束：36位UUID，当VPN网关的flavor配置为GM时，对端网关必须已导入过对端网关证书。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
  | peer_subnets         | Array of String                                                             | 否    | - 功能说明：IPv4对端子网。  - 约束： - IP协议版本号为IPv6时不填；VPN网关的关联模式为er且style字段为policy或bgp时不填；其他场景必填。  - 部分网段是VPC预留网段，不能作为对端子网，例如：100.64.0.0/10、100.64.0.0/12，214.0.0.0/8。不同region的预留网段不同，实际使用以console显示为准。 如果需要使用100.64.0.0/10或100.64.0.0/12，请[提交工单](https://console.huaweicloud.com/ticket/?locale=zh-cn#/ticketindex/serviceTickets)申请。   - 每个VPN连接最多填写50个对端子网。     |
  | peer_subnets_v6      | Array of String                                                             | 否    | - 功能说明：IPv6对端子网。  - 约束： - IP协议版本号为IPv4时不填；VPN网关的关联模式为er且style字段为policy或bgp时不填，其他场景必填。  - 每个VPN连接最多填写50个对端子网。                                                                                                                                                                                                                                                                                                                                                                                                     |
  | tunnel_local_address | String                                                                      | 否    | - 功能说明：路由模式下配置在VPN网关上的tunnel接口地址。例如：169.254.76.1/30。  - 约束： - 前16位必须是169.254，不能使用169.254.195.xxx。  - 掩码长度必须是30。必须和tunnel_peer_address在同一个30掩码范围。  - 应填写网段中的主机地址。                                                                                                                                                                                                                                                             |
  | tunnel_peer_address  | String                                                                      | 否    | - 功能说明：路由模式下配置在用户侧设备上的tunnel接口地址。例如：169.254.76.2/30。  - 约束： - 前16位必须是169.254，不能使用169.254.195.xxx。  - 掩码长度必须是30。必须和tunnel_local_address在同一个30掩码范围。  - 应填写网段中的主机地址。                                                                                                                                                                                                                                                |
  | enable_nqa           | Boolean                                                                     | 否    | - 功能说明：开启NQA检测。  - 取值范围：true，false。  - 默认值：false。  - 约束：当style为static时填写，否则不填。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
  | enable_health_check  | Boolean                                                                     | 否    | - 功能说明：开启健康检查。  - 取值范围：true，false。  - 默认值：true。  - 约束：当style为policy-template时不填。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
  | enable_hub           | Boolean                                                                     | 否    | - 功能说明：开启分支互联。  - 取值范围：true，false。  - 默认值：false。  - 约束：当style为BGP时填写，否则不填。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
  | psk                  | String                                                                      | 否    | - 功能说明：预共享密钥。 当VPN网关的flavor配置为GM时，此字段不用填写，否则必填。   - 约束：8-128个字符，只能包含大写字母、小写字母、数字和特殊字符(\~!@#$%\^\*()-_+={ },./:;)且至少包含四种字符的三种。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
  | policy_rules         | Array of [PolicyRule] object     | 否    | 功能说明：IPv4策略模式的策略规则组。 约束：最多填写5个。仅当style为policy且VPN网关的IP协议版本号为IPv4时填写。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
  | policy_rules_v6      | Array of [PolicyRule] object     | 否    | 功能说明：IPv6策略模式的策略规则组。 约束：最多填写5个。仅当style为policy且VPN网关的IP协议版本号为IPv6时填写。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
  | ikepolicy            | [IkePolicy] object               | 否    | ike策略对象。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
  | ipsecpolicy          | [IpsecPolicy] object             | 否    | ipsec策略对象。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
  | ha_role              | String                                                                      | 否    | - 功能说明：双活模式VPN网关下创建连接可不填，主备模式VPN网关下创建连接时，'master'表示主连接，'slave'表示备连接。  - 默认值：master。  - 约束：主备模式VPN网关在主EIP或者主私网地址建立的连接必须填'master'，在备EIP或者备私网地址建立的连接必须填'slave'。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
  | tags                 | Array of [VpnResourceTag] object | 否    | - 功能说明：标签列表。  - 约束：最多填写20个。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
     
   表4PolicyRule 
  | 名称          | 类型              | 是否必选 | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
  |:---|:---|:---|:---|
  | rule_index  | Integer         | 否    | - 功能说明：规则ID。  - 取值范围：0-50。  - 注：该字段已经废弃，但仍然保留兼容性支持，建议不要使用该字段。                                                                                                      |
  | source      | String          | 否    | - 功能说明：源地址网段，网段IPv4/IPv6格式需与VPN网关的IP协议版本匹配。  - 约束：不能与其他PolicyRule下的source相同。                                                                                                                                                                             |
  | destination | Array of String | 否    | - 功能说明：目的地址网段，网段IPv4/IPv6格式需与VPN网关的IP协议版本匹配。 单个IPv4网段格式示例：192.168.52.0/24。 单个IPv6网段格式示例：16af:cacc:1097::/48。   - 约束：每个PolicyRule最多填写50个。   |
     
   表5IkePolicy 
  | 名称                       | 类型                                                      | 是否必选 | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
  |:---|:---|:---|:---|
  | ike_version              | String                                                  | 否    | - 功能说明：IKE版本号。  - 取值范围： 当VPN网关的flavor配置为GM时，取值范围为v1。 其他场景下取值范围为v1，v2。   - 默认值： 当VPN网关的flavor配置为GM时，默认值为v1； 其他场景下，默认值为v2。                                                                                                                                                                 |
  | phase1_negotiation_mode  | String                                                  | 否    | - 功能说明：协商模式。  - 取值范围： 当VPN网关的flavor配置为GM时，取值范围为main。 其他场景下取值范围为main，aggressive。 main：主模式，协商过程安全性高。 aggressive：野蛮模式，协商快速且协商成功率高。   - 默认值：main。  - 约束：IKE版本为v1时填写，为v2时不填。                        |
  | authentication_algorithm | String                                                  | 否    | - 功能说明：认证算法。  - 取值范围： 当VPN网关的flavor配置为GM时，取值范围为sm3。 其他场景下取值范围为sha2-512，sha2-384，sha2-256，sha1，md5。 其中，sha1和md5安全性较低，请慎用。   - 默认值： 当VPN网关的flavor配置为GM时，默认值为sm3。 其他场景下，默认值为sha2-256。                                                               |
  | encryption_algorithm     | String                                                  | 否    | - 功能说明：加密算法。  - 取值范围： 当VPN网关的flavor配置为GM时，取值范围为sm4。 其他场景下取值范围为aes-256-gcm-16，aes-128-gcm-16，aes-256，aes-192，aes-128，3des。 其中，3des，aes-128，aes-192，aes-256安全性较低，请慎用。   - 默认值： 当VPN网关的flavor配置为GM时，默认值为sm4； 其他场景下，默认值为aes-128。    |
  | dh_group                 | String                                                  | 否    | - 功能说明：第一阶段密钥交换使用的DH组。 当VPN网关的flavor配置为GM时，该字段不用填写。   - 取值范围：group1，group2，group5，group14，group15，group16，group19，group20，group21。 其中，group1，group2，group5，group14安全性较低，请慎用。   - 默认值：group15。                                                                                                                                                                                       |
  | authentication_method    | String                                                  | 否    | - 功能说明：ike协商时的认证方法。  - 取值范围： pre-share：预共享密钥。 digital-envelope-v2：国密数字信封。   - 默认值： 非国密网关pre-share，国密网关digital-envelope-v2。                                                                                                                                                                                                                                                           |
  | lifetime_seconds         | Integer                                                 | 否    | - 功能说明：表示SA的生存周期，当该生存周期超时后IKE SA将自动更新。  - 取值范围：60-604800，单位：秒。  - 默认值：86400。                                                                                                                                                                                                                                                                                                                                                                                                                                    |
  | local_id_type            | String                                                  | 否    | - 功能说明：本端ID类型。 当VPN网关的flavor配置为GM时，该字段不用填写。   - 取值范围： - ip：IP类型。    - 默认值：ip。                                                                                                                                                                                                             |
  | local_id                 | String                                                  | 否    | - 功能说明：本端ID。 当VPN网关的flavor配置为GM时，该字段不用填写。   - 约束： 当local_id_type为ip时，可不填，填写需满足IPv4格式。 当local_id_type为fqdn时，最大长度255个字符，只能由大小写字母、数字和特殊符号组成，不支持以下特殊字符：\&、\<、\>、\[、\]、\\、空格、？，区分大小写。当local_id_type为fqdn时必须填写，需要和对端设备的peer_id一致。                                                                                                                                                                                                 |
  | peer_id_type             | String                                                  | 否    | - 功能说明：对端ID类型。 当VPN网关的flavor配置为GM时，该字段不用填写。   - 取值范围： - ip：IP类型    - 默认值：ip。                                                                                                                                                                                                                              |
  | peer_id                  | String                                                  | 否    | - 功能说明：对端ID。 当VPN网关的flavor配置为GM时，该字段不用填写。   - 约束： 当local_id_type为ip时，可不填，填写需满足IPv4格式。 当local_id_type为fqdn时，最大长度255个字符，只能由大小写字母、数字和特殊符号组成，不支持以下特殊字符：\&、\<、\>、\[、\]、\\、空格、？，区分大小写。当peer_id_type为fqdn时必须填写，需要和对端设备的local_id一致。                                                                                                                                                                                                 |
  | dpd                      | [Dpd] object | 否    | 对等体存活检测对象。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
     
   表6Dpd 
  | 名称       | 类型      | 是否必选 | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
  |:---|:---|:---|:---|
  | timeout  | Integer | 否    | - 功能说明：对等体存活检测报文重传间隔。  - 取值范围：2-60，单位：秒。  - 默认值：15。                                                                                                                                                                                                   |
  | interval | Integer | 否    | - 功能说明：对等体存活检测空闲时间。  - 取值范围：10-3600，单位：秒。  - 默认值：30。                                                                                                                                                                                                          |
  | msg      | String  | 否    | - 功能说明：对等体存活检测报文格式。  - 取值范围： seq-hash-notify：指定DPD报文中的载荷顺序是hash-notify。 seq-notify-hash：指定DPD报文中的载荷顺序是notify-hash。   - 默认值：seq-hash-notify。   |
     
   表7IpsecPolicy 
  | 名称                       | 类型      | 是否必选 | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
  |:---|:---|:---|:---|
  | authentication_algorithm | String  | 否    | - 功能说明：认证算法。  - 取值范围： 当VPN网关的flavor配置为GM时，取值范围为sm3。 其他场景下取值范围为sha2-512，sha2-384，sha2-256，sha1，md5。 其中，sha1和md5安全性较低，请慎用。   - 默认值： 当VPN网关的flavor配置为GM时，默认值为sm3。 其他场景下，默认值为sha2-256。                                                    |
  | encryption_algorithm     | String  | 否    | - 功能说明：加密算法。  - 取值范围： 当VPN网关的flavor配置为GM时，取值范围为sm4。 其他场景下取值范围为aes-256-gcm-16，aes-128-gcm-16，aes-256，aes-192，aes-128，3des。 其中，3des，aes-128，aes-192，aes-256安全性较低，请慎用。   - 默认值： 当VPN网关的flavor配置为GM时，默认值为sm4。 其他场景下，默认值为aes-128。    |
  | pfs                      | String  | 否    | - 功能说明：PFS使用的DH密钥组。 当VPN网关的flavor配置为GM时，该字段不用填写。   - 取值范围：group1，group2，group5，group14，group15，group16，group19，group20，group21，disable。 其中，group1，group2，group5，group14安全性较低，请慎用。   - 默认值：group15。                                                                                                                                                                               |
  | transform_protocol       | String  | 否    | - 功能说明：传输协议。  - 取值范围： esp：封装安全协议。   - 默认值：esp。                                                                                                                                                                                                                                                                                                                                                                                          |
  | lifetime_seconds         | Integer | 否    | - 功能说明：表示配置IPSec连接建立的隧道以时间为基准的生存周期。  - 取值范围：30-604800，单位：秒。  - 默认值：3600。                                                                                                                                                                                                                                                                                                                                                                                                                                               |
  | encapsulation_mode       | String  | 否    | - 功能说明：报文封装模式。  - 取值范围： tunnel：隧道模式。   - 默认值：tunnel。                                                                                                                                                                                                                                                                                                                                                                                           |
     
   表8VpnResourceTag 
  | 名称    | 类型     | 是否必选 | 描述                                                                                                                                                                                                                                                                                                                     |
  |:---|:---|:---|:---|
  | key   | String | 是    | - 功能说明：标签的键。  - 取值范围：1-128个字符，支持数字、英文字母、中文、西班牙语、葡语、空格，以及以下字符：_.:=+-@。   |
  | value | String | 是    | - 功能说明：标签的值。  - 取值范围：0-255个字符，支持数字、英文字母、中文、西班牙语、葡语、空格，以及以下字符：_.:=+-@。     |
     
  
- 请求样例
  1. 批量创建静态路由模式连接。
     ```
     POST https://{Endpoint}/v5/{project_id}/vpn-connections/batch-create
     {
         "vpn_connections": [
             {
                 "vgw_ip": "0d0f4af1-42b9-41eb-97b9-b4d41a0bf9c4",
                 "cgw_id": "12f3577a-cbd8-4602-b68c-ecbf792fcec5",
                 "vgw_id": "8030f6d6-32a8-4d20-a7f8-50a7a826e2f8",
                 "peer_subnets": [
                     "192.168.2.0/24"
                 ],
                 "psk": "abcd****"
             },
             {
                 "vgw_ip": "1fb97767-d780-4d8b-83bb-6f878f662005",
                 "cgw_id": "12f3577a-cbd8-4602-b68c-ecbf792fcec5",
                 "vgw_id": "8030f6d6-32a8-4d20-a7f8-50a7a826e2f8",
                 "peer_subnets": [
                     "192.168.2.0/24"
                 ],
                 "psk": "abcd****"
             }
         ]
     }
     ```
     
  
  2. 批量创建策略模式连接。
     ```
     POST https://{Endpoint}/v5/{project_id}/vpn-connections/batch-create
     {
         "vpn_connections": [
             {
                 "vgw_ip": "0d0f4af1-42b9-41eb-97b9-b4d41a0bf9c4",
                 "cgw_id": "12f3577a-cbd8-4602-b68c-ecbf792fcec5",
                 "vgw_id": "8030f6d6-32a8-4d20-a7f8-50a7a826e2f8",
                 "style": "policy",
                 "peer_subnets": [
                     "192.168.2.0/24"
                 ],
                 "psk": "abcd****",
                 "policy_rules": [
                     {
                         "source": "10.0.0.0/24",
                         "destination": [
                             "192.168.0.0/24"
                         ]
                     }
                 ]
             },
             {
                 "vgw_ip": "1fb97767-d780-4d8b-83bb-6f878f662005",
                 "cgw_id": "12f3577a-cbd8-4602-b68c-ecbf792fcec5",
                 "vgw_id": "8030f6d6-32a8-4d20-a7f8-50a7a826e2f8",
                 "style": "policy",
                 "peer_subnets": [
                     "192.168.2.0/24"
                 ],
                 "psk": "abcd****",
                 "policy_rules": [
                     {
                         "source": "10.0.0.0/24",
                         "destination": [
                             "192.168.0.0/24"
                         ]
                     }
                 ]
             }
         ]
     }
     ```
     
  
  3. 批量创建bgp路由模式连接。
     ```
     POST https://{Endpoint}/v5/{project_id}/vpn-connections/batch-create
     {
         "vpn_connections": [
             {
                 "name": "vpn-1655",
                 "vgw_ip": "0d0f4af1-42b9-41eb-97b9-b4d41a0bf9c4",
                 "cgw_id": "12f3577a-cbd8-4602-b68c-ecbf792fcec5",
                 "vgw_id": "8030f6d6-32a8-4d20-a7f8-50a7a826e2f8",
                 "style": "bgp",
                 "peer_subnets": [
                     "192.168.2.0/24"
                 ],
                 "tunnel_local_address": "169.254.56.225/30",
                 "tunnel_peer_address": "169.254.56.226/30",
                 "psk": "abcd****",
                 "ikepolicy": {
                     "ike_version": "v2",
                     "authentication_algorithm": "sha2-512",
                     "encryption_algorithm": "aes-256",
                     "dh_group": "group16",
                     "lifetime_seconds": 172800,
                     "local_id_type": "fqdn",
                     "local_id": "123***",
                     "peer_id_type": "fqdn",
                     "peer_id": "456***",
                     "dpd": {
                         "timeout": 30,
                         "interval": 60,
                         "msg": "seq-notify-hash"
                     }
                 },
                 "ipsecpolicy": {
                     "authentication_algorithm": "sha2-512",
                     "encryption_algorithm": "aes-256",
                     "pfs": "group16",
                     "transform_protocol": "esp",
                     "lifetime_seconds": 7200,
                     "encapsulation_mode": "tunnel"
                 }
             },
             {
                 "name": "vpn-1341",
                 "vgw_ip": "1fb97767-d780-4d8b-83bb-6f878f662005",
                 "cgw_id": "12f3577a-cbd8-4602-b68c-ecbf792fcec5",
                 "vgw_id": "8030f6d6-32a8-4d20-a7f8-50a7a826e2f8",
                 "style": "bgp",
                 "peer_subnets": [
                     "192.168.2.0/24"
                 ],
                 "tunnel_local_address": "169.254.56.225/30",
                 "tunnel_peer_address": "169.254.56.226/30",
                 "psk": "abcd****",
                 "ikepolicy": {
                     "ike_version": "v2",
                     "authentication_algorithm": "sha2-512",
                     "encryption_algorithm": "aes-256",
                     "dh_group": "group16",
                     "lifetime_seconds": 172800,
                     "local_id_type": "fqdn",
                     "local_id": "123***",
                     "peer_id_type": "fqdn",
                     "peer_id": "456***",
                     "dpd": {
                         "timeout": 30,
                         "interval": 60,
                         "msg": "seq-notify-hash"
                     }
                 },
                 "ipsecpolicy": {
                     "authentication_algorithm": "sha2-512",
                     "encryption_algorithm": "aes-256",
                     "pfs": "group16",
                     "transform_protocol": "esp",
                     "lifetime_seconds": 7200,
                     "encapsulation_mode": "tunnel"
                 }
             }
         ]
     }
     ```
     
  
  4. 批量创建国密型静态路由模式连接。 预置条件：
     vgw_id对应的VPN网关为国密型VPN网关且已导入国密证书。
     cgw_id对应的对端网关已导入对端网关证书。
     ```
     POST https://{Endpoint}/v5/{project_id}/vpn-connections/batch-create
     {
         "vpn_connections": [
             {
                 "vgw_ip": "da21634b-56bf-4137-bc80-b1a0937294ec",
                 "cgw_id": "12f3577a-cbd8-4602-b68c-ecbf792fcec5",
                 "vgw_id": "768b2790-ccc9-4257-91b3-e008747db9e6",
                 "peer_subnets": [
                     "192.168.2.0/24"
                 ]
             },
             {
                 "vgw_ip": "36857950-95e2-4e57-9c53-da7fe0f9841b",
                 "cgw_id": "12f3577a-cbd8-4602-b68c-ecbf792fcec5",
                 "vgw_id": "768b2790-ccc9-4257-91b3-e008747db9e6",
                 "peer_subnets": [
                     "192.168.2.0/24"
                 ]
             }
         ]
     }
     ```
     
   
 
#### 响应消息
- 响应参数 返回状态码为 201: successful operation。
  表9响应Body参数列表 
  | 名称              | 类型                                                                                                                                      | 描述                   |
  |:---|:---|:---|
  | vpn_connections | Array of [CreateResponseVpnConnection] object | vpn_connections对象数组。 |
  | request_id      | String                                                                                                                                  | 请求ID。                |
     
   表10CreateResponseVpnConnection 
  | 名称                    | 类型                                                                                   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
  |:---|:---|:---|
  | id                    | String                                                                               | - 功能说明：VPN连接ID。  - 格式：36位UUID。                                                                                                                                                                                                                                                                                       |
  | name                  | String                                                                               | - 功能说明：VPN连接名称。  - 取值范围：1-64个字符，支持数字、英文字母、中文(\\u4e00 - \\u9fa5)、_(下划线)、-(中划线)。                                                                                                                                                                                                                                           |
  | vgw_id                | String                                                                               | - 功能说明：VPN网关ID。  - 格式：36位UUID。                                                                                                                                                                                                                                                                                              |
  | vgw_ip                | String                                                                               | - 功能说明： VPN网关EIP的ID或接入私网IP。  - 格式：36位UUID或点分十进制IPv4地址（如192.168.45.7）。                                                                                                                                                                                                                                             |
  | style                 | String                                                                               | - 功能说明：连接模式。  - 取值范围： POLICY: 策略模式。 STATIC: 静态路由模式。 BGP: bgp路由模式。 POLICY-TEMPLATE: 策略模板模式。    |
  | cgw_id                | String                                                                               | - 功能说明：对端网关ID。  - 格式：36位UUID。                                                                                                                                                                                                                                                                                 |
  | peer_subnets          | Array of String                                                                      | IPv4对端子网。当VPN网关的关联模式为ER并且style字段为BGP或POLICY、或VPN网关的IP协议版本号为IPv6时不返回。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
  | peer_subnets_v6       | Array of String                                                                      | IPv6对端子网。当VPN网关的关联模式为ER并且style字段为BGP或POLICY、或VPN网关的IP协议版本号为IPv4时不返回。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
  | tunnel_local_address  | String                                                                               | 路由模式下配置在VPN网关上的tunnel接口地址。仅当style为STATIC或BGP时有效。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
  | tunnel_peer_address   | String                                                                               | 路由模式下配置在用户侧设备上的tunnel接口地址。仅当style为STATIC或BGP时有效。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
  | enable_nqa            | Boolean                                                                              | - 功能说明：开启NQA检测。仅当style为STATIC时返回。  - 取值范围：true，false。                                                                                                                                                                                                                                                                   |
  | enable_health_check   | Boolean                                                                              | - 功能说明：开启健康检查。当style为POLICY-TEMPLATE时不返回。  - 取值范围：true，false。                                                                                                                                                                                                                                                        |
  | policy_rules          | Array of [PolicyRule] objects             | IPv4策略模式的策略规则组。仅当style为POLICY且VPN网关的IP协议版本号为IPv4时返回实际的策略规则组。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
  | policy_rules_v6       | Array of [PolicyRule] objects             | IPv6策略模式的策略规则组。仅当style为POLICY且VPN网关的IP协议版本号为IPv6时返回实际的策略规则组。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
  | ikepolicy             | [IkePolicy] object                        | ike策略对象。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
  | ipsecpolicy           | [IpsecPolicy] object                      | ipsec策略对象。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
  | created_at            | String                                                                               | - 创建时间。  - UTC时间格式：*yyyy-MM-ddTHH:mm:ss.SSSZ。*                                                                                                                                                                                                                                                                    |
  | updated_at            | String                                                                               | - 最后一次更新时间。  - UTC时间格式：*yyyy-MM-ddTHH:mm:ss.SSSZ。*                                                                                                                                                                                                                                                                     |
  | enterprise_project_id | String                                                                               | - 功能说明：企业项目ID。  - 格式：36位UUID。与vgw_id所标识VPN网关的企业项目ID一致。                                                                                                                                                                                                                                                         |
  | ha_role               | String                                                                               | - 功能说明：主备模式VPN网关下的连接时，'master'表示主连接，'slave'表示备连接。双活模式下的连接ha_role都是'master'。  - 默认值：master。                                                                                                                                                                                                                            |
  | tags                  | Array of [VpnResourceTag] objects | 标签列表。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
     
   表11PolicyRule 
  | 名称          | 类型              | 描述                                                                                                                                                                                                                                                                                                                                                                                                            |
  |:---|:---|:---|
  | rule_index  | Integer         | - 功能说明：规则ID。  - 取值范围：0-50。  - 注：该字段已经废弃，但仍然保留兼容性支持，建议不要使用该字段。   |
  | source      | String          | 源地址网段。                                                                                                                                                                                                                                                                                                                                                                                                        |
  | destination | Array of String | 目的地址网段。单个IPv4网段格式示例：192.168.52.0/24。单个IPv6网段格式示例：16af:cacc:1097::/48。每个PolicyRule最多返回50个。                                                                                                                                                                                                                                                                                                                     |
     
   表12IkePolicy 
  | 名称                       | 类型                                                      | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
  |:---|:---|:---|
  | ike_version              | String                                                  | - 功能说明：IKE版本号。  - 取值范围：v1, v2。                                                                                                                                                                                      |
  | phase1_negotiation_mode  | String                                                  | - 功能说明：协商模式。仅当IKE版本为v1时返回。  - 取值范围： main：主模式，协商过程安全性高。 aggressive：野蛮模式，协商快速且协商成功率高。             |
  | authentication_algorithm | String                                                  | - 功能说明：认证算法。  - 取值范围：sha2-512，sha2-384，sha2-256，sha1，md5，sm3。                                                                                                                                                         |
  | encryption_algorithm     | String                                                  | - 功能说明：加密算法。  - 取值范围：aes-256-gcm-16，aes-128-gcm-16，aes-256，aes-192，aes-128，3des，sm4。                                                                                                                                |
  | dh_group                 | String                                                  | - 功能说明：第一阶段密钥交换使用的DH组，当VPN网关flavor为GM时不返回。  - 取值范围：group1，group2，group5，group14，group15，group16，group19，group20，group21。                                                                                      |
  | authentication_method    | String                                                  | - 功能说明：ike协商时的认证方法。  - 取值范围： pre-share：预共享密钥。 digital-envelope-v2：国密数字信封。                                |
  | lifetime_seconds         | Integer                                                 | - 功能说明：表示SA的生存周期，当该生存周期超时后IKE SA将自动更新。  - 取值范围：60-604800，单位：秒。                                                                                                                                                        |
  | local_id_type            | String                                                  | - 功能说明：本端ID类型，当VPN网关flavor为GM时不返回。  - 取值范围： - ip：IP类型。     |
  | local_id                 | String                                                  | 本端ID。当local_id_type为ip时返回创建或更新VPN连接时指定的本端ID，如果未指定本端ID则返回VPN连接所使用的VPN网关IP；当local_id_type为fqdn时返回创建或更新VPN连接时指定的本端ID。 当VPN网关flavor为GM时不返回。                                                                                                                                                                                                                                                                              |
  | peer_id_type             | String                                                  | - 功能说明：对端ID类型，当VPN网关flavor为GM时不返回。  - 取值范围： - ip：IP类型               |
  | peer_id                  | String                                                  | 对端ID。当peer_id_type为ip时返回创建或更新VPN连接时指定的对端ID，如果未指定则返回对端网关的IP；当peer_id_type为fqdn时返回创建或更新VPN连接时指定的对端ID。 当VPN网关flavor为GM时不返回。                                                                                                                                                                                                                                                                                              |
  | dpd                      | [Dpd] object | 对等体存活检测对象。                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
     
   表13Dpd 
  | 名称       | 类型      | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
  |:---|:---|:---|
  | timeout  | Integer | - 功能说明：对等体存活检测报文重传间隔。  - 取值范围：2-60，单位：秒。                                                                                                                                                                                        |
  | interval | Integer | - 功能说明：对等体存活检测空闲时间。  - 取值范围：10-3600，单位：秒。                                                                                                                                                                                        |
  | msg      | String  | - 功能说明：对等体存活检测报文格式。  - 取值范围： seq-hash-notify：指定DPD报文中的载荷顺序是hash-notify。 seq-notify-hash：指定DPD报文中的载荷顺序是notify-hash。    |
     
   表14IpsecPolicy 
  | 名称                       | 类型      | 描述                                                                                                                                                                                                                                                                                                                                                                           |
  |:---|:---|:---|
  | authentication_algorithm | String  | - 功能说明：认证算法。  - 取值范围：sha2-512，sha2-384，sha2-256，sha1，md5，sm3。                                                                  |
  | encryption_algorithm     | String  | - 功能说明：加密算法。  - 取值范围：aes-256-gcm-16，aes-128-gcm-16，aes-256，aes-192，aes-128，3des，sm4。                                            |
  | pfs                      | String  | - 功能说明：PFS使用的DH密钥组，当VPN网关flavor为GM时不返回。  - 取值范围：group1，group2，group5，group14，group15，group16，group19，group20，group21，disable。   |
  | transform_protocol       | String  | - 功能说明：传输协议。  - 取值范围： esp：封装安全协议。                       |
  | lifetime_seconds         | Integer | - 功能说明：表示配置IPSec连接建立的隧道以时间为基准的生存周期。  - 取值范围：30-604800，单位：秒。                                                                 |
  | encapsulation_mode       | String  | - 功能说明：报文封装模式。  - 取值范围： tunnel：隧道模式。                         |
     
   表15VpnResourceTag 
  | 名称    | 类型     | 描述                                                                                                                                                                                                                                                                                                                         |
  |:---|:---|:---|
  | key   | String | - 功能说明：标签的键。  - 取值范围：1-128个字符，支持数字、英文字母、中文、西班牙语、葡语、空格，以及以下字符：_.:=+-@。    |
  | value | String | - 功能说明：标签的值。  - 取值范围：0-255个字符，支持数字、英文字母、中文、西班牙语、葡语、空格，以及以下字符：_.:=+-@。   |
     
  - 响应样例
    1. 批量创建静态路由模式连接的响应。
       ```
       {
           "vpn_connections": [
               {
                   "id": "cf91c03c-9679-495f-a201-3622a1aec817",
                   "name": "vpn-b8fa",
                   "vgw_id": "8030f6d6-32a8-4d20-a7f8-50a7a826e2f8",
                   "vgw_ip": "0d0f4af1-42b9-41eb-97b9-b4d41a0bf9c4",
                   "style": "STATIC",
                   "cgw_id": "12f3577a-cbd8-4602-b68c-ecbf792fcec5",
                   "peer_subnets": [
                       "192.168.2.0/24"
                   ],
                   "tunnel_local_address": "169.254.12.37/30",
                   "tunnel_peer_address": "169.254.12.38/30",
                   "enable_nqa": false,
                   "enable_health_check": true,            
                   "policy_rules": [],
                   "ikepolicy": {
                       "ike_version": "v2",
                       "authentication_algorithm": "sha2-256",
                       "encryption_algorithm": "aes-128",
                       "dh_group": "group15",
                       "authentication_method": "pre-share",
                       "lifetime_seconds": 86400,
                       "local_id_type": "ip",
                       "local_id": "10.***.***.173",
                       "peer_id_type": "ip",
                       "peer_id": "2.***.***.2",
                       "dpd": {
                           "interval": 30,
                           "timeout": 15,
                           "msg": "seq-hash-notify"
                       }
                   },
                   "ipsecpolicy": {
                       "authentication_algorithm": "sha2-256",
                       "encryption_algorithm": "aes-128",
                       "pfs": "group15",
                       "transform_protocol": "esp",
                       "lifetime_seconds": 3600,
                       "encapsulation_mode": "tunnel"
                   },
                   "created_at": "2025-02-21T03:53:23.557Z",
                   "updated_at": "2025-02-21T03:53:23.557Z",
                   "enterprise_project_id": "0",
                   "ha_role": "master",
                   "tags": [],
                   "policy_rules_v6": []
               },
               {
                   "id": "64c09578-a23c-4d9d-9c64-56b2f9a74695",
                   "name": "vpn-ec21",
                   "vgw_id": "8030f6d6-32a8-4d20-a7f8-50a7a826e2f8",
                   "vgw_ip": "1fb97767-d780-4d8b-83bb-6f878f662005",
                   "style": "STATIC",
                   "cgw_id": "12f3577a-cbd8-4602-b68c-ecbf792fcec5",
                   "peer_subnets": [
                       "192.168.2.0/24"
                   ],
                   "tunnel_local_address": "169.254.60.229/30",
                   "tunnel_peer_address": "169.254.60.230/30",
                   "enable_nqa": false,
                   "enable_health_check": true,            
                   "policy_rules": [],
                   "ikepolicy": {
                       "ike_version": "v2",
                       "authentication_algorithm": "sha2-256",
                       "encryption_algorithm": "aes-128",
                       "dh_group": "group15",
                       "authentication_method": "pre-share",
                       "lifetime_seconds": 86400,
                       "local_id_type": "ip",
                       "local_id": "215.***.***.55",
                       "peer_id_type": "ip",
                       "peer_id": "2.***.***.2",
                       "dpd": {
                           "interval": 30,
                           "timeout": 15,
                           "msg": "seq-hash-notify"
                       }
                   },
                   "ipsecpolicy": {
                       "authentication_algorithm": "sha2-256",
                       "encryption_algorithm": "aes-128",
                       "pfs": "group15",
                       "transform_protocol": "esp",
                       "lifetime_seconds": 3600,
                       "encapsulation_mode": "tunnel"
                   },
                   "created_at": "2025-02-21T03:53:23.226Z",
                   "updated_at": "2025-02-21T03:53:23.226Z",
                   "enterprise_project_id": "0",
                   "ha_role": "master",
                   "tags": [],
                   "policy_rules_v6": []
               }
           ],
           "request_id": "3c53db019753c69323303c198af58a85"
       }
       ```
       
    
    2. 批量创建策略模式连接的响应。
       ```
       {
           "vpn_connections": [
               {
                   "id": "db06a7cb-e3b5-4c8c-b682-40ed54e8eb54",
                   "name": "vpn-ed37",
                   "vgw_id": "8030f6d6-32a8-4d20-a7f8-50a7a826e2f8",
                   "vgw_ip": "1fb97767-d780-4d8b-83bb-6f878f662005",
                   "style": "POLICY",
                   "cgw_id": "12f3577a-cbd8-4602-b68c-ecbf792fcec5",
                   "peer_subnets": [
                       "192.168.2.0/24"
                   ],
                   "tunnel_local_address": "169.254.44.197/30",
                   "tunnel_peer_address": "169.254.44.198/30",
                   "enable_health_check": true,  
                   "policy_rules": [
                       {
                           "rule_index": 1,
                           "source": "192.168.37.0/24",
                           "destination": [
                               "192.168.2.0/24"
                           ]
                       }
                   ],
                   "ikepolicy": {
                       "ike_version": "v2",
                       "authentication_algorithm": "sha2-256",
                       "encryption_algorithm": "aes-128",
                       "dh_group": "group15",
                       "authentication_method": "pre-share",
                       "lifetime_seconds": 86400,
                       "local_id_type": "ip",
                       "local_id": "215.***.***.55",
                       "peer_id_type": "ip",
                       "peer_id": "2.***.***.2",
                       "dpd": {
                           "interval": 30,
                           "timeout": 15,
                           "msg": "seq-hash-notify"
                       }
                   },
                   "ipsecpolicy": {
                       "authentication_algorithm": "sha2-256",
                       "encryption_algorithm": "aes-128",
                       "pfs": "group15",
                       "transform_protocol": "esp",
                       "lifetime_seconds": 3600,
                       "encapsulation_mode": "tunnel"
                   },
                   "created_at": "2025-02-21T03:59:50.341Z",
                   "updated_at": "2025-02-21T03:59:50.341Z",
                   "enterprise_project_id": "0",
                   "ha_role": "master",
                   "tags": [],
                   "policy_rules_v6": []
               },
               {
                   "id": "9f5220fd-f674-420c-9df7-6b6420a3ae99",
                   "name": "vpn-d0c2",
                   "vgw_id": "8030f6d6-32a8-4d20-a7f8-50a7a826e2f8",
                   "vgw_ip": "0d0f4af1-42b9-41eb-97b9-b4d41a0bf9c4",
                   "style": "POLICY",
                   "cgw_id": "12f3577a-cbd8-4602-b68c-ecbf792fcec5",
                   "peer_subnets": [
                       "192.168.2.0/24"
                   ],
                   "tunnel_local_address": "169.254.192.61/30",
                   "tunnel_peer_address": "169.254.192.62/30",
                   "enable_health_check": true,  
                   "policy_rules": [
                       {
                           "rule_index": 1,
                           "source": "192.168.37.0/24",
                           "destination": [
                               "192.168.2.0/24"
                           ]
                       }
                   ],
                   "ikepolicy": {
                       "ike_version": "v2",
                       "authentication_algorithm": "sha2-256",
                       "encryption_algorithm": "aes-128",
                       "dh_group": "group15",
                       "authentication_method": "pre-share",
                       "lifetime_seconds": 86400,
                       "local_id_type": "ip",
                       "local_id": "10.***.***.173",
                       "peer_id_type": "ip",
                       "peer_id": "2.***.***.2",
                       "dpd": {
                           "interval": 30,
                           "timeout": 15,
                           "msg": "seq-hash-notify"
                       }
                   },
                   "ipsecpolicy": {
                       "authentication_algorithm": "sha2-256",
                       "encryption_algorithm": "aes-128",
                       "pfs": "group15",
                       "transform_protocol": "esp",
                       "lifetime_seconds": 3600,
                       "encapsulation_mode": "tunnel"
                   },
                   "created_at": "2025-02-21T03:59:50.651Z",
                   "updated_at": "2025-02-21T03:59:50.651Z",
                   "enterprise_project_id": "0",
                   "ha_role": "master",
                   "tags": [],
                   "policy_rules_v6": []
               }
           ],
           "request_id": "81237dad5e1338b1818cd6582781b610"
       }
       ```
       
    
    3. 批量创建bgp路由模式连接的响应。
       ```
       {
           "vpn_connections": [
               {
                   "id": "5ddf5d02-c746-4075-be4b-95e9213e1c3c",
                   "name": "vpn-1655",
                   "vgw_id": "8030f6d6-32a8-4d20-a7f8-50a7a826e2f8",
                   "vgw_ip": "0d0f4af1-42b9-41eb-97b9-b4d41a0bf9c4",
                   "style": "BGP",
                   "cgw_id": "12f3577a-cbd8-4602-b68c-ecbf792fcec5",
                   "peer_subnets": [
                       "192.168.2.0/24"
                   ],
                   "tunnel_local_address": "169.254.56.225/30",
                   "tunnel_peer_address": "169.254.56.226/30",
                   "enable_hub": false,
                   "enable_health_check": true,  
                   "policy_rules": [],
                   "ikepolicy": {
                       "ike_version": "v2",
                       "authentication_algorithm": "sha2-512",
                       "encryption_algorithm": "aes-256",
                       "dh_group": "group16",
                       "authentication_method": "pre-share",
                       "lifetime_seconds": 172800,
                       "local_id_type": "fqdn",
                       "local_id": "123***",
                       "peer_id_type": "fqdn",
                       "peer_id": "456***",
                       "dpd": {
                           "interval": 60,
                           "timeout": 30,
                           "msg": "seq-notify-hash"
                       }
                   },
                   "ipsecpolicy": {
                       "authentication_algorithm": "sha2-512",
                       "encryption_algorithm": "aes-256",
                       "pfs": "group16",
                       "transform_protocol": "esp",
                       "lifetime_seconds": 7200,
                       "encapsulation_mode": "tunnel"
                   },
                   "created_at": "2025-02-21T06:50:25.238Z",
                   "updated_at": "2025-02-21T06:50:25.238Z",
                   "enterprise_project_id": "0",
                   "ha_role": "master",
                   "tags": [],
                   "policy_rules_v6": []
               },
               {
                   "id": "bb3632dd-f517-4e94-96b7-977c70d28966",
                   "name": "vpn-1341",
                   "vgw_id": "8030f6d6-32a8-4d20-a7f8-50a7a826e2f8",
                   "vgw_ip": "1fb97767-d780-4d8b-83bb-6f878f662005",
                   "style": "BGP",
                   "cgw_id": "12f3577a-cbd8-4602-b68c-ecbf792fcec5",
                   "peer_subnets": [
                       "192.168.2.0/24"
                   ],
                   "tunnel_local_address": "169.254.56.225/30",
                   "tunnel_peer_address": "169.254.56.226/30",
                   "enable_hub": false,
                   "enable_health_check": true,  
                   "policy_rules": [],
                   "ikepolicy": {
                       "ike_version": "v2",
                       "authentication_algorithm": "sha2-512",
                       "encryption_algorithm": "aes-256",
                       "dh_group": "group16",
                       "authentication_method": "pre-share",
                       "lifetime_seconds": 172800,
                       "local_id_type": "fqdn",
                       "local_id": "123***",
                       "peer_id_type": "fqdn",
                       "peer_id": "456***",
                       "dpd": {
                           "interval": 60,
                           "timeout": 30,
                           "msg": "seq-notify-hash"
                       }
                   },
                   "ipsecpolicy": {
                       "authentication_algorithm": "sha2-512",
                       "encryption_algorithm": "aes-256",
                       "pfs": "group16",
                       "transform_protocol": "esp",
                       "lifetime_seconds": 7200,
                       "encapsulation_mode": "tunnel"
                   },
                   "created_at": "2025-02-21T06:50:25.5Z",
                   "updated_at": "2025-02-21T06:50:25.5Z",
                   "enterprise_project_id": "0",
                   "ha_role": "master",
                   "tags": [],
                   "policy_rules_v6": []
               }
           ],
           "request_id": "938ea2bba48836a429c741bd6f7627a4"
       }
       ```
       
     
   
 
#### 状态码
请参见[状态码](https://support.huaweicloud.com/api-vpn/vpn_api_0052.html)。
