> For the complete documentation index, see [llms.txt](https://docs.console.zenlayer.com/api-reference/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.console.zenlayer.com/api-reference/cn/compute/bmc/vpc/createvpc.md).

# CreateVpc

## 1. 接口描述

本接口(CreateVpc)用于本接口用于创建一个私有网络VPC。

#### 准备工作

* 在创建VPC之前，你可以调用`DescribeVpcAvailableRegions`进行查看哪些节点支持VPC的创建。

{% hint style="info" %}
**注意事项**

* 同一个VPC节点能创建的VPC资源个数也是有限制的，详见VPC使用限制，如果需要申请更多资源，请提交Support申请。
* 本接口为异步接口，当创建VPC请求下发成功后会返回一个VPC`ID`列表，此时创建VPC操作并未立即完成。在此期间VPC的状态将会处于`CREATING`，VPC创建结果可以通过调用`DescribeVpcs`接口查询，如果VPC状态由`CREATING`(创建中)变为`AVAILABLE`，则代表VPC创建成功，`CREATE_FAILED`代表VPC创建失败。创建过程中不可对VPC进行任何操作。
  {% endhint %}

## 2. 请求参数

以下请求参数列表仅列出了接口中需要的请求参数

| 参数名称            | 必选 | 类型                                                                              | 描述                                                                 |
| --------------- | -- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
| vpcRegionId     | 是  | String                                                                          | VPC的节点ID。                                                          |
| cidrBlock       | 是  | String                                                                          | VPC的CIDR。                                                          |
| vpcName         | 是  | String                                                                          | <p>VPC的名称。</p><p>范围1到64个字符。仅支持输入字母、数字、-和英文句点(.)。</p>               |
| resourceGroupId | 否  | String                                                                          | <p>VPC所在的资源组ID。</p><p>如果不指定，则会放入默认资源组， 如果用户没有默认资源组权限， 则请求将会失败。</p> |
| tags            | 否  | [TagAssociation](/api-reference/cn/compute/bmc/datastructure.md#tagassociation) | <p>创建VPC时关联的标签。</p><p>注意: 关联标签键不能重复。</p>                           |

## 3. 响应结果

| 参数名称      | 类型     | 描述                                                       |
| --------- | ------ | -------------------------------------------------------- |
| requestId | String | <p>唯一请求 ID。</p><p>每次请求都会返回。定位问题时需要提供该次请求的 requestId。</p> |
| vpcId     | String | VPC的ID。                                                  |

## 4. 代码示例

{% tabs %}
{% tab title="示例" %}
**1. 创建CHI1节点的VPC。**

```json
POST /api/v2/bmc HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: CreateVpc
Request:
{
  "vpcRegionId": "CHI1",
  "cidrBlock": "10.0.0.0/8",
  "vpcName": "Test-VPC"
}
Response:
{
  "requestId": "T3811A0E7-C250-40A2-96AD-08AD759E1BC2",
  "response": {
    "requestId": "T3811A0E7-C250-40A2-96AD-08AD759E1BC2",
    "vpcId": "835957634816289496"
  }
}
```

{% endtab %}
{% endtabs %}

## 5. 开发者工具

Zenlayer Cloud API 2.0 提供了配套的[开发工具集（SDK）](/api-reference/cn/api-introduction/toolkit.md)，未来会陆续支持更多开发语言，方便快速接入和使用Zenlayer的产品和服务。

## 6. 错误码

下面包含业务逻辑中遇到的错误码，其他错误码见[公共错误码](/api-reference/cn/api-introduction/instruction/commonerrorcode.md)

| HTTP状态码 | 错误码 | 说明 |
| ------- | --- | -- |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.console.zenlayer.com/api-reference/cn/compute/bmc/vpc/createvpc.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
