# CreateVpc

## 1. API Description

This API (CreateVpc) is used to create a global VPC.

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name  | Required | Type                                                                                                   | Description                                                                                                                                                                                              |
| --------------- | -------- | ------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name            | Yes      | String                                                                                                 | <p>Global VPC name to be displayed.</p><p>This parameter must start and end with a number or a letter, containing 2 to 63 characters. Only letters, numbers, - and periods (.) are supported.</p>        |
| cidrBlock       | Yes      | String                                                                                                 | <p>CIDR block of the global VPC.</p><p>The IPv4 CIDR block should be a valid subnet within these ranges:</p><p>10.0.0.0/9 10.128.0.0/9 172.16.0.0/12 192.168.0.0/16</p>                                  |
| mtu             | Yes      | Integer                                                                                                | <p>Maximum Transmission Unit (MTU).</p><p>The optional values are as follows: 1300 , 1500 , 9000</p>                                                                                                     |
| enablePriIpv6   | No       | Boolean                                                                                                | <p>Enable private IPv6 or not. Private IPv6 is disabled by default.</p><p>Default value: false .</p><p>Once enabled, private IPv6 CIDR block function cannot be disabled.</p><p>Default value: false</p> |
| resourceGroupId | No       | String                                                                                                 | <p>Resource group ID where the global VPC resides.</p><p>If the value is empty, the global VPC will belong to the Default Resource Group.</p>                                                            |
| tags            | No       | [TagAssociation](https://docs.console.zenlayer.com/api-reference/compute/datastructure#tagassociation) | <p>Bound tags when creating the VPC.</p><p>Tag keys must be unique.</p>                                                                                                                                  |

## 3. Output Parameters

| Parameter Name | Type   | Description                                                                                                           |
| -------------- | ------ | --------------------------------------------------------------------------------------------------------------------- |
| requestId      | String | <p>The unique request ID, which is returned for each request.</p><p>RequestId is required for locating a problem.</p> |
| vpcId          | String | Global VPC ID.                                                                                                        |

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**Create a global VPC.**

<pre class="language-json"><code class="lang-json"><strong>POST /api/v2/zec HTTP/1.1
</strong>Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: CreateVpc


Request:
{
  "name": "vpcXXX",
  "cidrBlock": "10.0.0.0/9",
  "mtu": 1300,
  "enablePriIpv6": false,
  "resourceGroupId": "xxxx"
}

Response:
{
  "requestId": "TBFC01FCF-6439-4530-ADBC-16809F0C3E8F",
  "response": {
    "requestId": "TBFC01FCF-6439-4530-ADBC-16809F0C3E8F",
    "vpcId": "xxxx"
  }
}
</code></pre>

{% endtab %}
{% endtabs %}

## 5. Developer Resources

Zenlayer Cloud API 2.0 integrates [SDKs](https://docs.console.zenlayer.com/api-reference/api-introduction/toolkit/api-sdk)，to make it easier for you to call APIs. More programming languages will be supported.

## 6. Error Codes

The following only lists the error codes related to the API business logic. For other error codes, see [Common Error Codes](https://docs.console.zenlayer.com/api-reference/api-introduction/instruction/commonerrorcode).

| HTTP Status Code | Error Code                                          | Description                                   |
| ---------------- | --------------------------------------------------- | --------------------------------------------- |
| 400              | INVALID\_CIDR\_BLOCK\_FORMAT                        | Invalid CIDR block format.                    |
| 400              | INVALID\_CIDR\_BLOCK\_NETMASK\_RANGE                | CIDR block range is invalid.                  |
| 400              | INVALID\_CIDR\_BLOCK\_NOT\_EMPTY                    | CIDR block cannot be empty.                   |
| 400              | INVALID\_CIDR\_BLOCK\_NOT\_LAN\_IP                  | CIDR block must be a private IP range.        |
| 400              | INVALID\_IP\_BROADCAST\_ADDRESS                     | The IP address cannot be a broadcast address. |
| 400              | UNSUPPORTED\_OPERATION\_TEAM\_NETWORK\_COUNT\_LIMIT | Global VPC quantity exceeds limit.            |
