Endpoint
Allow or deny networks
Allow or deny specific networks. All other rules stay the same.
https://api.playit.gg/firewall/patchRequired scope: /firewall/patch
Request body#
-
firewall_idstring (UUID)RequiredThe firewall to change.
-
changesarrayRequiredThe networks to change. An empty array returns the current rules and changes nothing.
-
networkstringRequiredAn IPv4 address, an IPv4 network (
/0to/32), or an IPv6 network (/0to/64).An IPv4 address without a prefix becomes a
/32network. Single IPv6 addresses,ASNtargets, andCountrytargets are not accepted. -
allowedbooleanRequiredtrueallows the network.falsedenies it.
-
Response#
If the request succeeds, the API returns HTTP 200.
data contains the updated firewall.
-
rulesstringAll rules in the firewall after the change.
-
rule_countintegerThe number of rules that count toward your plan limit.
-
changedbooleantrueif the firewall changed.falseif it already had these decisions.
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}
]
}'
{
"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.
data | Meaning |
|---|---|
InvalidNetwork | A network is not valid. |
ConflictingChanges | Two changes overlap, but one allows and one denies. |
TooManyRules | The result has more rules than your plan allows. |
FirewallNotFound | Your account does not have a firewall with this ID. |
Two overlapping changes with the same decision are not a conflict.
{"status": "fail", "data": "ConflictingChanges"}