Get your free beta license ↗
API operation · security group
POST

/security/firewall/rules

First published 3 Oct 20260.1.0Unchanged since publication

Add a firewall rule

Who may call it
AdministratorResellerCustomer
Token scope, any of
securityall
Answers201 Created

Set kind to port to open an additional port or closed to drop traffic to a port even when a service is listening. For either kind, value accepts a port from 1 to 65535 or an inclusive range such as 30000-31000, with the lower port first. TCP is the default. Append /udp for UDP or /tcp for TCP. A closed rule lasts until removed, and IP addresses on the Allow list retain access. Closing a web interface or SSH port requires the caller's IP address to be on the Allow list.

For kind allow or deny, value accepts an IPv4 or IPv6 IP address or a network in CIDR notation. An allow rule can create an exception inside a larger denied network and lifts any active bans it covers. UrbeStack rejects duplicate rules, a deny rule fully covered by an existing allow rule, and an allow rule that would fully cover an existing deny rule. It also rejects a deny rule that covers the caller's IP address, a server IP address, or loopback. Invalid rule input returns 400.

Adding a deny rule requires that no other change be pending. UrbeStack restores the previous rules after five minutes unless you confirm with urbestack-firewall-confirm or through the Confirm button in the web interface. Verify access in a new session before confirming.

As a command

Run as root on the server

Request body

JSON ·FirewallRuleCreate· 3 fields
kindstring, one of port, allow, deny, closedRequired
valuestring, up to 64 charactersRequired
notestring, up to 80 characters
Note shown beside the port in the firewall table. It accepts up to 80 printable characters and excludes quotes and backslashes.

Example

See the API overview for how to set $API and $TOKEN.
Request
curl -sS -X POST "$API/security/firewall/rules" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "kind": "port",
    "note": "added by hand",
    "value": 8443
  }'
Response · 201 Created
{
  "lifted": 1,
  "revert": {
    "armed": true,
    "deadline": "text",
    "what": "text"
  },
  "rule": {
    "created_at": "2026-09-09T10:15:00Z",
    "id": 1,
    "kind": "port",
    "note": "added by hand",
    "value": 8443
  },
  "way_in": "panel"
}

Errors

12 errors, each a status and a sentence
400Invalid IPv4 address
400Invalid IPv6 address
400Invalid id
400Refused. <value>
400Refused. <value> is loopback: the server's own services talk to each other over it
400Say which bans: an address or network, a service or rule, a search, or a time window; or clear all blocks
400kind must be port, allow, deny or closed
401Authentication required
404Ban <id> not found
409<value> holds <dn.value>, which is on Deny: remove it there first
409<value> is on Allow as <al.value>: remove it there first
409A <kind> rule for <value> already exists
Generated from release 0.2.35 (current) · the API’s own descriptionThis entry has been unchanged since it was first published in release 0.1.0 on 3 Oct 2026.
urbestack.com/docs/api/post-security-firewall-rules/