# CreateEips

## 1. API Description

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

#### Prerequisites

* Query regions: call [`DescribeEipRegions`](https://docs.console.zenlayer.com/api-reference/compute/zec/elastic-ip/describeeipregions) to check the available regions supporting the sale of elastic IPs.
* Query network billing methods: call [`DescribeEipInternetChargeTypes`](https://docs.console.zenlayer.com/api-reference/compute/zec/elastic-ip/describeeipinternetchargetypes) to check the available network billing methods.
* Query remote regions: call [`DescribeEipRemoteRegions`](https://docs.console.zenlayer.com/api-reference/compute/zec/elastic-ip/describeeipremoteregions) to check the available regions you want to remote to.
* Query CIDR ID: call [`DescribeCidrs`](https://docs.console.zenlayer.com/api-reference/compute/zec/cidr-block/describecidrs) to check the available CIDR IDs.

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

* <mark style="color:blue;">`eipV4Type`</mark> <mark style="color:blue;">and</mark> <mark style="color:blue;">`cidrId`</mark> <mark style="color:blue;">cannot be passed together or left empty.</mark>
* <mark style="color:blue;">Passing</mark> <mark style="color:blue;">`cidrId`</mark> <mark style="color:blue;">means the public IP is generated from a CIDR block.</mark>
* <mark style="color:blue;">If assigning to an instance, ensure that the primary private IP on the instance’s primary vNIC can still be assigned an elastic IP.</mark>
  {% 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](https://docs.console.zenlayer.com/api-reference/compute/datastructure#internetchargetype) | Network billing methods .                                                                                                                                                                                                 |
| amount                  | No       | Integer                                                                                                        | <p>Quantity.</p><p>Value range: \[1, +)</p><p>Default value: 1</p>                                                                                                                                                        |
| eipV4Type \[Deprecated] | No       | [EipNetworkType](https://docs.console.zenlayer.com/api-reference/compute/datastructure#eipnetworktype)         | <p>Network types of public IPv4.</p><p>Deprecated. Please use networkLineType instead.</p>                                                                                                                                |
| networkLineType         | No       | [NetworkLineType](https://docs.console.zenlayer.com/api-reference/compute/datastructure#networklinetype)       | Network types of public IPv4.                                                                                                                                                                                             |
| primaryIsp              | No       | [EipIsp](https://docs.console.zenlayer.com/api-reference/compute/datastructure#eipisp)                         | <p>If the eipV4Type field is set to ThreeLine , this field is required and must include:</p><p>CHINA\_TELECOM CHINA\_UNICOM CHINA\_MOBILE</p>                                                                             |
| bandwidth               | No       | Integer                                                                                                        | <p>Public outbound bandwidth cap.</p><p>Unit: Mbps .</p><p>Bandwidth cap varies by instance size.</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                                                                                                         | The starting public IP.                                                                                                                                                                                                   |
| resourceGroupId         | No       | String                                                                                                         | Resource group.                                                                                                                                                                                                           |
| flowPackage             | No       | Float                                                                                                          | <p>Traffic package size (TB).</p><p>The parameter is valid only when internetChargeType is ByTrafficPackage .</p><p>Default value: 0 .</p><p>The value supports up to one decimal place.</p><p>Value range: \[0.0, +)</p> |
| clusterId               | No       | String                                                                                                         | <p>Bandwidth cluster ID for the public IPv6 address.</p><p>This parameter must be specified when the subnet's stack type includes public IPv6, and the network billing model is <code>BandwidthCluster</code>.</p>        |
| peerRegionId            | No       | String                                                                                                         | Remote region ID.                                                                                                                                                                                                         |
| marketingOptions        | No       | [MarketingInfo](https://docs.console.zenlayer.com/api-reference/compute/datastructure#marketinginfo)           | Information on marketing campaigns.                                                                                                                                                                                       |
| tags                    | No       | [TagAssociation](https://docs.console.zenlayer.com/api-reference/compute/datastructure#tagassociation)         | <p>Bound tags when creating the elastic IP.</p><p>Tag keys must be unique.</p>                                                                                                                                            |
| instanceIds             | No       | Array of String                                                                                                | <p>IDs of instances to be attached.</p><p>The number of IDs should be the same as diskAmount .</p>                                                                                                                        |
| bindType                | No       | [BindType](https://docs.console.zenlayer.com/api-reference/compute/datastructure#bindtype)                     | <p>Elastic IP mode when binding to resources.</p><p>Effective when specific instanceIds are specified.</p><p>Defaults to standard NAT mode.</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" %}
**Create one or more elastic IPs.**

<pre class="language-json"><code class="lang-json"><strong>POST /api/v2/zec HTTP/1.1
</strong>Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: CreateEips


Request：
{
  "regionId": "asia-east-1",
  "amount": 1,
  "name": "xxx",
  "internetChargeType": "ByTrafficPackage",
  "eipV4Type": "BGPLine",
  "bandwidth": 50,
  "flowPackage": 2,
  "resourceGroupId": "xxxx"
}

Response:
{
  "requestId": "TBFC01FCF-6439-4530-ADBC-16809F0C3E8F",
  "response": {
    "requestId": "TBFC01FCF-6439-4530-ADBC-16809F0C3E8F",
    "eipIds": ["xxx","xxx"],
    "orderNumber": "xxx"
  }
}
</code></pre>

{% 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                                                                      |
| ---------------- | --------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| 404              | INVALID\_CIDR\_NOT\_FOUND                                       | CIDR block not found.                                                            |
| 400              | INVALID\_PARAMETER\_BANDWIDTH\_ERROR                            | Bandwidth size is below the minimum limit.                                       |
| 400              | INVALID\_PARAMETER\_BANDWIDTH\_EXCEED                           | Bandwidth size exceeds the upper limit.                                          |
| 404              | INVALID\_REGION\_NOT\_FOUND                                     | Specified availability zone 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\_UNSUPPORT\_CUSTOMIZE                    | Manually specified IP address is invalid.                                        |
| 400              | OPERATION\_DENIED\_EIP\_UNSUPPORT\_NETWORK\_TYPE                | Elastic IP network billing model is not supported.                               |
| 400              | OPERATION\_DENIED\_EIP\_UNSUPPORT\_REMOTE\_IPT                  | Customer currently does not support configuring Remote IPT.                      |
| 400              | OPERATION\_DENIED\_INTERNET\_CHARGE\_TYPE\_NOT\_SUPPORT         | IP network billing type is not supported.                                        |
| 400              | OPERATION\_DENIED\_EIP\_NOT\_SUPPORT\_PASS\_THROUGH\_BIND\_TYPE | Elastic IP does not support the Bypass mode.                                     |
| 400              | INVALID\_REGION\_MISMATCH                                       | Region mismatch.                                                                 |
| 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\_LAN\_EIP\_TYPE\_CONFLICTS                    | Public IPv4 type conflict on the private IP.                                     |
| 400              | OPERATION\_DENIED\_EIP\_ASSIGNED\_LIMIT\_EXCEEDED               | Elastic IP binding exceeds the allowed limit.                                    |
