REST API
Everything the web UI does goes through the FireHawk REST API, so scripts and CI/CD pipelines can do the same: list hosts, check drift, preview and deploy, manage aliases, start rollouts.
Base URL
Section titled “Base URL”All API routes live under /api/. There are two ways to reach them:
| Through | Base URL | Notes |
|---|---|---|
| The UI address (recommended) | https://firehawk.example.com/api/ |
The frontend proxies /api/ to the API; works through your TLS reverse proxy or ingress |
| The API container directly | http://<server>:8000/api/ |
Only where port 8000 is reachable (often only on the server itself) |
Interactive documentation
Section titled “Interactive documentation”The API container serves its OpenAPI documentation on port 8000:
http://<server>:8000/docs: interactive documentation (Swagger UI) with every route, its parameters and its response formathttp://<server>:8000/redoc: the same as a reference pagehttp://<server>:8000/openapi.json: the OpenAPI schema, for code generators
These pages are not under /api/, so they are not available through the UI address. When port 8000 is only published on localhost, open them through an SSH tunnel (ssh -L 8000:127.0.0.1:8000 <server>, then http://localhost:8000/docs), or on Kubernetes with kubectl -n firehawk port-forward svc/firehawk-api 8000:8000.
Authentication with API tokens
Section titled “Authentication with API tokens”Create a personal API token on the API tokens page (every user has one):
- Scope: full (acts with all of your permissions) or read-only (only
GET,HEADandOPTIONSrequests; anything else answers 403). - Lifetime: 7 to 365 days.
- The token (
fhp_followed by 40 characters) is shown once. FireHawk stores only a hash of it, plus the time and IP address of its last use.
Send it as a bearer token:
export FIREHAWK_URL=https://firehawk.example.comexport FIREHAWK_TOKEN=fhp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
curl -s -H "Authorization: Bearer $FIREHAWK_TOKEN" "$FIREHAWK_URL/api/auth/me"A token acts as its owner: the same permission checks apply as in the UI (see Permissions), hosts the owner cannot see answer 404, and every action is audited under the owner’s name. Disabling the owner stops their tokens; deleting the owner deletes them. Tokens can be revoked on the API tokens page, and administrators see and can revoke every token.
Creating tokens and changing a password are only possible from a signed-in session, not with an API token. See Single sign-on and API tokens.
Workspaces
Section titled “Workspaces”In a FireHawk with several workspaces, every request works inside one workspace:
- An API token is bound to the workspace it was created in. Its requests always use that workspace; the
X-Workspaceheader is ignored. Create one token per workspace if a script needs several. - Signed-in sessions select the workspace with the
X-Workspaceheader (the workspace id, as returned byGET /api/workspaces). Without the header, the user’s first workspace is used.
Examples
Section titled “Examples”Health and readiness
Section titled “Health and readiness”These two routes need no authentication:
curl -s "$FIREHAWK_URL/api/health"# {"status":"ok","service":"firehawk-api","version":"1.0.0"}
curl -s "$FIREHAWK_URL/api/ready"# {"status":"ok","database":"ok"} (HTTP 503 when the database is unreachable)List hosts
Section titled “List hosts”curl -s -H "Authorization: Bearer $FIREHAWK_TOKEN" "$FIREHAWK_URL/api/hosts" \ | jq -r '.[] | [.id, .name, .firewall_backend, .drift_status, .pending_changes] | @tsv'Each host includes, among others, firewall_backend, drift_status, pending_changes (undeployed changes), persistence_status and host_key_status.
Check drift on one host
Section titled “Check drift on one host”HOST_ID=... # from the host listcurl -s -X POST -H "Authorization: Bearer $FIREHAWK_TOKEN" "$FIREHAWK_URL/api/hosts/$HOST_ID/drift/check"GET /api/hosts/{id}/drift returns the last report without connecting to the host.
Preview and deploy
Section titled “Preview and deploy”# what would change (rule diff and commands)curl -s -X POST -H "Authorization: Bearer $FIREHAWK_TOKEN" \ "$FIREHAWK_URL/api/hosts/$HOST_ID/deploy/preview"
# safe deploy with a 120 second confirmation windowcurl -s -X POST -H "Authorization: Bearer $FIREHAWK_TOKEN" \ "$FIREHAWK_URL/api/hosts/$HOST_ID/deploy?safe=true&confirm_timeout=120"The deploy answers with the deployment record, including its status (applied, auto_rolled_back, rollback_pending, …). Add dry_run=true to run the deploy without applying. confirm_timeout accepts 30 to 600 seconds. The preview is a POST, so it needs a full token even though it changes nothing.
For many hosts, prefer a server-side rollout (POST /api/rollouts) over a loop of deploy requests: it runs in batches on the workers and stops when too many hosts fail.
Main route groups
Section titled “Main route groups”| Prefix | Purpose |
|---|---|
/api/auth/... |
Current user (/me), users, single sign-on, API tokens (/tokens) |
/api/hosts |
Hosts, test SSH, detect, live rules (/{id}/rules/current), drift, persistence, host keys |
/api/hosts/{id}/rules/desired, /nat, /versions |
Desired rules, NAT rules, version history and diffs |
/api/hosts/{id}/deploy, /api/deployments/... |
Preview, deploy, deployments, rollback, safe-deploy check |
/api/aliases |
Aliases, dynamic alias refresh and source test |
/api/policies |
Layered policies |
/api/rule-templates |
Templates, apply, export and import |
/api/host-groups |
Host groups |
/api/config |
Configuration export and import |
/api/rollouts |
Rollouts: plan, create, pause, resume, cancel |
/api/jobs |
Background jobs and workers |
/api/credentials, /api/jump-hosts |
SSH credentials and jump hosts |
/api/notification-channels |
Notification channels |
/api/maintenance-windows |
Maintenance windows |
/api/access/..., /api/workspaces |
User groups, roles, grants, workspaces |
/api/audit |
Audit log |
The interactive documentation on port 8000 lists every route with its parameters.
