Create a firewall rule

Add a rule to a firewall. The rule applies to the firewall's servers shortly after the response.

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

The ID of the firewall to add the rule to.

Authorization string required

Bearer $TOKEN

Content-Type string

application/json

direction string required

Which traffic the rule matches.
Valid values:
inbound: The rule matches traffic that arrives at the server.
outbound: The rule matches traffic that leaves the server.

protocol string required

The IP protocol the rule matches. any matches every protocol. Possible values: tcp, udp, icmp, gre, esp, any.

ip_addresses array of strings required

The addresses the rule applies to, in CIDR notation, such as 10.0.0.0/8. Use 0.0.0.0/0 and ::/0 for every address. The list can't be empty.

port_from integer required

The first port of the range, from 0 to 65535. Every rule needs it. A protocol without ports, such as icmp, ignores it.

port_to integer or null

The last port of the range, from port_from to 65535. Leave it out to match only port_from.

201 Created
{
  "id": "example",
  "direction": "inbound",
  "protocol": "tcp",
  "ip_addresses": [
    "0.0.0.0/0",
    "::/0"
  ],
  "port_from": 443,
  "port_to": 443
}

Returns the newly created firewall rule.

id string

The rule's ID, a UUID.

direction string

Which traffic the rule matches.
Valid values:
inbound: The rule matches traffic that arrives at the server.
outbound: The rule matches traffic that leaves the server.

protocol string

The IP protocol the rule matches. any matches every protocol. Possible values: tcp, udp, icmp, gre, esp, any.

ip_addresses array of strings

The addresses the rule applies to, in CIDR notation, such as 10.0.0.0/8. Use 0.0.0.0/0 and ::/0 for every address. The list can't be empty.

port_from integer

The first port of the range, from 0 to 65535. Every rule needs it. A protocol without ports, such as icmp, ignores it.

port_to integer or null

The last port of the range, from port_from to 65535.