> 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/zlb/load-balancer-instance/addloadbalancersprivateips.md).

# AddLoadBalancersPrivateIps

## 1. API Description

This API (AddLoadBalancersPrivateIps) is used to add private IPs to a load balancer.

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

* This operation adds private IPv4 addresses and **applies only to the load balancer instances whose `ipStackType` is `IPv4`**. An IPv6 load balancer does not support binding private IPv4 addresses.
* Private IPs and stateless forwarding of listeners (`algoOpts` set to `StatelessForwarding`) are mutually exclusive: if the load balancer already has a listener with stateless forwarding enabled, private IPs cannot be bound. Disable stateless forwarding on that listener first, or create a new load balancer instance to bind private IPs.
* Private VIPs and public IPs together count against the VIP quota of a single load balancer instance. `INVALID_QUOTA_EXCEED` is returned if the quota is exceeded.
* The region of the load balancer must support private IPs (see `supportPrivateIp` in [DescribeLoadBalancerRegions](https://docs.console.zenlayer.com/api-reference/zlb/location/describeloadbalancerregions.md)); otherwise `OPERATION_DENIED_LB_REGION_NOT_SUPPORT_PRIVATE_IP` is returned. Private IPs that are already bound can still be unbound.
  {% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name | Required | Type            | Description                                                                                                                                                                                                                                                                                                      |
| -------------- | -------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| privateIps     | Yes      | Array of String | <p>Private IPs to be added.</p><p>Up to 20 private IPs can be added at a time.</p><p>They must be within the CIDR range of the subnet specified by <code>subnetId</code> and must not be occupied by other resources.</p>                                                                                        |
| loadBalancerId | Yes      | String          | <p>Load balancer ID.</p><p>It can be obtained by calling <a href="https://docs.console.zenlayer.com/api-reference/zlb/load-balancer-instance/describeloadbalancers.md">DescribeLoadBalancers</a>.</p>                                                                                                            |
| subnetId       | Yes      | String          | <p>ID of the subnet where the private IPs are located.</p><p>It can be obtained by calling <a href="https://docs.console.zenlayer.com/api-reference/zec/vpc-network/describesubnets.md">DescribeSubnets</a>.</p><p>The region and VPC of the subnet must be the same as those of the load balancer instance.</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> |

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**1. Add private IPs to a load balancer instance.**

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

Request:
{
  "privateIps": [
    "10.0.0.0"
  ],
  "loadBalancerId": "<your lb id>",
  "subnetId": "<your subnet id>"
}

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

{% endtab %}
{% endtabs %}

## 5. Developer Resources

Zenlayer Cloud API 2.0 integrates [SDKs](https://docs.console.zenlayer.com/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](https://docs.console.zenlayer.com/api-reference/api-introduction/instruction/commonerrorcode.md).

| HTTP Status Code | Error Code                                                          | Description                                                                                        |
| ---------------- | ------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| 400              | INVALID\_IP\_BROADCAST\_ADDRESS                                     | Invalid IP address: broadcast addresses are not allowed.                                           |
| 400              | INVALID\_IP\_FIRST\_ADDRESS                                         | Invalid IP address: gateway addresses are not allowed.                                             |
| 400              | INVALID\_IP\_NETWORK\_ADDRESS                                       | Invalid IP address: network addresses are not allowed.                                             |
| 400              | INVALID\_IP\_OUT\_OF\_RANGE                                         | Invalid IP address: not within the CIDR range.                                                     |
| 404              | INVALID\_LB\_NOT\_FOUND                                             | Load balancer does not exist.                                                                      |
| 400              | INVALID\_LB\_SUBNET\_REGION\_MISMATCH                               | The subnet of the load balancer private IP is not in the same region as the load balancer.         |
| 404              | INVALID\_REGION\_NOT\_FOUND                                         | Specified region does not exist.                                                                   |
| 400              | INVALID\_SUBNET\_NOT\_BELONG\_TO\_VPC                               | Specified subnet is not within the global VPC.                                                     |
| 404              | INVALID\_SUBNET\_NOT\_FOUND                                         | Subnet does not exist.                                                                             |
| 409              | INVALID\_SUBNET\_PRIVATE\_IPV4\_IN\_USED                            | Preset private IP is already be used.                                                              |
| 400              | OPERATION\_DENIED\_INSTANCE\_STATUS\_NOT\_SUPPORT                   | Operation is not supported for current instance state.                                             |
| 400              | OPERATION\_DENIED\_LB\_PRIVATE\_IP\_STATELESS\_FORWARDING\_CONFLICT | Private IPs cannot be bound when a listener of the load balancer has stateless forwarding enabled. |
| 400              | OPERATION\_DENIED\_LB\_REGION\_NOT\_SUPPORT\_PRIVATE\_IP            | The region of the load balancer does not support private IPs.                                      |
| 400              | OPERATION\_DENIED\_SUBNET\_TYPE\_NOT\_SUPPORT                       | Subnet stack type is not supported.                                                                |
| 400              | OPERATION\_DENIED\_SUBNET\_TYPE\_NOT\_SUPPORT\_IPV4                 | IPv4 subnet stack type is not supported.                                                           |
