> 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/vpc-network/associatevpccidrblock.md).

# AssociateVpcCidrBlock

## 1. API Description

This API (AssociateVpcCidrBlock) is used to add a secondary IPv4 CIDR block to a VPC.

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

* Concurrent CIDR block operations on the same VPC are not supported. Please call the interface serially.
  {% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name | Required | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| -------------- | -------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| vpcId          | Yes      | String | <p>ID of the VPC.</p><p>The default VPC does not support adding secondary CIDR blocks.</p><p>It can be obtained by calling <a href="/api-reference/zec/vpc-network/describevpcs.md">DescribeVpcs</a>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| cidrBlock      | Yes      | String | <p>Secondary IPv4 CIDR block to be added.</p><p>The mask length ranges from 9 to 29, and the starting address of the CIDR block must be specified, for example <code>10.0.0.0/16</code>.</p><p>It cannot overlap with the primary CIDR block or the existing secondary CIDR blocks of this VPC.</p><p>It cannot overlap with the following reserved CIDR blocks: <code>0.0.0.0/8</code>, <code>100.64.0.0/10</code>, <code>127.0.0.0/8</code>, <code>169.254.0.0/16</code>, and <code>224.0.0.0/4</code>.</p><p>The maximum number of CIDR blocks of a single VPC is controlled by the quota <code>ZEC\_CIDR\_IPv4\_Blocks\_per\_VPC</code>, which is 5 by default and can be increased upon request.</p><p>This quota counts the <strong>total</strong> number of the primary CIDR block and the secondary CIDR blocks, so up to 4 secondary CIDR blocks can be added under the default quota.</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 a secondary CIDR block to a VPC.**

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

Request：
{
  "vpcId": "<vpcId>",
  "cidrBlock": "172.16.0.0/16"
}

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\_VPC\_NOT\_FOUND                        | The global VPC does not exist.                                                    |
| 400              | INVALID\_CIDR\_BLOCK\_FORMAT                    | Invalid CIDR block format.                                                        |
| 400              | INVALID\_CIDR\_BLOCK\_NETMASK\_RANGE            | CIDR block range is invalid.                                                      |
| 400              | INVALID\_CIDR\_BLOCK\_NOT\_EMPTY                | CIDR block cannot be empty.                                                       |
| 400              | INVALID\_IP\_BROADCAST\_ADDRESS                 | The IP address cannot be a broadcast address.                                     |
| 400              | OPERATION\_DENIED\_DEFAULT\_VPC                 | The default global VPC cannot be modified.                                        |
| 400              | OPERATION\_DENIED\_VPC\_CIDR\_OVERLAP           | The CIDR blocks of the VPC overlap with each other.                               |
| 400              | OPERATION\_DENIED\_VPC\_CIDR\_RESERVED          | The CIDR block of the VPC overlaps with a reserved CIDR block and cannot be used. |
| 400              | OPERATION\_DENIED\_VPC\_SECONDARY\_CIDR\_EXISTS | The secondary CIDR block of the VPC already exists.                               |
