> 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/zec/disk/createdisks.md).

# CreateDisks

## 1. API Description

This API (CreateDisks) is used to create one or more disks.

{% hint style="info" %}
**Notes**

* This interface is asynchronous. After the request to create disks is submitted successfully, a list of disk IDs is returned, but the creation is not completed immediately. The creation result can be queried through [DescribeDisks](/api-reference/zec/disk/describedisks.md). If the corresponding disk data can be queried and its status is `AVAILABLE`, the disk is created successfully. If attaching it to an instance was specified at creation, the status `IN_USE` indicates that the attachment succeeded.
  {% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name         | Required | Type                                                                 | Description                                                                                                                                                                                                                                                                                                                                                                                    |
| ---------------------- | -------- | -------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| zoneId                 | Yes      | String                                                               | <p>ID of the availability zone that the disk belongs to.</p><p>It can be obtained by calling <a href="/api-reference/zec/location/describezones.md">DescribeZones</a>.</p>                                                                                                                                                                                                                     |
| diskSize               | Yes      | Integer                                                              | <p>Storage space.</p><p>Unit: GB.</p>                                                                                                                                                                                                                                                                                                                                                          |
| instanceChargePostpaid | No       | [ChargePostpaid](/api-reference/zec/datastructure.md#chargepostpaid) | <p>The commitment period for a postpaid cloud disk.</p><p>Only pass this when a commitment period needs to be specified.</p>                                                                                                                                                                                                                                                                   |
| diskName               | No       | String                                                               | <p>Disk name.</p><p>Length: 1 to 64 characters.</p><p>Only letters, digits, hyphens (-), slashes (/), underscores (\_) and periods (.) are allowed.</p><p>Must start and end with a digit or a letter.</p><p>Required when <code>diskNames</code> is not specified.</p>                                                                                                                        |
| diskNames              | No       | Array of String                                                      | <p>The individual name for each cloud disk.</p><p>The number of names must match the <code>diskAmount</code> field, and the naming rules are the same as <code>diskName</code>.</p><p>If not passed, all disks in this batch use the name specified by <code>diskName</code>.</p>                                                                                                              |
| diskAmount             | No       | Integer                                                              | <p>Quantity of disks.</p><p>Value range: \[1, 1000]</p><p>Default value: 1</p>                                                                                                                                                                                                                                                                                                                 |
| instanceId             | No       | String                                                               | <p>ID of the instance that the disk is attached to.</p><p>It can be obtained by calling <a href="/api-reference/zec/instance/describeinstances.md">DescribeInstances</a>.</p>                                                                                                                                                                                                                  |
| instanceIds            | No       | Array of String                                                      | <p>IDs of the instances to be bound.</p><p>The quantity must be the same as the <code>diskAmount</code> field, and each disk is attached to a different instance. When it is passed together with <code>instanceId</code>, <code>instanceId</code> takes precedence.</p><p>It can be obtained by calling <a href="/api-reference/zec/instance/describeinstances.md">DescribeInstances</a>.</p> |
| resourceGroupId        | No       | String                                                               | <p>Resource group ID.</p><p>If the value is null, the disk will be added into default resource group.</p>                                                                                                                                                                                                                                                                                      |
| diskCategory           | No       | String                                                               | <p>Disk category.</p><p>Basic NVMe SSD/BASIC\_NVME\_SSD: basic NVMe SSD.</p><p>Standard NVMe SSD/NVME\_SSD: standard NVMe SSD.</p><p>Default value: Standard NVMe SSD</p>                                                                                                                                                                                                                      |
| snapshotId             | No       | String                                                               | <p>Create the disk from a snapshot ID.</p><p>If it is specified, the disk is created from this snapshot, and the disk type of the snapshot must be a data disk snapshot.</p><p>It can be obtained by calling <a href="/api-reference/zec/disk-snapshot/describesnapshots.md">DescribeSnapshots</a>.</p>                                                                                        |
| marketingOptions       | No       | [MarketingInfo](/api-reference/zec/datastructure.md#marketinginfo)   | Information on marketing campaigns.                                                                                                                                                                                                                                                                                                                                                            |
| tags                   | No       | [TagAssociation](/api-reference/zec/datastructure.md#tagassociation) | <p>Bound tags when creating resources.</p><p>Tag keys must be unique.</p>                                                                                                                                                                                                                                                                                                                      |
| burstingEnabled        | No       | Boolean                                                              | <p>Whether to enable burstable performance.</p><p>Default value: false</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> |
| diskIds        | Array of String | ID list of disks.                                                                                                     |
| orderNumber    | String          | Number of order.                                                                                                      |

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**1. Create a 30 GiB disk.**

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

Request：
{
  "diskName": "Test-Disk",
  "diskSize": 30,
  "diskAmount": 1,
  "zoneId": "asia-east-1a"
}

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

**2. Create three 20 GiB disks and attach them to the same instance.**

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

Request：
{
  "diskName": "Test-Disk",
  "diskSize": 20,
  "diskAmount": 3,
  "zoneId": "asia-east-1a",
  "instanceId": "<instanceId>"
}

Response:
{
  "requestId": "T842EE571-4490-4AFE-9F17-931030D3B4F9",
  "response": {
    "requestId": "T842EE571-4490-4AFE-9F17-931030D3B4F9",
    "diskIds": [
      "<diskId1>",
      "<diskId2>",
      "<diskId3>"
    ],
    "orderNumber": "<orderNumber>"
  }
}
```

**3. Create two 20 GiB disks, attach them to two different instances, and specify a name for each of them.**

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

Request：
{
  "diskName": "Test-Disk",
  "diskNames": ["Test-Disk-1", "Test-Disk-2"],
  "diskSize": 20,
  "diskAmount": 2,
  "zoneId": "asia-east-1a",
  "instanceIds": ["<instanceId1>", "<instanceId2>"]
}

Response:
{
  "requestId": "T842EE571-4490-4AFE-9F17-931030D3B4F9",
  "response": {
    "requestId": "T842EE571-4490-4AFE-9F17-931030D3B4F9",
    "diskIds": [
      "<diskId1>",
      "<diskId2>"
    ],
    "orderNumber": "<orderNumber>"
  }
}
```

**4. Create a 30 GiB disk with a POC voucher. If no POC voucher exists in the system, the creation will fail.**

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

Request：
{
  "diskName": "Test-Disk",
  "diskSize": 30,
  "diskAmount": 1,
  "zoneId": "asia-east-1a",
  "marketingOptions": {
    "usePocVoucher": true
  }
}

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

{% endtab %}
{% endtabs %}

## 5. Developer Resources

Zenlayer Cloud API 2.0 integrates [SDKs](/api-reference/api-introduction/toolkit/api-sdk.md)，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](/api-reference/api-introduction/instruction/commonerrorcode.md).

| HTTP Status Code | Error Code                                           | Description                                                                            |
| ---------------- | ---------------------------------------------------- | -------------------------------------------------------------------------------------- |
| 400              | INVALID\_DISK\_CATEGORY\_ZONE\_NO\_SELL              | Disk type not for sale in the zone.                                                    |
| 400              | INVALID\_DISK\_SIZE\_EXCEED\_MAXIMUM                 | Disk size exceeds the maximum limit.                                                   |
| 400              | INVALID\_DISK\_SIZE\_LESS\_MINIMUM                   | Disk size should be larger than the minimum limit.                                     |
| 404              | INVALID\_DISK\_SNAPSHOT\_NOT\_FOUND                  | Snapshot does not exist.                                                               |
| 400              | INVALID\_DISK\_SNAPSHOT\_SIZE\_MISMATCH              | The capacity of the created disk is smaller than the source disk size of the snapshot. |
| 404              | INVALID\_DISK\_SNAPSHOT\_ZONE\_MISMATCH              | The snapshot does not match the specified zone.                                        |
| 404              | INVALID\_INSTANCE\_NOT\_FOUND                        | Instance not found.                                                                    |
| 404              | INVALID\_INSTANCE\_OR\_ZONE\_CANNOT\_BE\_BOTH\_EMPTY | Specify at least one of the parameters: instance and zone.                             |
| 400              | INVALID\_PARAMETER\_DISK\_NAME\_MALFORMED            | The disk name format is invalid.                                                       |
| 400              | INVALID\_ZONE\_MISMATCH                              | The zones mismatch.                                                                    |
| 404              | INVALID\_ZONE\_NOT\_FOUND                            | Region does not exist.                                                                 |
| 400              | LIMIT\_EXCEEDED\_INSTANCE\_CAN\_ATTACH               | Quantity of attached disks exceed available disk numbers of an instance.               |
| 400              | OPERATION\_DENIED\_DISK\_INSTANCE\_NOT\_ADAPTER      | The number of instances does not match the number of disks.                            |
| 400              | OPERATION\_DENIED\_DISK\_IO\_BURST                   | The disk bursting function is not enabled.                                             |
| 400              | OPERATION\_DENIED\_DISK\_NAME\_NOT\_ADAPTER          | The number of specified disk names does not match the number of disks to be created.   |
| 400              | OPERATION\_DENIED\_DISK\_SNAPSHOT\_STATUS            | The operation is not supported for current snapshot state.                             |
| 400              | OPERATION\_DENIED\_DISK\_SYSTEM\_TYPE                | The operation is not supported for system disks.                                       |
| 400              | UNSUPPORTED\_OPERATION\_INSTANCE\_STATUS             | Operations on instances in current state are not supported.                            |
