Create a firewall

Create a firewall. A firewall blocks all traffic that no rule allows. A new firewall comes with one rule, which allows all outbound traffic. Before you attach the firewall to a server, add an inbound rule for each port you connect on, such as port 22 for SSH.

POST https://{availability_zone}.betterstackcloud.com/v1/firewalls
Authorization string required

Bearer $TOKEN

Content-Type string

application/json

name string required

The firewall's name, unique in your organization.

team_id string required

The ID of the team that owns the firewall. betterstack team list shows it.

201 Created
{
  "id": "example",
  "name": "Example firewall",
  "rules": [
    {
      "id": "example",
      "direction": "example",
      "protocol": "example",
      "ip_addresses": [
        "example"
      ],
      "port_from": 443,
      "port_to": 443
    }
  ],
  "created_at": "2026-07-01T12:00:00.000Z",
  "updated_at": "2026-07-01T12:00:00.000Z",
  "team_id": "t123"
}

Returns the newly created firewall.

id string

The firewall's ID, a UUID.

name string

The firewall's name, unique in your organization.

rules array of objects

The firewall's rules, oldest first. Add and remove rules with the firewall rule endpoints.

rules[].id string

The rule's ID, a UUID.

rules[].direction string

Which traffic the rule matches, inbound or outbound.

rules[].protocol string

The IP protocol the rule matches. any matches every protocol.

rules[].ip_addresses array of strings

The addresses the rule applies to, in CIDR notation.

rules[].port_from integer

The first port of the range.

rules[].port_to integer or null

The last port of the range, or null when the rule matches only port_from.

created_at datetime

When the firewall was created. In ISO 8601 format, such as 2026-07-01T12:00:00Z.

updated_at datetime

When the firewall was last updated. In ISO 8601 format, such as 2026-07-01T12:00:00Z.

team_id string

The ID of the team that owns the firewall. betterstack team list shows it.