REST API v1

HOKAS REST API Documentation

Automate server power, live stats, console logs, files, startup commands, environment variables, network egress, backups, and GitHub deployments.

No sections matched your filter.

Overview

Base URLhttps://hokas.net/api/v1
Content Typeapplication/json; charset=utf-8
Max Request Body2.2 MB (write_file: 1 MB)
REST API access is enabled per plan in Admin Panel → Server Types. Servers whose plan does not include API access return 403 api_not_enabled. API keys only access your own servers.

Authentication

Create an hkapi_... key on Dashboard → REST API (/dashboard/api). Keys are shown only once upon creation. Send it via Authorization: Bearer or X-API-Key header on every request.

Authorization: Bearer hkapi_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# or
X-API-Key: hkapi_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Permission Scopes

ScopeDescription
fullFull access to all endpoints.
serversList servers, details, live stats (/stats), and logs (/logs).
powerStart, stop, restart (/power), and startup run_now.
filesList, read, write, mkdir, rename, and delete files or folders.
startupRead and update startup command (/startup).
envRead, set, and remove environment variables (/env).
networkView and switch network egress mode (wireguard, mullvad, warp, router).
backupsList, create, schedule, restore, and delete backups.
githubLink repo, status, deploy, reinstall, and unlink GitHub.
redeployRedeploy / reinstall server container (/redeploy).
deletePermanently delete a server (DELETE /servers/{id}).

Rate Limits & Errors

Rate limits: 120 req/min per key, 240 req/min per user, 60 write req/min, and 40 failed auth attempts per 5 min per IP.

HTTPError CodeDescription
400invalid_json / invalid_param / action_failedInvalid JSON body, invalid parameter type, or validation failure.
401unauthorized / invalid_key / expired_keyMissing, invalid, revoked, or expired API key.
403insufficient_scope / api_not_enabled / feature_lockedMissing scope, API disabled on plan, or feature locked.
404not_foundServer (32 hex chars) or endpoint not found.
409server_busyServer is currently deploying, redeploying, or deleting.
413payload_too_largeRequest body exceeds 2.2 MB limit.
429rate_limited / throttledToo many requests (check Retry-After header).
503node_offline / node_busy / maintenanceNode is offline/busy or panel is in maintenance mode.

Node Offline or Busy Handling

When a server node is offline, under maintenance, or unreachable, the API never exposes raw internal errors and always returns a clean HTTP 503 JSON response:

{
  "ok": false,
  "error": "node_offline",
  "node_offline": true,
  "message": "This server's node is currently offline or not responding. Please try again in a few moments."
}

Servers, Stats & Logs

GET/serversscope: servers

List all your servers, their 32-char id, limits, status, and api_enabled flag.

GET/servers/{id}scope: servers

Get server details, limits, startup command, linked GitHub repository, and env variable count.

GET/servers/{id}/statsscope: servers

Get live CPU, RAM, disk, and network usage of a running server.

GET/servers/{id}/logs?lines=100scope: servers

Read live console output (lines: 1–500, default 100).

Power & Startup Command

POST/servers/{id}/powerscope: power
{"action": "start"} // "start" | "stop" | "restart"
GET/servers/{id}/startupscope: startup

Read current startup command.

PUT/servers/{id}/startupscope: startup (+power if run_now)
{"startup_command": "node index.js", "run_now": true}

File Management

Internal deploy files (/hokas-deploy.sh, /hokas-deploy.log, /.hokas-tmp) are protected and blocked.

GET/servers/{id}/files?path=/scope: files
GET/servers/{id}/files/content?path=/index.jsscope: files

Read a text file (max 2 MB; optional ?start_line=1&end_line=100).

PUT/servers/{id}/files/contentscope: files
{"path": "/config.json", "content": "{\"port\":3000}"}
POST/servers/{id}/files/mkdirscope: files
{"path": "/src/utils"}
POST/servers/{id}/files/renamescope: files
{"from": "/a.js", "to": "/b.js"}
DELETE/servers/{id}/files?path=/b.jsscope: files

Environment Variables

GET/servers/{id}/envscope: env
PUT/servers/{id}/envscope: env
{"variables": {"NODE_ENV": "production", "PORT": "3000"}, "remove": ["OLD_KEY"]}
DELETE/servers/{id}/envscope: env
{"names": ["PORT"]}

Network Egress

GET/servers/{id}/networkscope: network

Returns active mode, available modes (wireguard, mullvad, warp, router:...), and change history.

PUT/servers/{id}/networkscope: network
{"mode": "warp"}

Backups & Schedules

GET/servers/{id}/backupsscope: backups
POST/servers/{id}/backupsscope: backups
{"name": "api-backup-1", "scope": "files"} // "files" | "db" | "both"
PUT/servers/{id}/backups/schedulescope: backups
{"enabled": true, "freq": "daily", "keep": 3, "scope": "files"}
POST/servers/{id}/backups/{uid}/restorescope: backups
GET/servers/{id}/backups/restore-statusscope: backups
DELETE/servers/{id}/backups/{uid}scope: backups

GitHub Deploy

GET/servers/{id}/githubscope: github
POST / PUT/servers/{id}/github/linkscope: github
{"repo_url": "https://github.com/user/repo", "branch": "main", "auto_deploy": true, "install_deps": true}
POST/servers/{id}/github/deployscope: github
POST/servers/{id}/github/reinstallscope: github
DELETE/servers/{id}/githubscope: github

Redeploy & Delete

POST/servers/{id}/redeployscope: redeploy
{"keep_files": true, "keep_databases": true, "keep_domains": false}
DELETE/servers/{id}scope: delete

Permanently deletes the server and its data. Servers with an active paid membership cannot be deleted.

Quickstart Examples

# Bash / Linux / macOS
curl -X POST "https://hokas.net/api/v1/servers/YOUR_SERVER_ID/power" \
  -H "Authorization: Bearer hkapi_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"action":"restart"}'

# Windows PowerShell
$h = @{ Authorization = "Bearer hkapi_YOUR_KEY" }
Invoke-RestMethod -Method Post -Uri "https://hokas.net/api/v1/servers/YOUR_SERVER_ID/power" `
  -Headers $h -ContentType "application/json" -Body '{"action":"restart"}'