HostCraft API Reference · v1.0

Real API Endpoint Contracts

Live reference for every route that exists under /api/v1/ — client auth, catalog, orders, wallet, services, game & web management, search, and the admin/internal APIs.

Base: /api/v1/ • Client session: HCSESSID cookie via /auth/login/ • Programmatic: Authorization: Bearer hc_… tokens
Mutating client calls require the session CSRF token in csrf_token body field or X-CSRF-Token header. Staff/internal endpoints are documented separately under /admin/api/v1/ (staff session required).

0. REST API v1 — Bearer Token Surface

The programmatic surface mirrors the console: what you can click, you can call. Create tokens under Dashboard → Profile → API Tokens — each carries scopes, an optional expiry and an IPv4 CIDR allow-list. Secrets are stored sha256-hashed and shown once.

curl -H "Authorization: Bearer hc_…" http://localhost/hostC/api/v1/me
ScopeGrants
readAll GET endpoints + POST /quote
orders.writePOST /instances — deploy + pay from wallet
instances.writePower actions, reinstall, console/VNC tickets, DELETE /instances/{id}
billing.readGET /billing, GET /invoices
*Everything
MethodEndpointScopePurpose
GET/mereadAccount, wallet, token scopes
GET/locationsreadZones + live availability + IPv4 stock + OS list
GET/plansreadAll active plans (vps/game/web, specs, INR price)
GET/osreadOS template catalogue
POST/quoteread{"plan_id":N} or {"plan":"VPS-…"} → price + spec
GET/instancesreadYour services + live power state
POST/instancesorders.writeDeploy: {"plan":"MC-2048MB","server_name":"…","eula":true,"idempotency_key":"…"} → 201 + order + job
GET/instances/{id}readDetail incl. credentials + last job — treat as secret
GET/instances/{id}/statsreadLive power, CPU, memory, uptime
POST/instances/{id}/{action}instances.writestart · stop · restart · kill · reinstall · vnc · console → 202
DELETE/instances/{id}instances.writeTerminate — body must send {"confirm":"<label>"}
GET/jobs/{id}readProvisioning job status/progress
GET/billingbilling.readWallet, monthly run-rate, unpaid orders
GET/invoicesbilling.readOrder history (last 100)
GET/statusreadNode fleet health + your instance states

tickets / dns return 404 — those modules aren't built on this platform. Limits: 600 req/min/token, 10 deploys/hour/account. Every call is logged to api_logs (method, path, status, IP, duration). Money is INR; deploys charge the wallet and return 402-style errors when it can't cover the price.

1. Response Envelopes & Authentication

Three envelope shapes exist in the codebase — all are real:

// REST v1 (token-authed, api/v1/rest.php) { "ok": true, ...payload } { "ok": false, "error": "...", "status": n } // Modern session endpoints (includes/response.php — client + admin) { "success": true, "message": "...", ...payload } { "success": false, "message": "...", "errors": { "field": "reason" } } // Legacy telemetry endpoints (health, database) { "status": "success", "data": { ... } }
Auth levelHow it is enforced
PUBLICNo session — e.g. health, register, login.
CLIENTrequire_client_auth() — HCSESSID cookie from /api/v1/client/auth/login/. Ownership is enforced server-side per row.
TOKENREST v1 Bearer token (hc_…) with scopes — see section 0.
CSRFrequire_client_csrf() on every client mutation — send csrf_token (session token) or X-CSRF-Token.

2. Health Telemetry

GET /api/v1/health/ PUBLIC

Database heartbeat + service readiness. Real response (live):

{ "status": "success", "data": { "database": "connected", "engine": "mysql", "db_version": "10.4.32-MariaDB", "timestamp": "2026-09-23T10:45:23+02:00", "service": "HostCraft Core API v1", "status": "healthy" } }

3. Client Authentication

POST/api/v1/client/auth/register/PUBLIC
FieldRequiredNotes
nameyes2–128 chars
emailyesunique — 422 if taken
usernameyesunique
passwordyes8+ chars, letter + number

Creates account → verification email sent → must verify before login. Rate-limited (429).

{ "success": true, "message": "Account created. Check your email to verify." }
POST/api/v1/client/auth/login/PUBLIC · CSRF
FieldNotes
identifier or emailemail OR username
passwordaccount password
rememberbool — extends session
csrf_tokenrequired

Sets the HCSESSID session cookie. Errors: unverified email, suspended account, invalid credentials, 429 lockout.

POST/api/v1/client/auth/otp-login/PUBLIC

Passwordless login. Two-step: {"action":"request","identifier":"…"} emails a 6-digit code, then {"action":"verify","identifier":"…","code":"123456"} returns the session.

POST/api/v1/client/auth/forgot/   …/reset/   …/verify/   …/logout/PUBLIC / CLIENT
forgot/ — body {"identifier":"email-or-username"} → mails a reset link
reset/ — body {"token":"…","password":"…"} → sets new password
verify/ — body {"token":"…"} → marks email verified
logout/ — destroys the session (client auth required)

4. Account

GET / POST/api/v1/client/account/CLIENT

GET → profile ("Account loaded."). POST → update name or change password (current_password + password).

5. Catalog

GET/api/v1/client/catalog/CLIENT
ParamNotes
(none)full catalog — plans with availability, regions, pricing
?plan_id=Nresolve one plan → "Plan resolved." (404 Plan not found.)

6. Wallet & Manual Deposits

GET/api/v1/client/wallet/CLIENT

Balance + transaction history → "Wallet loaded."

POST/api/v1/client/wallet/deposit/CLIENT · CSRF
FieldNotes
amountINR amount
txn_refUPI/bank reference — unique, 422 on reuse
screenshotpayment proof upload

Submits a manual deposit for staff approval. Rate-limited (429). Duplicate txn_ref → 422.

7. Orders

GET/api/v1/client/orders/CLIENT

?id=N → order detail; no param → list ("Orders loaded.").

POST/api/v1/client/orders/CLIENT · CSRF
FieldNotes
plan_idcatalog plan
configobject — hostname, OS, server name, eula, region…
domainrequired for web plans
idempotency_keydedupe — same key + different payload → 409 idempotency_conflict

Charges wallet atomically and queues the provisioning job. Errors: insufficient_funds (422), unavailable:<reason> (409), domain_required/bad_domain, bad_config_<field>.

8. Services & VPS

GET / POST/api/v1/client/services/CLIENT
GET — service list/detail; ?id=&action=credentials|events|sso
POST — {"id":N,"action":"renew"} (wallet-charged renewal) · request_suspend · request_terminate (staff-reviewed)
Errors: not_owner, not_renewable, duplicate_request, insufficient_funds
GET/api/v1/client/services/status/?id=NCLIENT

Live power probe against the hypervisor/panel — "Live status retrieved."

GET/api/v1/client/services/graph/?id=N&timeframe=…CLIENT

Metrics time-series for charts. Invalid timeframe / Instance has no VM on bad input.

POST/api/v1/client/services/action/CLIENT · CSRF
{"id":N,"action":"start|stop|restart|kill"} — power signals
{"id":N,"action":"reinstall","os":"…","confirm":"…"} — OS reinstall
Errors: bad_signal, suspended, reinstall_running, confirmation_mismatch, hypervisor_not_configured

9. Game Server Management

Single multiplexed endpoint — ?service=N&action=…. Backed by Pterodactyl; ownership + install-state enforced per call.

GET / POST/api/v1/client/game/?service=N&action=…CLIENT
GroupActions
Infooverview · resources · activity · events · network · provision_status
Consoleconsole_ws (mints one-time ws ticket → ws://127.0.0.1:8755/?t=…) · command · power (start|stop|restart|kill) · eula_accept
Filesfiles · file_read · file_write · file_upload · file_upload_url · file_download · files_delete · files_rename · file_copy · files_compress · file_decompress · folder_create
Backupsbackups · backup_create · backup_restore · backup_delete · backup_download
Databasesdatabases · db_create · db_delete · db_rotate
Schedulesschedules · schedule_create · schedule_update · schedule_delete · schedule_execute
Startupstartup · startup_var
Usersusers · user_invite · user_update · user_remove
Lifecyclesettings_rename · reinstall

Errors: not_game_service, no_server (still provisioning), server_installing, path_traversal, binary_file, file_too_large, ptero_forbidden.

10. Web Hosting (cPanel/WHM)

GET / POST/api/v1/client/web/?service=N&action=…CLIENT
GroupActions
Infooverview · usage · events · nameservers · dns
Databasesdatabases · db_create · db_delete · db_assign · db_user_create · db_user_delete
Mailmailboxes · mailbox_create · mailbox_delete · mailbox_password · mailbox_quota
Runtimephp · php_set · password_change
HTTPShttps_status · https_force · https_unforce

Errors: not_web_service, no_panel_user, node_unreachable, weak_password, bad_db_name, bad_mailbox.

11. Notifications & Client Search

GET / POST/api/v1/client/notifications/CLIENT

GET → list. POST {"action":"read","id":N} → "Marked as read."

GET/api/v1/search/?q=…CLIENT

Account-scoped global search — services, IPs, orders, wallet txns, deposits. Shape detection: IP/prefix/CIDR, MAC, email, pay_/order_ ids, #num, domain, text. Operators: type: status: loc: node: user:. Rate limit 30/10s → 429.

{ "q": "test-vps", "kind": "text", "took_ms": 4, "groups": [{ "type": "service", "label": "Services", "total": 1, "items": [{ "id": "service:316", "title": "QA-MC-Test", "url": "/dashboard/instances/" }] }] }