> 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/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 interface is asynchronous. The request to replicate an image returns immediately after it is sent successfully, but the operation is not completed at that point. The replication result can be queried in the target region by calling the [DescribeCustomImages](/api-reference/zec/image/describecustomimages.md) interface: if the image status changes from `SYNCING` to `AVAILABLE`, the replication succeeded; if it changes to `FAILED`, the replication failed. During the replication, the image cannot be replicated again and its replicas cannot be deleted.
* Cross-border replication is prohibited.
  {% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name | Required | Type            | Description                                                                                                                          |
| -------------- | -------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| imageId        | Yes      | String          | <p>Custom image ID.</p><p>It can be obtained by calling <a href="/api-reference/zec/image/describeimages.md">DescribeImages</a>.</p> |
| regionIdList   | Yes      | Array of String | Target 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" %}
**1. Copy to multiple 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 replication limit (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                 | The specified region does not exist.                                 |
| 400              | INVALID\_REGION\_NOT\_ON\_SALE              | Subnet is not available for sale in the specified region.            |
