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

# CreateEips

## 1. API Description

This API (CreateEips) is used to create one or more elastic IPs.

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

* You can call [`DescribeEipRegions`](/api-reference/compute/zec/elastic-ip/describeeipregions.md) to query the regions that support elastic IPs.
* You can call [`DescribeEipInternetChargeTypes`](/api-reference/compute/zec/elastic-ip/describeeipinternetchargetypes.md) to query the network billing methods supported by public IPs.
* If you need to create a `Remote EIP`, you can first call [`DescribeEipRemoteRegions`](/api-reference/compute/zec/elastic-ip/describeeipremoteregions.md) to query the supported remote regions.
* If you need to allocate via a `CIDR`, you can first call [`DescribeCidrs`](/api-reference/compute/zec/cidr-block/describecidrs.md) to query the `CIDR` blocks under your account.
* If binding to an instance at the same time, ensure that the `primary private IP` on the selected instance's `primary network interface` can still be assigned an EIP.
* Specifying a `prefixLength` less than 32 creates an EIP Block resource; when binding an instance at the same time, `bindType` can only be `Passthrough`.
* When `publicIp` is specified, a `prefixLength` of 32 means a plain IPv4 starting address is specified; a value less than 32 means a starting subnet with a mask is specified (the mask must match `prefixLength`, e.g. `88.0.5.64/26`). When `cidrId` is specified, this starting address/subnet must be one of the currently allocatable candidates within the selected `CIDR`; when `cidrId` is not specified (only `prefixLength` of 32 is supported), the address is allocated sequentially from the public IP pool starting at this address.
* The guaranteed traffic package size is only valid for monthly billing periods.
  {% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name           | Required | Type                                                                                 | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ------------------------ | -------- | ------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| regionId                 | Yes      | String                                                                               | Region ID.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| name                     | Yes      | String                                                                               | <p>Name of the elastic IP.</p><p>This parameter must start with a number or a letter, containing 2 to 63 characters. Only letters, numbers, - and periods (.) are supported.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| internetChargeType       | Yes      | [InternetChargeType](/api-reference/compute/zec/datastructure.md#internetchargetype) | Network billing method of the elastic IP.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| amount                   | No       | Integer                                                                              | <p>Quantity.</p><p>Value range: \[1, +)</p><p>Default value: 1</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| prefixLength             | No       | Integer                                                                              | <p>Prefix length. Value range: 20–32. Default: 32.</p><p>When a value less than 32 is specified, an EIP Block resource is created; <code>cidrId</code> must also be specified, and the value must not be less than the prefix length of the selected CIDR itself.</p><p>Value range: \[20, 32]</p><p>Default value: 32</p>                                                                                                                                                                                                                                                                                                                                                                   |
| eipV4Type \[Deprecated]  | No       | [EipNetworkType](/api-reference/compute/zec/datastructure.md#eipnetworktype)         | <p>Network types of public IPv4.</p><p>Deprecated. Please use networkLineType instead.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| networkLineType          | No       | [NetworkLineType](/api-reference/compute/zec/datastructure.md#networklinetype)       | Network types of public IPv4.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| primaryIsp \[Deprecated] | No       | [EipIsp](/api-reference/compute/zec/datastructure.md#eipisp)                         | ISP of the primary public IP.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| bandwidth                | No       | Integer                                                                              | <p>Bandwidth limit of the elastic IP.</p><p>Unit: Mbps.</p><p>Value range: \[1, +)</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| cidrId                   | No       | String                                                                               | <p>CIDR ID.</p><p>If this parameter is specified, eipV4Type must be empty.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| publicIp                 | No       | String                                                                               | <p>Creates an EIP starting from the specified public IP address.</p><p>When <code>cidrId</code> is not specified, the address is allocated sequentially from the public IP pool starting at this address (only <code>prefixLength</code> of 32 is supported); when <code>cidrId</code> is specified, the address is allocated starting at this address within that CIDR block.</p><p>When <code>prefixLength</code> is 32, provide a plain IPv4 address; when <code>prefixLength</code> is less than 32, <code>cidrId</code> must also be specified, and you must provide a starting subnet with a mask (the mask must match <code>prefixLength</code>, e.g. <code>88.0.5.64/26</code>).</p> |
| resourceGroupId          | No       | String                                                                               | Resource group ID for the elastic public IP. If not specified, the IP will be placed in the default resource group.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| flowPackage              | No       | Float                                                                                | <p>Traffic package size of the EIP.</p><p>Unit: TB.</p><p>The value must be 0 or a multiple of 0.1.</p><p>Required when the network billing type is traffic package billing (<code>ByTrafficPackage</code>).</p><p>Value range: \[0.0, +)</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| clusterId                | No       | String                                                                               | <p>Shared bandwidth package ID.</p><p>Required when the network billing method is shared bandwidth package billing (<code>BandwidthCluster</code>).</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| peerRegionId             | No       | String                                                                               | Remote region ID.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| marketingOptions         | No       | [MarketingInfo](/api-reference/compute/zec/datastructure.md#marketinginfo)           | Information on marketing campaigns.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| tags                     | No       | [TagAssociation](/api-reference/compute/zec/datastructure.md#tagassociation)         | <p>Bound tags when creating the elastic IP.</p><p>Tag keys must be unique.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| instanceId               | No       | String                                                                               | <p>The instance ID to be bound.</p><p>All EIPs created in this batch are bound to this instance.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| instanceIds              | No       | Array of String                                                                      | <p>Set of instance IDs to bind.</p><p>The quantity must match the <code>amount</code> field, with each EIP bound to a different instance; if passed together with <code>instanceId</code>, <code>instanceId</code> takes precedence.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| bindType                 | No       | [BindType](/api-reference/compute/zec/datastructure.md#bindtype)                     | <p>Binding mode.</p><p>Effective when <code>instanceIds</code> is specified.</p><p>Defaults to standard NAT mode.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| rateLimitMode            | No       | [RateLimitMode](/api-reference/compute/zec/datastructure.md#ratelimitmode)           | <p>Rate limit mode.</p><p><code>STRICT</code> (strict mode) requires <code>bandwidth</code> to be specified at the same time.</p><p>Default value: LOOSE</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> |
| eipIds         | Array of String | ID list of elastic IPs.                                                                                               |
| orderNumber    | String          | Order No.                                                                                                             |

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**1. Create a public elastic IP on a BGP line, billed by traffic package. The traffic package size is 10TB. The bandwidth limit is 50Mbps.**

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

Request：
{
  "regionId": "asia-east-1",
  "amount": 1,
  "name": "Test-EIP",
  "internetChargeType": "ByTrafficPackage",
  "networkLineType": "PremiumBGP",
  "bandwidth": 50,
  "flowPackage": 10,
  "rateLimitMode": "LOOSE"
}
```

**2. Allocate 2 public elastic IPs from a CIDR block, billed by fixed bandwidth. The bandwidth limit is 50Mbps.**

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

Request：
{
  "regionId": "asia-east-1",
  "amount": 2,
  "name": "Test-EIP",
  "internetChargeType": "ByBandwidth",
  "cidrId": "<cidrId>",
  "bandwidth": 50
}
  
Response：
{
  "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
  "response": {
    "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
    "eipIds": ["<eipId>", "<eipId2>"],
    "orderNumber": "<orderNumber>"
  }
}
```

**3. Allocate a single `/32` elastic IP from a BYOIP `CIDR` (e.g. `128.0.0.0/24`) and bind it to an instance. `prefixLength` defaults to 32 and can be omitted; both NAT mode (default) and `Passthrough` mode are supported.**

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

Request：
{
  "regionId": "na-east-1",
  "amount": 1,
  "name": "Test-EIP",
  "internetChargeType": "BandwidthCluster",
  "clusterId": "<clusterId>",
  "cidrId": "<cidrId>",
  "prefixLength": 32,
  "instanceIds": ["<instanceId>"],
  "bindType": "FullNat"
}

Response：
{
  "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
  "response": {
    "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
    "eipIds": ["<eipId>"],
    "orderNumber": "<orderNumber>"
  }
}
```

**4. Allocate a `/24` elastic IP (EIP Block) from a BYOIP `CIDR` with a `/24` mask and bind it to an instance. A `/24` BYOIP `CIDR` can only allocate a single `/24` EIP, so `amount` can only be 1. An EIP Block (`prefixLength` less than 32) only supports `Passthrough` binding mode, not NAT mode.**

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

Request：
{
  "regionId": "na-east-1",
  "amount": 1,
  "name": "Test-EIP",
  "internetChargeType": "BandwidthCluster",
  "clusterId": "<clusterId>",
  "cidrId": "<cidrId>",
  "prefixLength": 24,
  "instanceIds": ["<instanceId>"],
  "bindType": "Passthrough"
}

Response：
{
  "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
  "response": {
    "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
    "eipIds": ["<eipId>"],
    "orderNumber": "<orderNumber>"
  }
}
```

**5. Create 3 public elastic IPs, all bound to the same instance (`instanceId`).**

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

Request：
{
  "regionId": "asia-east-1",
  "amount": 3,
  "name": "Test-EIP",
  "internetChargeType": "ByBandwidth",
  "networkLineType": "PremiumBGP",
  "bandwidth": 50,
  "instanceId": "<instanceId>"
}

Response：
{
  "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
  "response": {
    "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
    "eipIds": ["<eipId1>", "<eipId2>", "<eipId3>"],
    "orderNumber": "<orderNumber>"
  }
}
```

**6. Create 2 public elastic IPs, each bound to a different instance (`instanceIds`, the quantity must match `amount`).**

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

Request：
{
  "regionId": "asia-east-1",
  "amount": 2,
  "name": "Test-EIP",
  "internetChargeType": "ByBandwidth",
  "networkLineType": "PremiumBGP",
  "bandwidth": 50,
  "instanceIds": ["<instanceId1>", "<instanceId2>"]
}

Response：
{
  "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
  "response": {
    "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
    "eipIds": ["<eipId1>", "<eipId2>"],
    "orderNumber": "<orderNumber>"
  }
}
```

**4. Allocate a single `/32` elastic IP from a BYOIP CIDR block (e.g. `128.0.0.0/24`) and bind it to an instance. `prefixLength` defaults to 32, so it can be omitted; both NAT mode (default) and `Passthrough` mode are supported.**

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

Request：
{
  "regionId": "na-east-1",
  "amount": 1,
  "name": "Test-EIP",
  "internetChargeType": "BandwidthCluster",
  "clusterId": "<clusterId>",
  "cidrId": "<cidrId>",
  "prefixLength": 32,
  "instanceIds": ["<instanceId>"],
  "bindType": "FullNat"
}

Response：
{
  "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
  "response": {
    "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
    "eipIds": ["<eipId>"],
    "orderNumber": "<orderNumber>"
  }
}
```

**5. Allocate a `/24` elastic IP (EIP Block) from a BYOIP CIDR block that itself is `/24`, and bind it to an instance. Since a `/24` BYOIP CIDR can only allocate one `/24` EIP, `amount` must be 1. An EIP Block (`prefixLength` < 32) only supports `Passthrough` binding mode, not NAT.**

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

Request：
{
  "regionId": "na-east-1",
  "amount": 1,
  "name": "Test-EIP",
  "internetChargeType": "BandwidthCluster",
  "clusterId": "<clusterId>",
  "cidrId": "<cidrId>",
  "prefixLength": 24,
  "instanceIds": ["<instanceId>"],
  "bindType": "Passthrough"
}

Response：
{
  "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
  "response": {
    "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
    "eipIds": ["<eipId>"],
    "orderNumber": "<orderNumber>"
  }
}
```

{% 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\_CIDR\_NOT\_FOUND                                             | CIDR block not found.                                                                                          |
| 404              | INVALID\_CIDR\_IP\_NOT\_FOUND                                         | The specified IP address does not exist in the CIDR.                                                           |
| 400              | INVALID\_PREFIX\_LENGTH\_OUT\_OF\_RANGE                               | The prefix length of the EIP is invalid.                                                                       |
| 400              | INVALID\_PREFIX\_LENGTH\_MUST\_EXCEED\_CIDR\_NETMASK                  | The prefix length of the EIP must be greater than the prefix length of the selected CIDR.                      |
| 400              | INVALID\_STARTING\_CIDR\_PREFIX\_MISMATCH                             | The prefix length of the specified starting CIDR block does not match prefixLength.                            |
| 400              | INVALID\_PARAMETER\_BANDWIDTH\_ERROR                                  | Bandwidth size is below the minimum limit.                                                                     |
| 400              | INVALID\_RATE\_LIMIT\_MODE\_REQUIRES\_BANDWIDTH                       | Bandwidth must be specified when the rate limit mode is STRICT.                                                |
| 400              | OPERATION\_DENIED\_CIDR\_CREATE\_SOURCE                               | This operation is not supported by the CIDR source.                                                            |
| 400              | INVALID\_PARAMETER\_BANDWIDTH\_EXCEED                                 | Bandwidth size exceeds the upper limit.                                                                        |
| 404              | INVALID\_REGION\_NOT\_FOUND                                           | The specified region does not exist.                                                                           |
| 400              | OPERATION\_DENIED\_CIDR\_IP\_INSUFFICIENT                             | Insufficient remaining IPs in the CIDR block.                                                                  |
| 400              | OPERATION\_DENIED\_CIDR\_STATUS                                       | The specified CIDR state does not support this operation.                                                      |
| 400              | OPERATION\_DENIED\_EIP\_UNSUPPORTED\_CUSTOMIZE                        | The manually specified IP address is invalid.                                                                  |
| 400              | INVALID\_IP\_NETWORK\_ADDRESS                                         | The IP address cannot be a network address.                                                                    |
| 400              | INVALID\_IP\_BROADCAST\_ADDRESS                                       | The IP address cannot be a broadcast address.                                                                  |
| 400              | OPERATION\_DENIED\_EIP\_UNSUPPORTED\_NETWORK\_TYPE                    | The EIP network billing method is not supported.                                                               |
| 400              | OPERATION\_DENIED\_EIP\_UNSUPPORTED\_REMOTE\_IPT                      | This customer is temporarily not supported to configure Remote IPT.                                            |
| 400              | OPERATION\_DENIED\_INTERNET\_CHARGE\_TYPE\_NOT\_SUPPORT               | IP network billing type is not supported.                                                                      |
| 400              | INVALID\_REGION\_MISMATCH                                             | The EIP is not in the same region as the target resource.                                                      |
| 400              | OPERATION\_DENIED\_EIP\_INSTANCE\_NOT\_ADAPTER                        | Specified instance count does not match the number of elastic IPs to be created.                               |
| 404              | INVALID\_INSTANCE\_NOT\_FOUND                                         | Instance not found.                                                                                            |
| 400              | INVALID\_NIC\_STATUS                                                  | Current vNIC state does not allow this operation.                                                              |
| 400              | OPERATION\_DENIED\_EIP\_ASSIGNED\_LIMIT\_EXCEEDED                     | Elastic IP binding exceeds the allowed limit.                                                                  |
| 400              | OPERATION\_DENIED\_FLOW\_PACKAGE\_NOT\_SUPPORTED\_HOUR\_PERIOD        | The current product cycle is based on hourly billing and does not support setting a minimum data package size. |
| 400              | INVALID\_PARAMETER\_FLOW\_PACKAGE\_NOT\_SUPPORTED\_FOR\_PATH\_BASED   | PathBasedBandwidthIP does not support custom traffic package sizes. Pass 0 or omit this parameter.             |
| 400              | OPERATION\_DENIED\_FIXED\_BANDWIDTH\_NOT\_SUPPORTED\_FOR\_PATH\_BASED | PathBasedBandwidthIP does not support fixed bandwidth billing.                                                 |
| 400              | INVALID\_EIP\_BINDING\_MODE\_UNSUPPORTED                              | EIP Block does not support NAT binding mode.                                                                   |
