# ModifySubnetStackType

## 1. API Description

This API (ModifySubnetStackType) is used to modify the IP stack type of the specified subnet (IPv4, IPv4\_IPv6, or IPv6). When switching to dual-stack or IPv6-only, you must provide the IPv6 type and the corresponding CIDR block configuration.

{% hint style="info" %} <mark style="color:blue;">**Note**</mark>

<mark style="color:blue;">You can only change the IP stack type of subnet from</mark> <mark style="color:blue;">`IPv4`</mark> <mark style="color:blue;">to</mark> <mark style="color:blue;">`IPv4_IPv6`</mark><mark style="color:blue;">.</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.                                                                                                                                                                                                                                                                                                                                                                                                     |
| ipv6Type        | Yes      | [IPv6Type](/api-reference/compute/zec/datastructure.md#ipv6type)               | <p>Subnet IPv6 type.</p><p>The optional values are as follows: Public , Private</p>                                                                                                                                                                                                                                                                                                                            |
| stackType       | No       | [SubnetStackType](/api-reference/compute/zec/datastructure.md#subnetstacktype) | <p>IP stack type of subnet.</p><p>The optional values are as follows: IPv4\_IPv6</p><p>Default value: IPv4\_IPv6</p>                                                                                                                                                                                                                                                                                           |
| ipv6CidrBlockId | No       | String                                                                         | <p>ID of the public IPv6 CIDR block.</p><p>This field can only be specified when <code>ipv6Type</code> is <code>Public</code>.</p><p>If not specified, it will be allocated from the system's default IP pool.</p>                                                                                                                                                                                             |
| ipv6MaskLength  | No       | Integer                                                                        | <p>The size of the IPv6 CIDR prefix assigned to the instance.</p><p>This parameter must be used together with the <code>ipv6CidrBlockId</code> parameter.</p><p>The default value is 96 if not explicitly provided.</p><p>The minimum value must be greater than or equal to the prefix of the specified <code>ipv6CidrBlockId</code>, and the maximum value cannot exceed 96.</p><p>Value range: \[-, 96]</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> |
| ipv6CidrBlock  | String | IPv6 CIDR block of subnet.                                                                                            |

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**Modify the IP stack type of subnet.**

<pre class="language-json"><code class="lang-json"><strong>POST /api/v2/zec HTTP/1.1
</strong>Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: ModifySubnetStackType


Request:
{
  "subnetId": "XXX",
  "stackType": "IPv4_IPv6",
  "ipv6Type": "Private"
}

Response:
{
  "requestId": "TBFC01FCF-6439-4530-ADBC-16809F0C3E8F",
  "response": {
    "requestId": "TBFC01FCF-6439-4530-ADBC-16809F0C3E8F",
    "ipv6CidrBlock": "xxx"
  }
}
</code></pre>

{% 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\_STATUS                       | The CIDR block state is invalid.                                                             |
| 404              | INVALID\_CIDR\_IPV6\_NOT\_FOUND                    | IPv6 CIDR block does not exist                                                               |
| 400              | INVALID\_CIDR\_REGION\_MISMATCH                    | The subnet region does not match the IPv6 CIDR block region.                                 |
| 400              | INVALID\_MASK\_LENGTH                              | The IPv6 address mask length must be greater than or equal to the subnet IPv6 prefix length. |
| 404              | INVALID\_SUBNET\_NOT\_FOUND                        | Subnet does not exist.                                                                       |
| 404              | INVALID\_VPC\_NOT\_FOUND                           | The global VPC does not exist.                                                               |
| 404              | INVALID\_ZONE\_NOT\_FOUND                          | Region does not exist.                                                                       |
| 400              | OPERATION\_DENIED\_NO\_AVAILABLE\_CIDR             | No available CIDR block.                                                                     |
| 400              | OPERATION\_DENIED\_REGION\_NOT\_SUPPORT\_PUB\_IPV6 | Public IPv6 is not supported in the specified region.                                        |
| 400              | OPERATION\_DENIED\_SUBNET\_TYPE\_NOT\_SUPPORT      | Operations on subnets with such IP stack type is not supported.                              |
| 400              | OPERATION\_DENIED\_VPC\_NOT\_SUPPORT\_PRI\_IPV6    | Private IPv6 is not supported for the specified global VPC.                                  |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.console.zenlayer.com/api-reference/compute/zec/vpc-network/modifysubnetstacktype.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
