# CreateImage

## 1. API Description

This API (CreateImage) is used to create a custom image.

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

* <mark style="color:blue;">Up to 5 images can be created in each zone. If you need more, please contact Zenlayer Support.</mark>
* <mark style="color:blue;">The system disk of an instance will be mirrored while creating an image. Please ensure the instance is shut down.</mark> <mark style="color:blue;">Any operations on the instances are not allowed while creating.</mark>
* <mark style="color:blue;">The image size is the same as that of instance system disk.</mark>
* <mark style="color:blue;">Images are not supported in</mark> <mark style="color:blue;">`SIN-E`</mark> <mark style="color:blue;">and</mark> <mark style="color:blue;">`LAX-A`</mark> <mark style="color:blue;">for now.</mark>
  {% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name   | Required | Type   | Description                                                                                                                                                  |
| ---------------- | -------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| instanceId       | Yes      | String | ID of instance to be mirrored.                                                                                                                               |
| imageName        | Yes      | String | <p>Image name to be displayed.</p><p>This parameter must contain up to 24 characters. Only Chinese characters, letters, numbers, - and \_ are supported.</p> |
| imageDescription | No       | String | <p>Image description.</p><p>This parameter must contain up to 255 characters.</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> |
| imageId        | String | Image ID.                                                                                                             |

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**Create an image.**

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

Request:
{
  "instanceId": "your-instance-id",
  "imageName": "testimagename",
  "imageDescription": "testimagedescription"
}

Response:
{
  "requestId": "T69E37B61-4E39-4461-A2BB-205F847D1D60",
  "response": {
    "requestId": "T69E37B61-4E39-4461-A2BB-205F847D1D60",
    "imageId": "img-xxxxx"
  }
}
```

{% 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 |
| ---------------- | ---------- | ----------- |


---

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