# Firewall endpoints (Client API: game servers)

> 6 FeatherPanel Client API: game servers endpoints from user/server/firewall.php: methods, paths, auth, permissions, rate limits, parameters and responses.

Source: https://featherpanel.com/docs/api/reference/user/server/firewall/

Defined in [`backend/app/routes/user/server/firewall.php`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/routes/user/server/firewall.php). Authentication used here: **Server access**. Read [Authentication](https://featherpanel.com/docs/api/authentication/) for how to send credentials and [Rate limits and errors](https://featherpanel.com/docs/api/rate-limits-and-errors/) for the response envelope.

Paths, methods, permissions and rate limits come from the route file. Summaries, parameters and response codes come from the OpenAPI annotations on the controllers; endpoints without annotations show only what the route file declares.

## Endpoints

### GET `/api/user/servers/{uuidShort}/firewall`

- Auth: Server access
- Default rate limit: 30 / minute (`user-server-firewall`)
- Route name: `user-server-firewall-list`
- Controller: [`ServerFirewallController::listRules`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/User/Server/ServerFirewallController.php)
- [route source](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/routes/user/server/firewall.php#L28)

**List firewall rules** Get all firewall rules for a server that the user owns or has subuser access to.

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `uuidShort` | path | string | yes | Server short UUID |

| Response `data` field | Type | Description |
| --- | --- | --- |
| `data` | FirewallRule\[\] |  |

```bash
curl -X GET "$PANEL_URL/api/user/servers/$UUID_SHORT/firewall" \
  -H "Authorization: Bearer $FEATHERPANEL_API_KEY" \
  -H "Accept: application/json"
```

Responses: `200` Firewall rules retrieved successfully · `400` Bad request · `401` Unauthorized · `403` Forbidden · `404` Server not found · `500` Internal server error

### POST `/api/user/servers/{uuidShort}/firewall`

- Auth: Server access
- Route name: `user-server-firewall-create`
- Controller: [`ServerFirewallController::createRule`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/User/Server/ServerFirewallController.php)
- [route source](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/routes/user/server/firewall.php#L52)

**Create firewall rule** Create a new firewall rule for a server that the user owns or has subuser access to.

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `uuidShort` | path | string | yes | Server short UUID |

Request body: [`FirewallRuleCreateRequest`](https://featherpanel.com/docs/api/schemas/#schema-firewallrulecreaterequest) (application/json)

| Body field | Type | Required | Description |
| --- | --- | --- | --- |
| `remote_ip` | string | yes | IP address or CIDR |
| `server_port` | integer | yes | Allocated port (1-65535) |
| `priority` | integer | no | Rule priority (0-10000) |
| `type` | string | yes |  |
| `protocol` | string | no |  |

| Response `data` field | Type | Description |
| --- | --- | --- |
| `data` | FirewallRule |  |

```bash
curl -X POST "$PANEL_URL/api/user/servers/$UUID_SHORT/firewall" \
  -H "Authorization: Bearer $FEATHERPANEL_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{"remote_ip":"","server_port":0,"priority":0,"type":"","protocol":""}'
```

Plugin events: [`featherpanel:server:update`](https://featherpanel.com/docs/plugins/events/server/#server-updated)

Responses: `201` Firewall rule created successfully · `400` Bad request · `401` Unauthorized · `403` Forbidden · `404` Server or node not found · `500` Internal server error

### PUT `/api/user/servers/{uuidShort}/firewall/{ruleId}`

- Auth: Server access
- Default rate limit: 10 / minute (`user-server-firewall`)
- Route name: `user-server-firewall-update`
- Controller: [`ServerFirewallController::updateRule`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/User/Server/ServerFirewallController.php)
- [route source](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/routes/user/server/firewall.php#L74)

**Update firewall rule** Update an existing firewall rule for a server that the user owns or has subuser access to.

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `uuidShort` | path | string | yes | Server short UUID |
| `ruleId` | path | integer | yes | Firewall rule ID |

Request body: [`FirewallRuleUpdateRequest`](https://featherpanel.com/docs/api/schemas/#schema-firewallruleupdaterequest) (application/json)

| Body field | Type | Required | Description |
| --- | --- | --- | --- |
| `remote_ip` | string | no | IP address or CIDR |
| `server_port` | integer | no | Allocated port (1-65535) |
| `priority` | integer | no | Rule priority (0-10000) |
| `type` | string | no |  |
| `protocol` | string | no |  |

| Response `data` field | Type | Description |
| --- | --- | --- |
| `data` | FirewallRule |  |

```bash
curl -X PUT "$PANEL_URL/api/user/servers/$UUID_SHORT/firewall/$RULE_ID" \
  -H "Authorization: Bearer $FEATHERPANEL_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{"remote_ip":"","server_port":0,"priority":0,"type":"","protocol":""}'
```

Plugin events: [`featherpanel:server:update`](https://featherpanel.com/docs/plugins/events/server/#server-updated)

Responses: `200` Firewall rule updated successfully · `400` Bad request · `401` Unauthorized · `403` Forbidden · `404` Server or rule not found · `500` Internal server error

### DELETE `/api/user/servers/{uuidShort}/firewall/{ruleId}`

- Auth: Server access
- Default rate limit: 10 / minute (`user-server-firewall`)
- Route name: `user-server-firewall-delete`
- Controller: [`ServerFirewallController::deleteRule`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/User/Server/ServerFirewallController.php)
- [route source](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/routes/user/server/firewall.php#L100)

**Delete firewall rule** Delete a firewall rule for a server that the user owns or has subuser access to.

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `uuidShort` | path | string | yes | Server short UUID |
| `ruleId` | path | integer | yes | Firewall rule ID |

```bash
curl -X DELETE "$PANEL_URL/api/user/servers/$UUID_SHORT/firewall/$RULE_ID" \
  -H "Authorization: Bearer $FEATHERPANEL_API_KEY" \
  -H "Accept: application/json"
```

Plugin events: [`featherpanel:server:update`](https://featherpanel.com/docs/plugins/events/server/#server-updated)

Responses: `200` Firewall rule deleted successfully · `400` Bad request · `401` Unauthorized · `403` Forbidden · `404` Server or rule not found · `500` Internal server error

### GET `/api/user/servers/{uuidShort}/firewall/port/{port}`

- Auth: Server access
- Default rate limit: 30 / minute (`user-server-firewall`)
- Route name: `user-server-firewall-by-port`
- Controller: [`ServerFirewallController::getRulesByPort`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/User/Server/ServerFirewallController.php)
- [route source](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/routes/user/server/firewall.php#L126)

**Get firewall rules by port** Get all firewall rules for a specific port on a server that the user owns or has subuser access to.

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `uuidShort` | path | string | yes | Server short UUID |
| `port` | path | integer | yes | Server port |

| Response `data` field | Type | Description |
| --- | --- | --- |
| `data` | FirewallRule\[\] |  |

```bash
curl -X GET "$PANEL_URL/api/user/servers/$UUID_SHORT/firewall/port/$PORT" \
  -H "Authorization: Bearer $FEATHERPANEL_API_KEY" \
  -H "Accept: application/json"
```

Responses: `200` Firewall rules for port retrieved successfully · `400` Bad request · `401` Unauthorized · `403` Forbidden · `404` Server not found · `500` Internal server error

### POST `/api/user/servers/{uuidShort}/firewall/sync`

- Auth: Server access
- Default rate limit: 5 / minute (`user-server-firewall`)
- Route name: `user-server-firewall-sync`
- Controller: [`ServerFirewallController::syncRules`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/User/Server/ServerFirewallController.php)
- [route source](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/routes/user/server/firewall.php#L152)

**Sync firewall rules** Manually sync firewall rules for a server to iptables.

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `uuidShort` | path | string | yes | Server short UUID |

| Response `data` field | Type | Description |
| --- | --- | --- |
| `message` | string |  |

```bash
curl -X POST "$PANEL_URL/api/user/servers/$UUID_SHORT/firewall/sync" \
  -H "Authorization: Bearer $FEATHERPANEL_API_KEY" \
  -H "Accept: application/json"
```

Plugin events: [`featherpanel:server:update`](https://featherpanel.com/docs/plugins/events/server/#server-updated)

Responses: `200` Firewall rules synced successfully · `400` Bad request · `401` Unauthorized · `403` Forbidden · `404` Server or node not found · `500` Internal server error
