# Firewall Rules

> Source: https://developers.cloud66.com/v3/endpoints/firewall-rules/

## Get Firewall Rule

URL: https://developers.cloud66.com/v3/endpoints/firewall-rules/#get
Endpoint: GET /stacks/:stack_id/firewalls/:firewall_rule_id
OAuth scope: admin

Get information about a specific firewall rule.

**Related models:** Firewall Rule

### Parameters

- `stack_id` (string, required) — The stack UID
- `firewall_rule_id` (integer, required) — The firewall rule ID

### Response

```json
{
  "response": {
    "id": 5027,
    "from_ip": "0.0.0.0/0",
    "from_group_id": null,
    "from_server_id": null,
    "to_ip": null,
    "to_group_id": 128,
    "to_server_id": null,
    "protocol": "tcp",
    "port": 80,
    "rule_type": "dynamic",
    "comments": null,
    "created_at": "2014-08-29T17:58:23Z",
    "updated_at": "2014-08-29T17:58:23Z"
  }
}
```

---

## List Firewall Rules

URL: https://developers.cloud66.com/v3/endpoints/firewall-rules/#list
Endpoint: GET /stacks/:stack_id/firewalls
OAuth scope: admin

Get list of all the firewall rules of a stack.

**Related models:** Firewall Rule, Pagination

### Parameters

- `stack_id` (string, required) — The stack UID

### Response

```json
{
  "response": [
    {
      "id": 5027,
      "from_ip": "0.0.0.0/0",
      "from_group_id": null,
      "from_server_id": null,
      "to_ip": null,
      "to_group_id": 128,
      "to_server_id": null,
      "protocol": "tcp",
      "port": 80,
      "rule_type": "dynamic",
      "comments": null,
      "created_at": "2014-08-29T17:58:23Z",
      "updated_at": "2014-08-29T17:58:23Z"
    }
  ],
  "count": 2,
  "pagination": {
    "previous": null,
    "next": null,
    "current": 1,
    "per_page": 30,
    "count": 2,
    "pages": 1
  }
}
```

---

## Add Firewall Rule

URL: https://developers.cloud66.com/v3/endpoints/firewall-rules/#create
Endpoint: POST /stacks/:stack_id/firewalls
OAuth scope: admin

Add a new firewall rule to a stack.

**Related models:** Firewall Rule

### Parameters

- `stack_id` (string, required) — The stack UID
- `from_ip` (string, optional) — Source IP address or CIDR
- `protocol` (string, required) — Protocol (tcp/udp/icmp)
- `port` (integer, required) — Port number

### Response

```json
{
  "response": {
    "id": 5029,
    "from_ip": "0.0.0.0/0",
    "from_group_id": null,
    "from_server_id": null,
    "to_ip": null,
    "to_group_id": 128,
    "to_server_id": null,
    "protocol": "tcp",
    "port": 8080,
    "rule_type": "dynamic",
    "comments": "Custom rule",
    "created_at": "2015-01-01T12:00:00Z",
    "updated_at": "2015-01-01T12:00:00Z"
  }
}
```
