> 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/zec/public-ipv6/assignnetworkinterfaceipv6.md).

# AssignNetworkInterfaceIpv6

## 1. API Description

This API (AssignNetworkInterfaceIpv6) is used to assign IPv6 addresses to a network interface.

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

* This operation is supported only when the stack type of the network interface is `IPv4` and the stack type of the subnet it belongs to is `IPv4_IPv6`.
* If the IPv6 of the subnet is public, the billing-related parameters of the public network need to be specified.
* The committed traffic package size is valid only when the billing cycle is monthly.
  {% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name     | Required | Type                                                                         | Description                                                                                                                                                                                                                                                                                                                            |
| ------------------ | -------- | ---------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| nicId              | Yes      | String                                                                       | <p>ID of the network interface to which IPv6 addresses are to be added.</p><p>It can be obtained by calling <a href="/api-reference/zec/vnic/describenetworkinterfaces.md">DescribeNetworkInterfaces</a>.</p>                                                                                                                          |
| internetChargeType | No       | [InternetChargeType](/api-reference/zec/datastructure.md#internetchargetype) | <p>Network billing model.</p><p>See InternetChargeType for available values.</p><p>If the subnet stack type is IPv4\_IPv6 and the IPv6 access 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>Traffic package size of the public IPv6 address.</p><p>Unit: TB.</p><p>The value must be 0 or a multiple of 0.1.</p><p>This parameter is required when the subnet stack type contains IPv6 that is public and the network billing mode is traffic package billing (<code>ByTrafficPackage</code>).</p><p>Value range: \[0.0, +)</p> |
| clusterId          | No       | String                                                                       | <p>ID of the bandwidth cluster specified for the public IPv6 address.</p><p>This parameter is required when the subnet stack type contains IPv6 that is public and the network billing mode is bandwidth cluster billing (<code>BandwidthCluster</code>).</p>                                                                          |
| rateLimitMode      | No       | [RateLimitMode](/api-reference/zec/datastructure.md#ratelimitmode)           | <p>Rate limit mode.</p><p><code>bandwidth</code> must be specified at the same time for the strict mode (<code>STRICT</code>).</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. The network interface is assigned a private IPv6 address.**

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

Request：
{
  "nicId": "<nicId>"
}

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

**2. The network interface is assigned a public IPv6 address, billed by shared bandwidth package, with the bandwidth limit set to 100Mbps.**

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

Request：
{
  "nicId": "<nicId>",
  "internetChargeType": "BandwidthCluster",
  "bandwidth": 100,
  "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                                                                                                    |
| ---------------- | -------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| 400              | INVALID\_NIC\_IPV6\_EXISTS                                     | vNIC already has an IPv6 assigned; operation not allowed.                                                      |
| 404              | INVALID\_NIC\_NOT\_FOUND                                       | vNIC does not exist.                                                                                           |
| 400              | INVALID\_NIC\_STATUS                                           | Current vNIC state does not allow this operation.                                                              |
| 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\_RATE\_LIMIT\_MODE\_REQUIRES\_BANDWIDTH                | Bandwidth must be specified when the rate limit mode is STRICT.                                                |
| 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\_SUBNET\_IPSTACK\_NOT\_SUPPORT                         | Subnet IP stack type not supported.                                                                            |
| 409              | INVALID\_SUBNET\_IPV6\_INSUFFICIENT                            | Insufficient available IPv6 addresses in the subnet.                                                           |
| 400              | OPERATION\_DENIED\_INTERNET\_CHARGE\_TYPE\_NOT\_SUPPORT        | IP network billing type is not supported.                                                                      |
| 400              | OPERATION\_DENIED\_NIC\_EXIST\_IPV6                            | The vNIC already IPv6 assigned.                                                                                |
| 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. |
