> 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/vnic/createnetworkinterface.md).

# CreateNetworkInterface

## 1. API Description

This API (CreateNetworkInterface) is used to create an elastic vNIC.

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

* This API is an async API. A response is returned after the request is sent. However, it does not mean the operation has been completed. If the status changes from `PENDING` to `Available`, it means that the vNIC has been created successfully. If the status changes to `CREATE_FAILED`, the creation is failed.
* The size of the guaranteed traffic package is only valid for billing periods of one month.
  {% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name     | Required | Type                                                                                 | Description                                                                                                                                                                                                                                         |
| ------------------ | -------- | ------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name               | Yes      | String                                                                               | <p>The name of the vNIC.</p><p>The length is 2 to 63 characters. Only letters, numbers, - and periods (.) are supported. The name must start and end with a number or a letter.</p>                                                                 |
| subnetId           | Yes      | String                                                                               | ID of the subnet.                                                                                                                                                                                                                                   |
| nicStackType       | No       | [SubnetStackType](/api-reference/compute/zec/datastructure.md#subnetstacktype)       | <p>The IP stack type of the vNIC.</p><p>If not specified, it will be determined by the subnet’s stack type: IPv4 for an IPv4 subnet, and IPv6 for an IPv6 subnet.</p><p>Specify this parameter if you need IPv4\_IPv6 vNIC IP stack type.</p>       |
| resourceGroupId    | No       | String                                                                               | <p>The resource group ID of the vNIC.</p><p>If you do not specify a resource group, it is placed in the default resource group.</p>                                                                                                                 |
| securityGroupId    | No       | String                                                                               | <p>ID of the security group deployed on the primary vNIC.</p><p>Currently only one security group can be deployed.</p><p>If not specified, the security group associated with global VPC will be used by default.</p>                               |
| internetChargeType | No       | [InternetChargeType](/api-reference/compute/zec/datastructure.md#internetchargetype) | <p>Network billing model.</p><p>See InternetChargeType for available values.</p><p>If the subnet stack type is IPv6 and the type is Public , this value is required.</p>                                                                            |
| bandwidth          | No       | Integer                                                                              | <p>Outbound public network bandwidth cap (Mbps). Unit: Mbps.</p><p>The value differs with different instance types.</p><p>Value range: \[1, +)</p>                                                                                                  |
| packageSize        | No       | Float                                                                                | <p>Data transfer package size(TB).</p><p>The unit is TB.</p><p>This value takes effect only when internetChargeType is set to ByTrafficPackage .</p><p>The default value is 0.</p><p>Maximum of one decimal place.</p><p>Value range: \[0.0, +)</p> |
| clusterId          | No       | String                                                                               | <p>Bandwidth cluster ID.</p><p>If the value of internetChargeType is BandwidthCluster , the parameter is required.</p>                                                                                                                              |
| eipBindType        | No       | [BindType](/api-reference/compute/zec/datastructure.md#bindtype)                     | <p>The binding mode of public network IP.</p><p>It needs to be specified when allocating public network IP.</p><p>Default value: FullNat</p>                                                                                                        |
| eipIds             | No       | Array of String                                                                      | <p>Assign the existing EIPs to the network cards.</p><p>The number of IPs must be the same as the number of created network cards.</p><p>Make sure that the <code>ipStackType</code> of the created network cards includes <code>IPv4</code>.</p>   |
| 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 vNIC.</p><p>Tag keys must be unique.</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> |
| nicId          | String | vNIC ID.                                                                                                              |

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**Create an elastic vNIC.**

<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: CreateNetworkInterface


Request:
{
  "name": "XXX",
  "subnetId": "xxx",
  "packageSize": 10,
  "internetChargeType": "ByTrafficPackage",
  "resourceGroupId": "xxxx"
}

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

{% 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.                                                                                     |
| 404              | INVALID\_INSTANCE\_NOT\_FOUND                                  | Instance not found.                                                                                            |
| 400              | INVALID\_IP\_BROADCAST\_ADDRESS                                | The IP address cannot be a broadcast address.                                                                  |
| 400              | INVALID\_IP\_FIRST\_ADDRESS                                    | The IP address cannot be a gateway address.                                                                    |
| 400              | INVALID\_IP\_NETWORK\_ADDRESS                                  | The IP address cannot be a network address.                                                                    |
| 400              | INVALID\_IP\_OUT\_OF\_RANGE                                    | Invalid IP address. It does not belong to the CIDR block.                                                      |
| 409              | INVALID\_NIC\_INSTANCE\_REGION\_MISMATCH                       | Instance and vNIC are not in the same zone.                                                                    |
| 400              | INVALID\_NIC\_IPV6\_EXISTS                                     | vNIC already has an IPv6 assigned; operation not allowed.                                                      |
| 400              | INVALID\_PARAMETER\_BANDWIDTH\_ERROR                           | Bandwidth size is below the minimum limit.                                                                     |
| 400              | INVALID\_PARAMETER\_BANDWIDTH\_EXCEED                          | Bandwidth size exceeds the upper limit.                                                                        |
| 400              | INVALID\_PARAMETER\_FLOW\_TRAFFIC\_PACKAGE                     | Data transfer package size is invalid.                                                                         |
| 400              | INVALID\_PARAMETER\_TRAFFIC\_PACKAGE\_EXCEED                   | Data traffic package exceeds the maximum limit.                                                                |
| 400              | INVALID\_REGION\_NOT\_ON\_SALE                                 | Subnet is not available for sale in the specified region.                                                      |
| 404              | INVALID\_SECURITY\_GROUP\_NOT\_FOUND                           | The specified security group does not exist.                                                                   |
| 409              | INVALID\_SUBNET\_IPV4\_INSUFFICIENT                            | Insufficient available IPv4 addresses in the subnet.                                                           |
| 409              | INVALID\_SUBNET\_IPV6\_INSUFFICIENT                            | Insufficient available IPv6 addresses in the subnet.                                                           |
| 404              | INVALID\_SUBNET\_NOT\_FOUND                                    | Subnet does not exist.                                                                                         |
| 409              | INVALID\_SUBNET\_PRIVATE\_IPV4\_IN\_USED                       | Private IPv4 is occupied.                                                                                      |
| 400              | OPERATION\_DENIED\_EIP\_IS\_DEFAULT                            | Default public IP cannot be unbound.                                                                           |
| 400              | OPERATION\_DENIED\_EIP\_IS\_NOT\_UN\_ASSIGN                    | Elastic IP is not in unassigned state.                                                                         |
| 400              | OPERATION\_DENIED\_EIP\_NIC\_NOT\_ADAPTER                      | Specified vNIC count does not match the number of elastic IPs to create.                                       |
| 400              | OPERATION\_DENIED\_EIP\_NOT\_ASSIGNED                          | Elastic IP is not bound.                                                                                       |
| 400              | OPERATION\_DENIED\_INSTANCE\_NIC\_NOT\_ADAPTER                 | Specified instance count does not match the number of vNICs to create.                                         |
| 400              | OPERATION\_DENIED\_INSTANCE\_STATUS\_NOT\_SUPPORT              | Current instance state does not allow this operation.                                                          |
| 400              | OPERATION\_DENIED\_INTERNET\_CHARGE\_TYPE\_NOT\_SUPPORT        | IP network billing type is not supported.                                                                      |
| 400              | OPERATION\_DENIED\_STACK\_TYPE\_NOT\_SUPPORT                   | Stack type is not supported.                                                                                   |
| 400              | OPERATION\_DENIED\_SUBNET\_TYPE\_NOT\_SUPPORT\_IPV4            | Subnet type does not support IPv4.                                                                             |
| 409              | INVALID\_NIC\_EIP\_REGION\_MISMATCH                            | The network card and the EIP are not on the same region.                                                       |
| 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. |
