> 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`](https://github.com/zenlayer/zenlayercloud-api-doc-en/blob/main/zec/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:mm: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.                |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.console.zenlayer.com/api-reference/compute/zec/disk-snapshot/createsnapshot.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
