# CreateSnapshot

## 1. API Description

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

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

* <mark style="color:blue;">Whether the disk supports creating snapshots can be determined by the</mark> <mark style="color:blue;">`SnapshotAbility`</mark> <mark style="color:blue;">field. You can use</mark> [<mark style="color:purple;">`DescribeDisks`</mark>](https://docs.console.zenlayer.com/api-reference/compute/zec/disk/describedisks) <mark style="color:blue;">to query the value.</mark>
* <mark style="color:blue;">The disk must be</mark> <mark style="color:blue;">`IN_USE`</mark> <mark style="color:blue;">or</mark> <mark style="color:blue;">`AVAILABLE`</mark><mark style="color:blue;">.</mark>
* <mark style="color:blue;">For the limit on the number of snapshots that can be created, see the product usage limits.</mark>
  {% 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](https://docs.console.zenlayer.com/api-reference/api-introduction/toolkit/api-sdk)，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](https://docs.console.zenlayer.com/api-reference/api-introduction/instruction/commonerrorcode).

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