> 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/nat-gateway/modifynatgatewayattribute.md).

# ModifyNatGatewayAttribute

## 1. API Description

This API (ModifyNatGatewayAttribute) is used to modify the name, associated subnets, ICMP echo reply, and security group configuration of a NAT gateway.

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name   | Required | Type            | Description                                                                                                                                                                                                                                                                                                                                                                  |
| ---------------- | -------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| natGatewayId     | Yes      | String          | <p>NAT gateway ID.</p><p>It can be obtained by calling <a href="/api-reference/zec/nat-gateway/describenatgateways.md">DescribeNatGateways</a>.</p>                                                                                                                                                                                                                          |
| name             | No       | String          | <p>NAT gateway name.</p><p>The length is 2 to 63 characters.</p>                                                                                                                                                                                                                                                                                                             |
| subnetIds        | No       | Array of String | <p>Subnet ID of the NAT gateway.</p><p>It can be obtained by calling <a href="/api-reference/zec/vpc-network/describesubnets.md">DescribeSubnets</a>.</p>                                                                                                                                                                                                                    |
| isAllSubnet      | No       | Boolean         | <p>Whether the NAT gateway applies to all subnets.</p><p>This field cannot be set together with subnetIds .</p>                                                                                                                                                                                                                                                              |
| icmpReplyEnabled | No       | Boolean         | Whether to enable ICMP echo reply or not.                                                                                                                                                                                                                                                                                                                                    |
| securityGroupId  | No       | String          | <p>ID of the target security group to be bound to the NAT gateway.</p><p>A NAT gateway can be associated with only one security group for now.</p><p>Specifying this field unbinds the original security group of the NAT gateway.</p><p>It can be obtained by calling <a href="/api-reference/zec/security-group/describesecuritygroups.md">DescribeSecurityGroups</a>.</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 attributes of a NAT gateway and change the specified subnets.**

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

Request：
{
    "natGatewayId": "natGatewayId",
    "subnetIds": ["subnetId1", "subnetId2"]
}

Response：
{
  "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
  "response": {
    "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3"
  }
}
```

**2. Modify the attributes of a NAT gateway and change it to all subnets.**

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

Request：
{
    "natGatewayId": "natGatewayId",
    "isAllSubnet": true
}

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\_NAT\_NOT\_FOUND                      | NAT gateway does not exist.                                                                  |
| 404              | INVALID\_NAT\_SUBNET\_IS\_MISSING             | The subnet range of the NAT gateway is smaller than the subnet range of its associated SNAT. |
| 404              | INVALID\_SUBNET\_NOT\_FOUND                   | Subnet does not exist.                                                                       |
| 400              | OPERATION\_DENIED\_NAT\_STATUS                | NAT gateway state is not RUNNING.                                                            |
| 400              | OPERATION\_DENIED\_SUBNET\_STATUS             | Subnet state is not supported.                                                               |
| 400              | OPERATION\_DENIED\_SUBNET\_TYPE\_NOT\_SUPPORT | Operations on subnets with such IP stack type is not supported.                              |
| 404              | INVALID\_SECURITY\_GROUP\_NOT\_FOUND          | The specified security group does not exist.                                                 |
