playit.ggAPI docs

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)Required

    The firewall to change.

  • rulesstringRequired

    All 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.

RequestBash
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"
  }'
ResponseJSON
{"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.

errorMeaning
InvalidRuleA rule is not valid. details tells you which line and why.
TooManyRulesThe firewall has more rules than your plan allows.
FirewallNotFoundYour account does not have a firewall with this ID.
InvalidRulesDeprecated. 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.reasonMeaning
InvalidNetworkThe target is not a valid network.
InvalidNetworkPrefixThe prefix after / is not valid.
InvalidNetworkIpThe IP address is not valid.
InvalidAsnThe ASN is not a valid number.
InvalidCountryThe country code is not valid.
InvalidActionThe action is not allow, deny, reject, or block.
Ipv6NetworkTooSpecificThe IPv6 prefix is longer than /64.
TooManyLinesThe rules have too many lines.
Error responseJSON
{
  "status": "fail",
  "data": {
    "error": "InvalidRule",
    "details": {
      "line_number": 1,
      "reason": "InvalidAction"
    }
  }
}