# CreateDisks

## 1. 接口描述

本接口(CreateDisks)用于创建一个或多个云硬盘。

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

* 预付费云硬盘的购买会预先扣除本次云硬盘购买所需金额，如果余额不足，请求将会失败。后付费云硬盘购买时需要确保账户账号状态正常。
* 本接口为异步接口，当创建云硬盘请求下发成功后会返回一个云硬盘`ID`列表，此时创建云硬盘操作并未立即完成。云硬盘创建结果可以通过 [DescribeDisks](/api-reference/cn/compute/vm/disk/describedisks.md) 查询。如果能够查询到对应云硬盘数据且状态为**AVAILABLE**则代表云硬盘创建成功，如果创建时指定了挂载到某个实例，则当状态为**IN\_USE**时则代表挂载成功。
  {% endhint %}

## 2. 请求参数

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

| 参数名称             | 必选 | 类型                                                                             | 描述                                                                             |
| ---------------- | -- | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ |
| chargeType       | 是  | [ChargeType](/api-reference/cn/compute/vm/datastructure.md#chargetype)         | <p>付费类型。</p><p>PREPAID：预付费，即包年包月。</p><p>POSTPAID：后付费。</p>                      |
| diskName         | 是  | String                                                                         | <p>云硬盘名称。</p><p>必须以数字或字母开头或结尾，长度1-64字符，仅支持字母、数字、-和英文句点(.)。</p>                 |
| diskSize         | 是  | Integer                                                                        | 云硬盘大小，单位GB。                                                                    |
| chargePrepaid    | 否  | [ChargePrepaid](/api-reference/cn/compute/vm/datastructure.md#chargeprepaid)   | <p>预付费模式，即包年包月相关参数设置。</p><p>若指定云硬盘的付费模式为预付费则该参数必传。</p>                         |
| diskAmount       | 否  | Integer                                                                        | <p>云硬盘创建数量。</p><p>最小值与默认值均为1，最大值50。</p><p>可选值范围：\[1, 50]</p><p>默认值：1</p>       |
| instanceId       | 否  | String                                                                         | <p>创建后需要挂载的实例ID。</p><p>指定实例ID将会为实例所在的可用区创建数据盘并挂载到实例上。</p>                      |
| zoneId           | 否  | String                                                                         | <p>云硬盘所属的可用区ID。</p><p>如果指定了instanceId，则该字段无效。</p>                              |
| resourceGroupId  | 否  | String                                                                         | 云硬盘所在的资源组ID，如不指定则放入默认资源组。                                                      |
| diskCategory     | 否  | String                                                                         | <p>云硬盘种类。</p><p>STANDARD：标准云盘。</p><p>SSD：固态硬盘。</p><p>默认为SSD。</p><p>默认值：SSD</p> |
| marketingOptions | 否  | [MarketingInfo](/api-reference/cn/compute/vm/datastructure.md#marketinginfo)   | 市场营销活动相关信息。                                                                    |
| tags             | 否  | [TagAssociation](/api-reference/cn/compute/vm/datastructure.md#tagassociation) | <p>创建云硬盘时关联的标签。</p><p>注意：关联标签键不能重复。</p>                                        |

## 3. 响应结果

| 参数名称        | 类型              | 描述                                                       |
| ----------- | --------------- | -------------------------------------------------------- |
| requestId   | String          | <p>唯一请求 ID。</p><p>每次请求都会返回。定位问题时需要提供该次请求的 requestId。</p> |
| diskIds     | Array of String | 云硬盘ID集合。                                                 |
| orderNumber | String          | 订单编号。                                                    |

## 4. 代码示例

{% tabs %}
{% tab title="示例" %}
**1. 创建一个或多个云硬盘。**

```json
POST /api/v2/vm HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: CreateDisks
<Common Request Params>

Request:
{
  "chargeType": "POSTPAID",
  "diskName": "Test-Disk",
  "diskSize": 30,
  "diskAmount": 1,
  "zoneId": "HKG-A"
}

Response:
{
  "requestId": "T842EE571-4490-4AFE-9F17-931030D3B4F9",
  "response": {
    "requestId": "T842EE571-4490-4AFE-9F17-931030D3B4F9",
    "diskIds": [
      "862857204414550690"
    ],
    "orderNumber": "862857208122313378"
  }
}
```

{% 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: 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:

```
GET https://docs.console.zenlayer.com/api-reference/cn/compute/vm/disk/createdisks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
