Endpoint
Replace firewall rules
Replace all rules in a firewall with a new list.
https://api.playit.gg/firewalls/updateRequired scope: /firewalls/update
Caution
This endpoint deletes all rules that are not in your request. The change applies to every tunnel that uses the firewall.
Request body#
-
firewall_idstring (UUID)RequiredThe firewall to change.
-
rulesstringRequiredAll rules for the firewall, with a newline (
\n) after each rule. For the rule format, see Firewall rules.An empty string denies all traffic.
Response#
If the request succeeds, the API returns HTTP 200.
data is null.
Retries#
You can send the same request again safely. If someone else changed the firewall in the meantime, your request replaces their changes.
curl --silent --show-error --fail-with-body \
--request POST \
--url "${PLAYIT_API_BASE}/firewalls/update" \
--header "Authorization: Api-Key ${PLAYIT_API_KEY}" \
--header 'Content-Type: application/json' \
--data-binary '{
"firewall_id": "11111111-1111-4111-8111-111111111111",
"rules": "192.0.2.10/32 allow\n0.0.0.0/0 deny\n::/0 deny\n"
}'
{"status": "success", "data": null}
This example allows 192.0.2.10 and denies all other traffic.
Errors#
If the request fails, the API returns HTTP 400.
data is an object with an error field.
error | Meaning |
|---|---|
InvalidRule | A rule is not valid. details tells you which line and why. |
TooManyRules | The firewall has more rules than your plan allows. |
FirewallNotFound | Your account does not have a firewall with this ID. |
InvalidRules | Deprecated. New errors use InvalidRule. |
Rule errors#
details.line_number is the line with the error.
Line numbers start at 1.
A line number of 0 means that the error is not on one specific line.
details.reason | Meaning |
|---|---|
InvalidNetwork | The target is not a valid network. |
InvalidNetworkPrefix | The prefix after / is not valid. |
InvalidNetworkIp | The IP address is not valid. |
InvalidAsn | The ASN is not a valid number. |
InvalidCountry | The country code is not valid. |
InvalidAction | The action is not allow, deny, reject, or block. |
Ipv6NetworkTooSpecific | The IPv6 prefix is longer than /64. |
TooManyLines | The rules have too many lines. |
{
"status": "fail",
"data": {
"error": "InvalidRule",
"details": {
"line_number": 1,
"reason": "InvalidAction"
}
}
}