Authentication & Setup
Enabling the API
- Open:
Win64/PalDefender/RESTAPI/RESTConfig.json - Set
"Enabled"totrue - Restart the server.
On startup you should see logs similar to:
[16:42:28][info] [RESTAPI] Loaded 'RESTConfig.json'.
[16:42:31][info] [RESTAPI] Loaded 1 Bearer token.
[16:42:31][info] [RESTAPI] Running PalDefender RESTAPI on port 17993
Port
- Default port:
17993
Do not expose it publicly. If you want to access the API from outside your LAN / machine, put it behind a reverse proxy (nginx / Caddy / Traefik) and terminate TLS there. Keep the actual PalDefender REST API bound to localhost or a private interface.
Tokens
- Start the server once to generate an example token.
- Every
.jsonfile insideWin64/PalDefender/RESTAPI/Tokens/is treated as a valid token file. (Only exception is the fileTokenExample.json!) - Make one token per person/service. Tokens are passwords.
Example token file:
{
"Name": "AdminPanel",
"Token": "DblJITQxmavSbIWyYIEwHiND2SkMsq1LGesgmlhgzNgu230TGRlNFoWp5cavqgoa",
"Permissions": [
"REST.*"
]
}
`Permissions` may be a string or an array of strings. Use narrower permissions for public dashboards or automation that should not have full admin access.
Headers
Send the token via the standard Authorization header:
Python example
import requests
base_url = "http://127.0.0.1:17993"
# do not do this. Never store the token in any code. use smth like .env! This is only for demonstration.
token = "DblJITQxmavSbIWyYIEwHiND2SkMsq1LGesgmlhgzNgu230TGRlNFoWp5cavqgoa"
headers = {"Authorization": f"Bearer {token}"}
r = requests.get(base_url + "/v1/pdapi/version", headers=headers, timeout=10)
print(r.status_code, r.text)