---
title: "Create firewall rule"
method: POST
path: "/api/vps/v1/firewall/{firewallId}/rules"
tags: ["VPS: Firewall"]
---

# Create firewall rule

`POST /api/vps/v1/firewall/{firewallId}/rules`

Create new firewall rule for a specified firewall.

By default, the firewall drops all incoming traffic,
which means you must add accept rules for all ports you want to use.

Any virtual machine that has this firewall activated will lose sync with the firewall
and will have to be synced again manually.

Use this endpoint to add new security rules to firewalls.

## Path parameters

- `firewallId` integer, required

## Request body

- VPSV1FirewallRulesStoreRequest
  - `protocol` 'TCP' | 'UDP' | 'ICMP' | 'GRE' | 'any' | 'ESP' | 'AH' | 'ICMPv6' | 'SSH' | 'HTTP' | 'HTTPS' | 'MySQL' | 'PostgreSQL', required
  - `port` string, required — Port or port range, ex: 1024:2048
  - `source` 'any' | 'custom', required
  - `source_detail` string, required — IP range, CIDR, single IP or `any`

## Response `200`

Success response

- VPSV1FirewallFirewallRuleResource
  - `id` integer — Firewall rule ID
  - `action` 'accept' | 'drop' — Firewall rule action
  - `protocol` 'TCP' | 'UDP' | 'ICMP' | 'GRE' | 'any' | 'ESP' | 'AH' | 'ICMPv6' | 'SSH' | 'HTTP' | 'HTTPS' | 'MySQL' | 'PostgreSQL' — Firewall rule protocol
  - `port` string — Firewall rule destination port: single or port range
  - `source` string — Firewall rule source. Can be `any` or `custom`
  - `source_detail` string — Firewall rule source detail. Can be `any` or IP address, CIDR or range

## Other responses

- `401` — Unauthenticated response
- `422` — Validation error response
- `500` — Error response

---

[API](https://skmtc.net/hostinger/apis/hostinger-api.md) · [All operations](https://skmtc.net/hostinger/apis/hostinger-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/hostinger/hostinger-api/versions/796bd5194565/schema)
