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

# ModifySubnetAttribute

## 1. API Description

This API (ModifySubnetAttribute) is used to modify the attributes of a subnet under a global VPC. Only the subnet name and the IPv4 CIDR block to be displayed can be modified for now.

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

* When modifying the subnet CIDR block, if instances already exist in the subnet, the new CIDR block must completely cover the original one, that is, it can only be expanded, not shrunk. For example, `10.0.0.0/24` can be changed to `10.0.0.0/23`.
  {% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name | Required | Type   | Description                                                                                                                                                                            |
| -------------- | -------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| subnetId       | Yes      | String | <p>ID of the subnet.</p><p>It can be obtained by calling <a href="/api-reference/zec/vpc-network/describesubnets.md">DescribeSubnets</a>.</p>                                          |
| subnetName     | No       | String | <p>The subnet name.</p><p>Only letters, digits, hyphens (-), underscores (\_), slashes (/), periods (.) and spaces are allowed.</p><p>Must start and end with a digit or a letter.</p> |
| cidrBlock      | No       | String | <p>IPv4 CIDR block to be modified.</p><p>Only subnets with an IPv4 stack type are supported.</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. Modify the subnet name and the IPv4 CIDR block.**

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

Request：
{
    "subnetId": "<subnetId>",
    "subnetName": "Test-Subnet",
    "cidrBlock": "10.0.0.0/23"
}

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\_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              | INVALID\_IP\_FIRST\_ADDRESS                        | The IP address cannot be a gateway address.               |
| 400              | INVALID\_IP\_NETWORK\_ADDRESS                      | The IP address cannot be a network address.               |
| 400              | INVALID\_IP\_OUT\_OF\_RANGE                        | Invalid IP address. It does not belong to the CIDR block. |
| 400              | INVALID\_PARAMETER\_SUBNET\_CIDR\_NOT\_BELONG\_VPC | The subnet does not belong to the specified VPC.          |
| 400              | INVALID\_SUBNET\_IPSTACK\_NOT\_SUPPORT             | Subnet IP stack type not supported.                       |
| 404              | INVALID\_SUBNET\_NOT\_FOUND                        | Subnet does not exist.                                    |
| 400              | OPERATION\_DENIED\_SUBNET\_CIDR\_CONFLICT          | Subnet CIDR ranges conflict.                              |
