---
title: "Add Firewall Rule"
method: POST
path: "/servers/{id}/firewall"
tags: ["Firewall"]
---

# Add Firewall Rule

`POST /servers/{id}/firewall`

## Request

- Base URL: `https://gpucloud.ca/api`
- URL: `https://gpucloud.ca/api/servers/{id}/firewall`
- Auth: HTTP bearer

Add a firewall rule to a server.

## Request body

- CreateFirewallRuleRequest
  - `direction` 'ingress' | 'egress', required
  - `protocol` 'tcp' | 'udp' | 'icmp', required
  - `ethertype` 'IPv4' | 'IPv6'
  - `remoteIpPrefix` string: Source CIDR (default: anywhere)
  - `portRangeMin` integer
  - `portRangeMax` integer

## Response `201`

Firewall rule created

- object
  - `data` FirewallRule
    - `id` integer
    - `direction` 'ingress' | 'egress'
    - `protocol` 'tcp' | 'udp' | 'icmp'
    - `port` union: Single port number or range (e.g. "8000-9000")
      - integer
      - string
    - `source` string: CIDR notation (e.g. 0.0.0.0/0)
    - `status` string
    - `createdAt` string

## Other responses

- `400`: Invalid request
- `401`: No API key (accountAction.code NO_API_KEY) or an invalid, expired, revoked or read only key on a write (INVALID_API_KEY). Provide a valid API key as `Authorization: Bearer <key>`; accountAction gives the links to create an account and a key.
- `404`: Resource not found
- `429`: Rate limit exceeded
- `500`: Internal server error

---

[API](https://skmtc.dev/gpucloud/apis/gpu-cloud-api.md) · [All operations](https://skmtc.dev/gpucloud/apis/gpu-cloud-api/llms.txt) · [OpenAPI document](https://skmtc.dev/gpucloud/apis/gpu-cloud-api/revisions/ed530411f5c7?raw)
