# 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" %} <mark style="color:blue;">**Note**</mark>

<mark style="color:blue;">When modifying a subnet’s CIDR block, if the subnet contains instances, the new CIDR block must encompass the original CIDR block.</mark>\ <mark style="color:blue;">Example:</mark> <mark style="color:blue;">`10.0.0.0/24`</mark> <mark style="color:blue;">→</mark> <mark style="color:blue;">`10.0.0.0/23`</mark>
{% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name | Required | Type   | Description                                                                                                                                    |
| -------------- | -------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| subnetId       | Yes      | String | Subnet ID.                                                                                                                                     |
| subnetName     | No       | String | <p>Subnet name.</p><p>This parameter must start and end with a number or a letter. Only letters, numbers, - and periods (.) are supported.</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" %}
**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>",
    "name": "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](https://docs.console.zenlayer.com/api-reference/api-introduction/toolkit/api-sdk)，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](https://docs.console.zenlayer.com/api-reference/api-introduction/instruction/commonerrorcode).

| 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\_CIDR\_BLOCK\_NOT\_LAN\_IP                 | CIDR block must be a private IP range.                    |
| 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.                              |
