> 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/elastic-ip/replaceeipaddress.md).

# ReplaceEipAddress

## 1. API Description

This API (ReplaceEipAddress) is used to replace the elastic IP addresses.

{% hint style="info" %}
**Notes**

* The EIP to be replaced must be unassociated, that is, not associated with any resource such as an instance or a vNIC.
* EIPs created from a CIDR block do not support replacing the IP.
  {% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name | Required | Type                                                                | Description                                   |
| -------------- | -------- | ------------------------------------------------------------------- | --------------------------------------------- |
| replaceIps     | Yes      | Array of [ReplaceIp](/api-reference/zec/datastructure.md#replaceip) | Lists of the original and target elastic IPs. |

## 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> |
| failedEipIds   | Array of String | Elastic IP IDs that failed to replace.                                                                                |

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**1. Replace the public IP. The system will assign one randomly.**

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

Request：
{
  "replaceIps": [
    {
      "eipId": "<eipId>"
    }
  ]
}

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

{% 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\_EIP\_NOT\_FOUND                            | Elastic IP does not exist.                                          |
| 400              | INVALID\_IP\_BROADCAST\_ADDRESS                     | The IP address cannot be a broadcast address.                       |
| 400              | INVALID\_IP\_NETWORK\_ADDRESS                       | The IP address cannot be a network address.                         |
| 400              | OPERATION\_DENIED\_CIDR\_CREATE\_SOURCE             | This operation is not supported by the CIDR source.                 |
| 400              | OPERATION\_DENIED\_EIP\_BLOCK\_CANNOT\_REPLACE\_IP  | EIP Block does not support replacing the IP.                        |
| 400              | OPERATION\_DENIED\_EIP\_INSUFFICIENT                | Insufficient elastic IP stock.                                      |
| 400              | OPERATION\_DENIED\_EIP\_IN\_RISK\_CONTROL           | This operation is not supported for elastic IPs under risk control. |
| 400              | OPERATION\_DENIED\_EIP\_IP\_CHANGE\_LIMIT\_EXCEEDED | Replacement limit exceeded.                                         |
| 500              | OPERATION\_DENIED\_EIP\_STATUS\_NOT\_SUPPORT        | Operations on the EIP with current status are not supported.        |
| 400              | OPERATION\_DENIED\_EIP\_UNSUPPORTED\_CUSTOMIZE      | The manually specified IP address is invalid.                       |
| 400              | OPERATION\_EIP\_PUBLIC\_IP\_CONFLICT                | Public IP address conflict exists.                                  |
