# ModifySubnetStackType

## 1. API Description

This API (ModifySubnetStackType) is used to modify the IP stack type of subnet under a global VPC.

{% 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](https://docs.console.zenlayer.com/api-reference/compute/datastructure#ipv6type)               | <p>Subnet IPv6 type.</p><p>The optional values are as follows: Public , Private</p>                                                                                                                                                                                                                                                                                                                            |
| stackType       | No       | [SubnetStackType](https://docs.console.zenlayer.com/api-reference/compute/datastructure#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](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\_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\_MAST\_LENGTH                              | The IPv6 address mask length must be greater than 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.                      |
