> 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/cidr-block/createipv6cidr.md).

# CreateIpv6Cidr

## 1. API Description

This API (CreateIpv6Cidr) is used to purchase IPv6 CIDR blocks with the specified mask and quantity.

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

* This interface is asynchronous. When `cidrIds` is returned, the CIDR blocks are in the `CREATING` state. You can poll `DescribeIpv6Cidrs` until the state becomes `AVAILABLE` before using them.
* This interface is only used to purchase IPv6 CIDR blocks provided by Zenlayer. To announce your own IPv6 CIDR blocks, use `CreateByoip`.
  {% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name         | Required | Type                                                                   | Description                                                                                                                                                                                                                                                                                                   |
| ---------------------- | -------- | ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| regionId               | Yes      | String                                                                 | Region ID.                                                                                                                                                                                                                                                                                                    |
| networkLineType        | Yes      | [NetworkLineType](/api-reference/zec/datastructure.md#networklinetype) | <p>Network type of the public IPv6.</p><p>The supported lines are subject to the response of <code>DescribeIpv6CidrNetmasks</code>.</p>                                                                                                                                                                       |
| netmask                | Yes      | [Ipv6NetmaskInfo](/api-reference/zec/datastructure.md#ipv6netmaskinfo) | <p>Mask and quantity of the CIDR blocks to purchase.</p><p>To purchase CIDR blocks with different masks, call this interface multiple times.</p>                                                                                                                                                              |
| subnetMaskLength       | Yes      | Integer                                                                | <p>Mask length used when the CIDR block is split into subnets.</p><p>Value range: <code>\[mask, mask+8]</code>.</p><p>Value range: \[24, 40]</p>                                                                                                                                                              |
| instanceChargePostpaid | Yes      | [ChargePostpaid](/api-reference/zec/datastructure.md#chargepostpaid)   | <p>Commitment period settings for postpaid.</p><p>Only commitment periods enabled for the account are supported.</p>                                                                                                                                                                                          |
| name                   | No       | String                                                                 | <p>CIDR block name.</p><p>Length: 2–63 characters. Allowed characters: letters (A–Z, a–z), numbers (0–9), hyphen ( - ), slash ( / ), underscore ( \_ ), and period ( . ). Must start and end with a letter or number.</p><p>If not specified, the assigned CIDR address will be used as the default name.</p> |
| resourceGroupId        | No       | String                                                                 | <p>Resource group ID.</p><p>If not specified, the CIDR block will be added to the default resource group.</p>                                                                                                                                                                                                 |
| marketingOptions       | No       | [MarketingInfo](/api-reference/zec/datastructure.md#marketinginfo)     | Information on marketing campaigns.                                                                                                                                                                                                                                                                           |
| tags                   | No       | [TagAssociation](/api-reference/zec/datastructure.md#tagassociation)   | <p>Bound tags when creating the CIDR block.</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> |
| cidrIds        | Array of String | ID list of created IPv6 CIDR blocks.                                                                                  |
| orderNumber    | String          | Order number generated for this purchase.                                                                             |

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**1. Purchase 2 `/29` IPv6 CIDR blocks on the Premium BGP line in `asia-east-1`, split into `/37` subnets, with a 1-month commitment period.**

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

Request:
{
  "regionId": "asia-east-1",
  "networkLineType": "PremiumBGP",
  "netmask": { "netmask": 29, "amount": 2 },
  "subnetMaskLength": 37,
  "instanceChargePostpaid": {
    "period": 1
  }
}

Response:
{
  "requestId": "TBFC01FCF-6439-4530-ADBC-16809F0C3E8F",
  "response": {
    "requestId": "TBFC01FCF-6439-4530-ADBC-16809F0C3E8F",
    "cidrIds": ["<cidrId1>","<cidrId2>"],
    "orderNumber": "<orderNumber>"
  }
}
```

{% 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              | OPERATION\_DENIED\_CIDR\_INSUFFICIENT              | Insufficient CIDR blocks.                        |
| 400              | INVALID\_IPV6\_SUBNET\_MASK\_LENGTH                | IPv6 subnet mask length is out of valid range.   |
| 404              | INVALID\_REGION\_NOT\_FOUND                        | The specified region does not exist.             |
| 400              | OPERATION\_DENIED\_EIP\_UNSUPPORTED\_NETWORK\_TYPE | The EIP network billing method is not supported. |
