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

# AssignLoadBalancerIpv6

## 1. API Description

This API (AssignLoadBalancerIpv6) is used to assign public IPv6 addresses to a load balancer instance.

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

* The load balancer instance must be in the `RUNNING` state.
* The public IPv6 addresses are assigned from the subnet specified when the load balancer instance was created. **This operation does not accept a subnet parameter.** The subnet must contain a public IPv6 block.
* This operation is asynchronous. The addresses are not ready when the call returns successfully. You can query the assignment result in the details of the load balancer instance.
* The public IPv6 block itself is not billed. Only the bandwidth is billed.
* The number of the public IPs that can be assigned to a single load balancer instance is limited by the `VIPs_per_LB` quota.
  {% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name     | Required | Type                                                                         | Description                                                                                                                                                                                                                                                                                                                            |
| ------------------ | -------- | ---------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| loadBalancerId     | Yes      | String                                                                       | <p>ID of the load balancer instance to which public IPv6 addresses are assigned.</p><p>Only available for load balancer instances whose <code>ipStackType</code> is <code>IPv6</code>.</p><p>It can be obtained by calling <a href="/api-reference/zlb/load-balancer-instance/describeloadbalancers.md">DescribeLoadBalancers</a>.</p> |
| internetChargeType | Yes      | [InternetChargeType](/api-reference/zlb/datastructure.md#internetchargetype) | Network billing method of the public IPv6.                                                                                                                                                                                                                                                                                             |
| vipCount           | No       | Integer                                                                      | <p>Number of the public IPv6 addresses to be assigned this time.</p><p><code>INVALID\_SUBNET\_IPV6\_INSUFFICIENT</code> is returned when the available public IPv6 addresses left in the subnet are insufficient.</p><p>Value range: \[1, 20]</p><p>Default value: 1</p>                                                               |
| bandwidth          | No       | Integer                                                                      | <p>Bandwidth limit of the public IPv6.</p><p>Unit: Mbps.</p><p>Required when the network billing method is fixed bandwidth (<code>ByBandwidth</code>).</p><p>Value range: \[1, +)</p>                                                                                                                                                  |
| packageSize        | No       | Float                                                                        | <p>Traffic package size of the public IPv6.</p><p>Unit: TB.</p><p>The value must be 0 or a multiple of 0.1.</p><p>Required when the network billing method is traffic package (<code>ByTrafficPackage</code>), and it can be set only when the billing period is month.</p><p>Value range: \[0.0, +)</p>                               |
| clusterId          | No       | String                                                                       | <p>ID of the bandwidth cluster specified for the public IPv6.</p><p>Required when the network billing method is bandwidth cluster (<code>BandwidthCluster</code>).</p>                                                                                                                                                                 |
| rateLimitMode      | No       | [RateLimitMode](/api-reference/zlb/datastructure.md#ratelimitmode)           | <p>Rate limit mode.</p><p>The strict mode (<code>STRICT</code>) requires <code>bandwidth</code> to be specified at the same time. Otherwise, <code>INVALID\_RATE\_LIMIT\_MODE\_REQUIRES\_BANDWIDTH</code> is returned.</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> |

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**1. Assign one public IPv6 to a load balancer instance. The billing type is fixed bandwidth and the bandwidth limit is set to 100 Mbps.**

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

Request：
{
  "loadBalancerId": "<loadBalancerId>",
  "internetChargeType": "ByBandwidth",
  "bandwidth": 100,
  "rateLimitMode": "LOOSE"
}

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

**2. Assign three public IPv6 addresses to a load balancer instance at a time. The billing type is bandwidth cluster.**

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

Request：
{
  "loadBalancerId": "<loadBalancerId>",
  "vipCount": 3,
  "internetChargeType": "BandwidthCluster",
  "clusterId": "<clusterId>",
  "rateLimitMode": "LOOSE"
}

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](/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\_LB\_NOT\_FOUND                                        | Load balancer does not exist.                                                                                  |
| 400              | INVALID\_LB\_STATUS                                            | Load balancer state is not supported.                                                                          |
| 400              | INVALID\_PARAMETER\_BANDWIDTH\_ERROR                           | The bandwidth limit value is below the minimum limit.                                                          |
| 400              | INVALID\_PARAMETER\_BANDWIDTH\_EXCEED                          | The bandwidth limit value exceeds the maximum limit.                                                           |
| 400              | INVALID\_PARAMETER\_FLOW\_TRAFFIC\_PACKAGE                     | The traffic package size is invalid.                                                                           |
| 400              | INVALID\_PARAMETER\_TRAFFIC\_PACKAGE\_EXCEED                   | The traffic package size exceeds the maximum limit.                                                            |
| 400              | INVALID\_RATE\_LIMIT\_MODE\_REQUIRES\_BANDWIDTH                | The bandwidth must be specified when the rate limit mode is STRICT.                                            |
| 409              | INVALID\_SUBNET\_IPV6\_INSUFFICIENT                            | The number of the available IPv6 addresses in the subnet is insufficient.                                      |
| 404              | INVALID\_SUBNET\_NOT\_FOUND                                    | Subnet does not exist.                                                                                         |
| 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              | OPERATION\_DENIED\_INTERNET\_CHARGE\_TYPE\_NOT\_SUPPORT        | The network billing method of the IP is not supported.                                                         |
| 400              | OPERATION\_DENIED\_SUBNET\_NOT\_SUPPORT\_PUBLIC\_IPV6          | The subnet does not have a public IPv6 block.                                                                  |
