playit.ggAPI docs

Request body#

  • firewall_idstring (UUID)Required

    The firewall to change.

  • changesarrayRequired

    The networks to change. An empty array returns the current rules and changes nothing.

    • networkstringRequired

      An IPv4 address, an IPv4 network (/0 to /32), or an IPv6 network (/0 to /64).

      An IPv4 address without a prefix becomes a /32 network. Single IPv6 addresses, ASN targets, and Country targets are not accepted.

    • allowedbooleanRequired

      true allows the network. false denies it.

Response#

If the request succeeds, the API returns HTTP 200. data contains the updated firewall.

  • rulesstring

    All rules in the firewall after the change.

  • rule_countinteger

    The number of rules that count toward your plan limit.

  • changedboolean

    true if the firewall changed. false if it already had these decisions.

RequestBash
curl --silent --show-error --fail-with-body \
  --request POST \
  --url "${PLAYIT_API_BASE}/firewall/patch" \
  --header "Authorization: Api-Key ${PLAYIT_API_KEY}" \
  --header 'Content-Type: application/json' \
  --data-binary '{
    "firewall_id": "11111111-1111-4111-8111-111111111111",
    "changes": [
      {"network": "192.0.2.10", "allowed": true}
    ]
  }'
ResponseJSON
{
  "status": "success",
  "data": {
    "rules": "192.0.2.10/32 allow\n0.0.0.0/0 deny\n::/0 deny\n",
    "rule_count": 1,
    "changed": true
  }
}

Before this request, the firewall had only the two default deny rules.

How changes are applied#

The API applies all changes together, or none of them. To apply a change, the API can:

  • Add a new rule above the existing rules.
  • Remove rules for networks inside the changed network that have the opposite action.

The API keeps all other rules, comments, and formatting.

Retries#

You can send the same request again safely. If the firewall already has these decisions, changed is false.

Errors#

If the request fails, the API returns HTTP 400. data is a string.

dataMeaning
InvalidNetworkA network is not valid.
ConflictingChangesTwo changes overlap, but one allows and one denies.
TooManyRulesThe result has more rules than your plan allows.
FirewallNotFoundYour account does not have a firewall with this ID.

Two overlapping changes with the same decision are not a conflict.

Error responseJSON
{"status": "fail", "data": "ConflictingChanges"}