# BatchAssignNetworkInterfaceIpv4

## 1. API Description

This API (BatchAssignNetworkInterfaceIpv4) is used to batch assign the private IPv4 addresses to the vNIC.

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

* <mark style="color:blue;">vNIC state must be</mark> <mark style="color:blue;">`AVAILABLE`</mark> <mark style="color:blue;">or</mark> <mark style="color:blue;">`USED`</mark><mark style="color:blue;">.</mark>
* <mark style="color:blue;">If any of the private IPv4 addresses is illegal, the operation will fail immediately.</mark>
  {% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name | Required | Type            | Description                                                                                                                                                                                 |
| -------------- | -------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| nicId          | Yes      | String          | ID of the vNIC.                                                                                                                                                                             |
| ipAddresses    | No       | Array of String | <p>List of private IP addresses.</p><p>Each IP must fall within the IP range of the associated subnet and must not be the gateway, broadcast, or network address.</p>                       |
| ipAddressCount | No       | Integer         | <p>Number of additional private IPs to assign.</p><p>Either this field or ipAddresses must be specified. If both are provided, ipAddresses takes precedence.</p><p>Value range: \[1, +)</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> |
| ipAddresses    | Array of String | Assigned private IPs.                                                                                                 |

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**Batch bind the private IPv4 to the vNIC.**

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

Request：
{
  "nicId": "<nicId>",
  "ipAddresses": ["10.0.0.3", "10.0.0.4"]
}

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

{% 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\_NIC\_STATUS                                   | Current vNIC state does not allow this operation.              |
| 400              | OPERATION\_DENIED\_SUBNET\_TYPE\_NOT\_SUPPORT\_IPV4    | Subnet type does not support IPv4.                             |
| 409              | INVALID\_SUBNET\_PRIVATE\_IPV4\_IN\_USED               | Private IPv4 is occupied.                                      |
| 400              | INVALID\_IP\_OUT\_OF\_RANGE                            | Invalid IP address. It does not belong to the CIDR block.      |
| 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              | INVALID\_IP\_FIRST\_ADDRESS                            | The IP address cannot be a gateway address.                    |
| 400              | OPERATION\_DENIED\_SUBNET\_IP\_INSUFFICIENT            | Insufficient available IPs in the subnet.                      |
| 400              | INVALID\_PARAMETER\_PRIVATE\_IP\_ILLEGAL               | Invalid private IP address.                                    |
| 400              | OPERATION\_DENIED\_NIC\_ATTACH\_LAN\_IP\_EXCEED\_LIMIT | The number of private IPs on the vNIC exceeds the upper limit. |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.console.zenlayer.com/api-reference/compute/zec/vnic/batchassignnetworkinterfaceipv4.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
