# 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;">If you create a subscription disk, the amount required will be pre-deducted. If the balance is insufficient, the request will fail. If you create a pay-as-you-go disk, please ensure your account balance is sufficient before calling this API.</mark>
* <mark style="color:blue;">This API is an async API. A disk ID 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/vm/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,</mark> <mark style="color:blue;">it means that the disk has been created successfully;</mark> <mark style="color:blue;">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                                                                                                                                                                            |
| ---------------- | -------- | --------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| chargeType       | Yes      | [ChargeType](/api-reference/compute/vm/datastructure.md#chargetype)         | <p>Disk pricing model.</p><p>PREPAID: subscription</p><p>POSTPAID: pay-as-you-go</p>                                                                                                   |
| diskName         | Yes      | String                                                                      | <p>Disk name to be displayed.</p><p>This parameter must start with a number or a letter, containing up to 64 characters. Only letters, numbers, - and periods (.) are supported.</p>   |
| diskSize         | Yes      | Integer                                                                     | <p>Storage space.</p><p>Unit: GB.</p>                                                                                                                                                  |
| chargePrepaid    | No       | [ChargePrepaid](/api-reference/compute/vm/datastructure.md#chargeprepaid)   | Details of the monthly subscription, including the purchase period, auto-renewal. It is required if the chargeType is PREPAID.                                                         |
| diskAmount       | No       | Integer                                                                     | <p>Quantity of disks.</p><p>Minimum value: 1 (default value);</p><p>Maximum value: 50.</p><p>Value range: \[1, 50]</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>                                        |
| zoneId           | No       | String                                                                      | <p>ID of zone to which thedisk belongs.</p><p>If instanceId is specified, this parameter is invalid.</p><p>Call Describezones to obtain zoneId.</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 type.Standard Disk: Hard Disk DriveSSD: Solid State DriveThe default value is Standard Disk.</p><p>Call DescribeDiskCategory to obtain disk type.</p><p>Default value: SSD</p> |
| marketingOptions | No       | [MarketingInfo](/api-reference/compute/vm/datastructure.md#marketinginfo)   | Information on marketing campaigns.                                                                                                                                                    |
| tags             | No       | [TagAssociation](/api-reference/compute/vm/datastructure.md#tagassociation) | <p>Tags associated when creating resources.</p><p>Note: The associated tag key cannot be duplicated.</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" %}
**Create one or more disks.**

```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. 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 |
| ---------------- | ---------- | ----------- |


---

# 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/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.
