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

# CreateDisks

## 1. API Description

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

{% hint style="info" %} <mark style="color:blue;">**Note**</mark>

<mark style="color:blue;">This API is an async API. A disk</mark> <mark style="color:blue;">`ID`</mark> <mark style="color:blue;">list is returned after the creation request is sent. However, it does not mean the creation has been completed. You can use</mark> [<mark style="color:purple;">`DescribeDisks`</mark>](/api-reference/compute/zec/disk/describedisks.md) <mark style="color:blue;">to query the status of the disk. If disk has been queried with the</mark> <mark style="color:blue;">**AVAILABLE**</mark> <mark style="color:blue;">status, it means that the disk has been created successfully; if disk has been attached to a certain instance while creating, the</mark> <mark style="color:blue;">**IN\_USE**</mark> <mark style="color:blue;">status means attaching successfully.</mark>
{% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name         | Required | Type                                                                         | Description                                                                                                                                                                                                                                                                       |
| ---------------------- | -------- | ---------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| zoneId                 | Yes      | String                                                                       | ID of availability zone to which the disk belongs.                                                                                                                                                                                                                                |
| diskSize               | Yes      | Integer                                                                      | <p>Storage space.</p><p>Unit: GB.</p>                                                                                                                                                                                                                                             |
| instanceChargePostpaid | No       | [ChargePostpaid](/api-reference/compute/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 instance to which the disks are attached.</p><p>Specify the ID of an instance in the current zone to which the disks are attached.</p>                                                                                                                                   |
| instanceIds            | No       | Array of String                                                              | <p>IDs of the instances to attach.</p><p>The number of IDs must match the <code>diskAmount</code> field, and each disk is attached to a different instance. If <code>instanceId</code> is passed at the same time, <code>instanceId</code> takes precedence.</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: economical NVMe SSD.</p><p>Standard NVMe SSD/NVME\_SSD: standard NVMe SSD.</p><p>Default value: Standard NVMe SSD.</p><p>Default value: Standard NVMe SSD</p>                                                            |
| snapshotId             | No       | String                                                                       | <p>ID of the snapshot to create a disk.</p><p>If this parameter is specified, the disk will be created from the snapshot. The snapshot’s disk info must be of type disk.</p>                                                                                                      |
| marketingOptions       | No       | [MarketingInfo](/api-reference/compute/zec/datastructure.md#marketinginfo)   | Information on marketing campaigns.                                                                                                                                                                                                                                               |
| tags                   | No       | [TagAssociation](/api-reference/compute/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 one 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.**

```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>"
  }
}
```

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