# List NAT Gateway Rules

Perform a `GET` request to retrieve all rules configured for a specific NAT gateway, including those that translate traffic from internal networks to public IP addresses.

## Endpoint

`https://api.ionos.com/cloudapi/v6/datacenters/{datacenterId}/natgateways/{natGatewayId}/rules`

## Request

```bash
curl --location \
--request GET 'https://api.ionos.com/cloudapi/v6/datacenters/15f67991-0f51-4efc-a8ad-ef1fb31a480c/natgateways/d8fbc197-d892-48b1-b8e5-e9b8c700abe2/rules' \
--header 'Authorization: Bearer $IONOS_TOKEN'
```

## Parameters

{% tabs %}
{% tab title="Path Parameters" %}
The following table lists the path parameters:

| **Path Parameters** | **Required** | **Type** | **Description**                   |
| ------------------- | ------------ | -------- | --------------------------------- |
| `datacenterId`      | Yes          | string   | The unique ID of the data center. |
| `natGatewayId`      | Yes          | string   | The unique ID of the NAT Gateway. |
| {% endtab %}        |              |          |                                   |

{% tab title="Query Parameters" %}
The following table lists the query parameters:

| **Query Parameters** | **Required** | **Type** | **Description**                                                                                                                                                                                                                                                                                                                          | **Default** |
| -------------------- | ------------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
| `pretty`             | No           | boolean  | Formats the JSON response with indentations and new lines for readability.                                                                                                                                                                                                                                                               | `true`      |
| `depth`              | No           | integer  | <p>Specifies the level of detail for response objects:<br>- depth=0: Returns only direct properties (excludes children).<br>- depth=1: Returns direct properties and child references.<br>- depth=2: Returns direct properties and child properties.<br>- depth=3: Recursively returns properties of children and their descendants.</p> | `0`         |
| `offset`             | No           | integer  | Starts the response at a specific element index for pagination. Use with `limit` for pagination.                                                                                                                                                                                                                                         | `0`         |
| `limit`              | No           | integer  | Sets the maximum number of elements to return per page. Use with `offset` for pagination.                                                                                                                                                                                                                                                | `1000`      |
| {% endtab %}         |              |          |                                                                                                                                                                                                                                                                                                                                          |             |

{% tab title="Request Header Parameters" %}
Include the following mandatory fields in the request header to authenticate your requests:

| **Header Parameters** | **Required** | **Type** | **Description**                                                             |
| --------------------- | ------------ | -------- | --------------------------------------------------------------------------- |
| `Authorization`       | Yes          | string   | Use a Bearer token to authenticate requests through a JSON Web Token (JWT). |
| {% endtab %}          |              |          |                                                                             |
| {% endtabs %}         |              |          |                                                                             |

## Response

A **200 OK** response indicates that the NAT Gateway rules are successfully listed. Each rule includes its configuration details such as `name`, `type`, `protocol`, `IP addresses`, and `port ranges`.

```json
{
  "id": "rules",
  "type": "collection",
  "href": "/datacenters/15f67991-0f51-4efc-a8ad-ef1fb31a480c/natgateways/d8fbc197-d892-48b1-b8e5-e9b8c700abe2/rules",
  "items": [
    {
      "id": "cd589a49-51c8-4bc5-ade5-3f0dc7ed44b4",
      "type": "nat-gateway-rule",
      "href": "/datacenters/15f67991-0f51-4efc-a8ad-ef1fb31a480c/natgateways/d8fbc197-d892-48b1-b8e5-e9b8c700abe2/rules/cd589a49-51c8-4bc5-ade5-3f0dc7ed44b4",
      "metadata": {
        "createdDate": "2024-01-15T09:30:00+00:00",
        "createdBy": "ionos:identity:::users/87f9a82e-b28d-49ed-9d04-fba2c0459cd3",
        "createdByUserId": "87f9a82e-b28d-49ed-9d04-fba2c0459cd3",
        "lastModifiedDate": "2024-01-15T09:30:00+00:00",
        "lastModifiedBy": "ionos:identity:::users/87f9a82e-b28d-49ed-9d04-fba2c0459cd3",
        "lastModifiedByUserId": "87f9a82e-b28d-49ed-9d04-fba2c0459cd3",
        "resourceURN": "ionos:cloudapi:natgateway:rule:cd589a49-51c8-4bc5-ade5-3f0dc7ed44b4",
        "status": "AVAILABLE",
        "statusMessage": null,
        "publicEndPoint": null
      },
      "properties": {
        "name": "Web Server Rule",
        "type": "SNAT",
        "protocol": "TCP",
        "publicIp": "203.0.113.10",
        "sourceSubnet": "192.168.1.0/24",
        "targetSubnet": "203.0.113.10/32",
        "targetPortRange": {
          "start": 80,
          "end": 80
        }
      }
    },
    {
      "id": "a8f93b12-3d46-4e8f-b7c9-2e4d5f6a7b9c",
      "type": "nat-gateway-rule",
      "href": "/datacenters/15f67991-0f51-4efc-a8ad-ef1fb31a480c/natgateways/d8fbc197-d892-48b1-b8e5-e9b8c700abe2/rules/a8f93b12-3d46-4e8f-b7c9-2e4d5f6a7b9c",
      "metadata": {
        "createdDate": "2024-01-16T14:45:00+00:00",
        "createdBy": "ionos:identity:::users/87f9a82e-b28d-49ed-9d04-fba2c0459cd3",
        "createdByUserId": "87f9a82e-b28d-49ed-9d04-fba2c0459cd3",
        "lastModifiedDate": "2024-01-16T14:45:00+00:00",
        "lastModifiedBy": "ionos:identity:::users/87f9a82e-b28d-49ed-9d04-fba2c0459cd3",
        "lastModifiedByUserId": "87f9a82e-b28d-49ed-9d04-fba2c0459cd3",
        "resourceURN": "ionos:cloudapi:natgateway:rule:a8f93b12-3d46-4e8f-b7c9-2e4d5f6a7b9c",
        "status": "AVAILABLE",
        "statusMessage": null,
        "publicEndPoint": null
      },
      "properties": {
        "name": "SSH Access Rule",
        "type": "SNAT",
        "protocol": "TCP",
        "publicIp": "203.0.113.11",
        "sourceSubnet": "192.168.2.0/24",
        "targetSubnet": "203.0.113.11/32",
        "targetPortRange": {
          "start": 22,
          "end": 22
        }
      }
    }
  ],
  "offset": 0,
  "limit": 1000,
  "_links": {
    "prev": null,
    "self": "/datacenters/15f67991-0f51-4efc-a8ad-ef1fb31a480c/natgateways/d8fbc197-d892-48b1-b8e5-e9b8c700abe2/rules?offset=0&limit=1000",
    "next": null
  }
}
```


---

# 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.ionos.com/cloud/network-services/nat-gateway/api-howtos/list-nat-gateway-rule.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.
