Guide
playit API
Manage your playit firewalls from your own scripts and tools.
The playit API is available with playit Premium. You need a Premium account and an API key.
POST /firewalls/update
Replace rules
Replace all rules in a firewall.
POST /firewall/patch
Allow or deny networks
Change specific networks and keep all other rules.
POST /tunnels/firewall/assign
Assign to a tunnel
Assign a firewall to a tunnel, or remove it.
Quickstart#
This quickstart reads the rules of one firewall. It does not change the firewall.
-
Get an API key#
Create an API key with the
/firewall/patchscope. For more information about scopes, see Authentication. -
Set up your shell#
The examples in these docs use Bash and curl 7.76 or later. Enter your API key. The key does not show on screen.
export PLAYIT_API_BASE='https://api.playit.gg' read -r -s -p 'API key: ' PLAYIT_API_KEY && printf '\n' export PLAYIT_API_KEY -
Send a request#
Replace the example ID with the ID of one of your firewalls. An empty
changeslist returns the current rules and changes nothing.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": [] }'The response contains the firewall rules:
{ "status": "success", "data": { "rules": "0.0.0.0/0 deny\n::/0 deny\n", "rule_count": 0, "changed": false } } -
Clean up#
When you are done, remove the key from your shell.
unset PLAYIT_API_KEY
Next steps#
- Learn how to write rules in Firewall rules.
- Learn how to read responses in Responses and errors.
- Browse all endpoints and send requests in the API reference.