API guides
Authentication
Personal access tokens, sessions, public endpoints — and keeping tokens safe.
🔑 Personal access tokens
Scripts, CI pipelines and integrations authenticate with a personal access token.
- In the panel, open Settings → Security → Personal Access Tokens.
- Give the token a name that says where it is used — GitHub Actions, Backup script — and choose when it expires: Never, 30 days, 90 days or 1 year.
- Click Create token and copy it. It is shown once.
A token looks like this — orch_ followed by 64 hexadecimal characters:
orch_3f9c2a7b1d4e8f6a0c5b9d2e7f1a4c8b3f9c2a7b1d4e8f6a0c5b9d2e7f1a4c8b
Send it in the Authorization header of every request:
curl https://panel.example.com/api/sites \
-H "Authorization: Bearer $ORCH_TOKEN"
const res = await fetch('https://panel.example.com/api/sites', {
headers: { Authorization: `Bearer ${process.env.ORCH_TOKEN}` },
});
use Illuminate\Support\Facades\Http;
$sites = Http::withToken(env('ORCH_TOKEN'))
->get('https://panel.example.com/api/sites')
->throw()
->json();
import os
import requests
res = requests.get(
"https://panel.example.com/api/sites",
headers={"Authorization": f"Bearer {os.environ['ORCH_TOKEN']}"},
timeout=60,
)
The header must be exactly Bearer (with a capital B and one space) followed by the token.
What a token can do
A token acts as the user who created it:
- it has that user's role — admin, developer or viewer — and their site access;
- the role and site access are read on every request, so changing the user's role or access applies to their tokens immediately;
- there are no per-token scopes: to limit what a script can do, create the token on an account with only the role and sites it needs (see Token security).
The reference shows on every endpoint which roles may call it and whether it needs access to the site.
What a token cannot do
Some things are deliberately limited to a person in a browser, with two-factor authentication:
- WebSockets — the site terminal, the server terminal and live fleet metrics;
- the 2FA step-up, and everything that needs it: free fleet commands, the server terminal, running or editing saved scripts from the browser, and turning on a server's terminal, command or AI permissions;
- enrolling, installing, updating or revoking agents, and adding servers.
Fixed fleet actions (restart a service, reboot …) and saved scripts work with a token only when the server grants the matching AI permission — see MCP server → Server permissions.
Expiry and revocation
- An expired token gets
401 {"error":"Invalid or expired access token"}. Expired tokens stay listed (marked expired) until you delete them. - Revoke a token at any time in Settings → Security; it stops working at once.
- The panel stores only a SHA-256 hash of each token and shows its first characters (
orch_3f9c2a…) and when it was last used.
Every token request is recorded
Requests made with a token appear on the AI Activity page (admin): token name, user, method, path, status, duration and IP address. Privileged actions are also written to the audit log.
🖥️ Browser sessions
The panel's own web app logs in with POST /api/auth/login and receives a session token (a JWT, valid for 24 hours by default). You can use the same flow for a browser-based tool, but prefer personal access tokens for anything automated: sessions expire, need the 2FA code at login, and keep the role they were issued with until they expire.
curl -X POST https://panel.example.com/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"[email protected]","password":"…","totpCode":"123456"}'
const res = await fetch('https://panel.example.com/api/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email: '[email protected]', password: '…', totpCode: '123456' }),
});
const { token, requiresTOTP } = await res.json();
- With two-factor authentication on and no
totpCode, the response is{"requiresTOTP": true}— ask for the code and send the request again with it. - Success returns
{"token": "eyJ…"}; send it asAuthorization: Bearer <token>. - Login is limited to 10 attempts per 15 minutes per IP address.
🌍 Endpoints without a login
| Kind | Examples | Credential |
|---|---|---|
| Public | GET /api/health |
none |
| Secret in the URL | public status pages (/api/public/status/{token}), the client portal (/api/portal/{token}) |
the random token in the path |
| Signed webhook | POST /api/webhooks/github/{token} |
GitHub's X-Hub-Signature-256 signature |
| Agent | enrollment and binary downloads under /api/fleet/agent/… |
a one-time install token, then the agent key |
See Public and internal and Fleet agent.
🌐 Calling the API from a browser
The panel only allows cross-origin browser requests from its own address (CORS_ORIGIN). Call the API from your server or CI, not from JavaScript in someone else's web page — and never put a token in front-end code.
🛡️ Token security
- One token per use. A separate token for each pipeline, server or tool, named after it, so you can revoke one without breaking the others.
- Least privilege. For CI that only deploys, create a developer account with access to just those sites, and create the token there. Use a viewer account for read-only dashboards.
- Set an expiry — 90 days or a year — and rotate before it runs out.
- Store tokens as secrets: GitHub Actions secrets, GitLab CI variables (masked and protected), environment variables on servers. Never commit them, never put them in a URL or a log.
- Watch AI Activity for unexpected paths, IP addresses or error spikes, and revoke a token as soon as it may have leaked.
- Rotate by creating the new token first, switching your tools over, then revoking the old one.