# CreateDisks

## 1. API Description

This API 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>](describedisks) <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.

<table><thead><tr><th width="200">Parameter Name</th><th width="126">Required</th><th width="97">Type</th><th>Description</th></tr></thead><tbody><tr><td>zoneId</td><td>Yes</td><td>String</td><td>ID of availability zone to which the disk belongs.</td></tr><tr><td>diskName</td><td>Yes</td><td>String</td><td><p>Disk name.</p><p>This parameter must start with a number or a letter, containing up to 64 characters.</p><p>Only letters, numbers, - and periods (.) are supported.</p></td></tr><tr><td>diskSize</td><td>Yes</td><td>Integer</td><td><p>Storage space.</p><p>Unit: GB.</p></td></tr><tr><td>diskAmount</td><td>Yes</td><td>Integer</td><td><p>Quantity of disks.</p><p>Minimum value: 1 (default value); Maximum value: 50.</p></td></tr><tr><td>instanceId</td><td>No</td><td>String</td><td>ID of instance to which the disks are attached.<br>Specify the ID of an instance in the current zone to which the disks are attached.</td></tr><tr><td>resourceGroupId</td><td>No</td><td>String</td><td><p>Resource group ID.</p><p>If the value is null, the disk will be added into default resource group.</p></td></tr><tr><td>diskCategory</td><td>No</td><td>String</td><td><p>Disk type.</p><ul><li><code>Basic NVMe SSD</code>: the Basic NVMe SSD.</li><li><code>Standard NVMe SSD</code>: the Standard NVMe SSD.</li></ul><p>Default value: <code>Standard NVMe SSD</code>.<br>Call <a href="describediskcategory"><mark style="color:blue;"><code>DescribeDiskCategory</code></mark></a> to obtain disk type.</p></td></tr></tbody></table>

## 3. Output Parameters

<table><thead><tr><th width="203">Parameter Name</th><th width="159">Type</th><th>Description</th></tr></thead><tbody><tr><td>requestId</td><td>String</td><td>The unique request ID, which is returned for each request. RequestId is required for locating a problem.</td></tr><tr><td>diskIds</td><td>Array of String</td><td>ID list of disks.</td></tr><tr><td>orderNumber</td><td>String</td><td>Number of order.</td></tr></tbody></table>

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**Create one or more disks.**

```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": "HKG-A"
}

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

## 5. Developer Resources

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

<table><thead><tr><th width="212">HTTP Status Code</th><th>Error Code</th><th>Description</th></tr></thead><tbody><tr><td><strong>400</strong></td><td>INVALID_ILLEGAL_DISK_SIZE</td><td>Disk size exceeds the maximum or minimum limit.</td></tr><tr><td><strong>404</strong></td><td>INVALID_ZONE_NOT_FOUND</td><td>Availability zone does not exist.</td></tr><tr><td><strong>400</strong></td><td>LIMIT_EXCEEDED_INSTANCE_CAN_ATTACH</td><td>Quantity of attached disks exceeds the maximum limit.</td></tr><tr><td><strong>404</strong></td><td>INVALID_INSTANCE_NOT_FOUND</td><td>Instance to which the disks to be attached does not exist.</td></tr><tr><td><strong>400</strong></td><td>INVALID_INSTANCE_OR_ZONE_CANNOT_BE_BOTH_EMPTY</td><td>Specify at least one of the parameters: instance and zone.</td></tr><tr><td><strong>400</strong></td><td>INVALID_CHARGE_TYPE</td><td>Invalid billing model.</td></tr><tr><td><strong>400</strong></td><td>INVALID_DISK_CATEGORY_ZONE_NO_SELL</td><td>Disk type not for sale in the zone.</td></tr><tr><td><strong>400</strong></td><td>INVALID_DISK_CATEGORY_ZONE_NOT_SUPPORT</td><td>Unavailable disk type in the zone.</td></tr></tbody></table>
