> 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/image/copyimage.md).

# CopyImage

## 1. API Description

This API (CopyImage) is used to replicate a custom image to other regions.

{% 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 image copy result by calling [`DescribeCustomImages`](/api-reference/compute/zec/image/describecustomimages.md) in the target region. If the image status changes from `SYNCING` to `AVAILABLE`, the copy was successful. If it changes to `FAILED`, the copy failed. During the copy process, the image cannot be copied again or have its replicas deleted.
* Cross-border copying is not allowed.
  {% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name | Required | Type            | Description                 |
| -------------- | -------- | --------------- | --------------------------- |
| imageId        | Yes      | String          | Custom image ID.            |
| regionIdList   | Yes      | Array of String | Destination region ID list. |

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

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**Replicate a custom image to more than one regions.**

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

Request：
{
  "imageId": "<custom image id>",
  "regionIdList": ["region-a", "region-b"]
}

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

{% 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                                                          |
| ---------------- | ------------------------------------------- | -------------------------------------------------------------------- |
| 400              | INVALID\_IMAGE\_CROSS\_BORDER\_COPY\_DENIED | Replication between Mainland China and other regions is not allowed. |
| 404              | INVALID\_IMAGE\_NOT\_FOUND                  | Image not found.                                                     |
| 400              | INVALID\_IMAGE\_REGION\_EXIST               | This image already exists in the selected region.                    |
| 400              | INVALID\_IMAGE\_SIZE\_EXCEED\_LIMIT         | The image `{}` size exceeds the cross-region copy limit of 200 GiB   |
| 400              | INVALID\_IMAGE\_STATUS                      | The image's state does not support this operation.                   |
| 400              | INVALID\_REGION\_NOT\_ACTIVE                | Specified region is unavailable                                      |
| 404              | INVALID\_REGION\_NOT\_FOUND                 | Specified availability zone does not exist.                          |
| 400              | INVALID\_REGION\_NOT\_ON\_SALE              | Subnet is not available for sale in the specified region.            |
