> 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-snapshot/createsnapshot.md).

# CreateSnapshot

## 1. API Description

This API (CreateSnapshot) is used to create a snapshot of the specified disk.

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

* This is an asynchronous API. The request returns immediately after submission, but the operation is not yet complete. You can query the snapshot creation result by calling [`DescribeSnapshots`](/api-reference/compute/zec/disk-snapshot/describesnapshots.md). If the snapshot status changes from `CREATING` to `AVAILABLE`, the creation was successful. The snapshot cannot be deleted during the creation process.
* Whether the disk supports creating snapshots can be determined by the `SnapshotAbility` field, which can be queried via the [`DescribeDisks`](/api-reference/compute/zec/disk/describedisks.md) API.
* The disk must be in **In Use** or **Available** state.
* See the product usage limits for the maximum number of snapshots that can be created.
  {% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name | Required | Type   | Description                                                                                                                                                                                                                                                                              |
| -------------- | -------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| diskId         | Yes      | String | ID of the disk.                                                                                                                                                                                                                                                                          |
| snapshotName   | Yes      | String | Snapshot name.                                                                                                                                                                                                                                                                           |
| retentionTime  | No       | String | <p>Retention expiration time.</p><p>Format: YYYY-MM-ddTHH<span data-gb-custom-inline data-tag="emoji" data-code="1f1f2-1f1f2">🇲🇲</span>ssZ.</p><p>If not transmitted, it means that it is retained indefinitely.</p><p>The specified time must be 24 hours after the current time.</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> |
| snapshotId     | String | The IDs of the created snapshots.                                                                                     |

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**Create a snapshot of the disk.**

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

Request：
{
  "diskId": "diskId1",
  "snapshotName": "xxx",
  "retentionTime": "2025-07-16T01:26:39Z"
}

Response：
{
  "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
  "response": {
    "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
    "snapshotId": "snapshotId1"
  }
}
```

{% 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                                                                  |
| ---------------- | ------------------------------------ | ---------------------------------------------------------------------------- |
| 404              | INVALID\_DISK\_NOT\_FOUND            | Disk does not exist.                                                         |
| 400              | INVALID\_SNAPSHOT\_QUOTA\_EXCEED     | The number of snapshots exceeds the limit.                                   |
| 400              | INVALID\_SNAPSHOT\_RETENTION\_TIME   | Invalid snapshot retention time. It must be 24 hours after the current time. |
| 400              | UNSUPPORTED\_OPERATION\_DISK\_STATUS | Operations on the disk with current status are not supported.                |
