API guides
Errors and rate limits
Every status code, the error format and the rate limits.
๐งฑ Error format
Errors are JSON. Errors returned by the panel itself have an error message, and sometimes a machine-readable code:
{ "error": "Site not found" }
{
"error": "Confirm with your 2FA code first (step-up required).",
"code": "elevation_required"
}
Errors from the web framework โ validation, rate limits and unknown routes โ use a slightly different shape with statusCode, error (the HTTP reason) and message:
{
"statusCode": 400,
"code": "FST_ERR_VALIDATION",
"error": "Bad Request",
"message": "body/release must match pattern \"^\\d{14}$\""
}
A robust client reads message ?? error.
async function call(url, options = {}) {
const res = await fetch(url, {
...options,
headers: { Authorization: `Bearer ${process.env.ORCH_TOKEN}`, ...options.headers },
});
const body = await res.json().catch(() => ({}));
if (!res.ok) {
const err = new Error(body.message ?? body.error ?? res.statusText);
err.status = res.status;
err.code = body.code;
throw err;
}
return body;
}
use Illuminate\Http\Client\RequestException;
use Illuminate\Support\Facades\Http;
try {
$site = Http::withToken(env('ORCH_TOKEN'))
->get('https://panel.example.com/api/sites/12')
->throw()
->json();
} catch (RequestException $e) {
$message = $e->response->json('message') ?? $e->response->json('error');
report("Orchestrator API {$e->response->status()}: {$message}");
}
res = requests.get(url, headers=headers, timeout=60)
if not res.ok:
body = res.json() if res.headers.get("content-type", "").startswith("application/json") else {}
raise RuntimeError(f"{res.status_code}: {body.get('message') or body.get('error') or res.reason}")
๐ข Status codes
| Status | Meaning | What to do |
|---|---|---|
200 201 |
Success. | โ |
400 |
The request is invalid: a parameter is missing, has the wrong type or breaks a limit, or the action is not possible in the current state (for example a site that is not active). | Read message; fix the request. |
401 |
No token, a malformed Authorization header, or a token that is unknown, revoked or expired. |
Check the header and the token. |
403 |
You are logged in, but not allowed: your role, your site access, a viewer trying to change something, or an action that needs a 2FA step-up or a server permission. | Use an account with the right role and access; see the messages below. |
404 |
The resource does not exist (or you cannot see it), or the route does not exist. | Check the id and the path. |
409 |
Conflict with something already happening โ a deploy or rollback is running, a certificate is being issued, a duplicate. | Wait and retry, or follow the running operation. |
413 |
The upload is too large (over 512 MB). | Upload a smaller file. |
422 |
The request is well-formed but cannot be carried out (for example a commit that cannot be resolved). | Read error. |
429 |
Too many requests. | Wait for Retry-After seconds, then retry. |
500 |
The panel or a command on the server failed. Some endpoints add details with the command output. |
Retry once; check System โ Doctor and the panel logs. |
502 503 |
A dependency is unavailable โ the AI provider, phpMyAdmin, a remote server โ or the panel is restarting during an update. | Retry with back-off. |
Each endpoint in the reference lists the errors it returns, with their exact messages.
Authentication and permission messages
These come from the panel's access checks and can be returned by any authenticated endpoint:
| Status | Message | Why |
|---|---|---|
401 |
Unauthorized |
No Authorization header, or an invalid or expired session. |
401 |
Invalid or expired access token |
The personal access token is unknown, revoked or expired. |
403 |
Forbidden: insufficient role |
Your role may not call this endpoint (most server, billing and system endpoints are admin-only). |
403 |
Forbidden: no access to this site |
Your account has no access to the site in the URL. |
403 |
Forbidden: viewer role is read-only |
Viewers can read, never change. |
403 |
Confirm with your 2FA code first (step-up required). (code: elevation_required) |
The action needs a 2FA step-up, which only a browser session can do. |
๐ฆ Rate limits
Every client IP may make 600 requests per minute across the whole API (configurable on the panel with RATE_LIMIT_MAX). Some endpoints have their own, stricter limits:
| Endpoint | Limit |
|---|---|
POST /api/auth/login |
10 per 15 minutes per IP |
POST /api/fleet/elevate |
10 per minute per IP |
POST /api/fleet/servers/{id}/actions |
60 per minute per token or session |
POST /api/fleet/runs |
30 per minute per token or session |
POST /api/sites/{id}/databases/{dbId}/query |
30 per minute per IP |
POST /api/sites/{id}/databases/{dbId}/import |
5 per minute per IP |
POST /api/fleet/agent/enroll |
10 per minute per IP |
Agent WebSocket GET /api/terminal/fleet/agent |
30 connections per minute per IP |
POST /api/portal/{token}/support |
5 per hour per IP |
The reference shows the limit on every endpoint that has one.
Rate-limit headers
Every response carries the state of the limit that applies to it:
| Header | Meaning |
|---|---|
x-ratelimit-limit |
Requests allowed in the window. |
x-ratelimit-remaining |
Requests left in the current window. |
x-ratelimit-reset |
Seconds until the window resets. |
retry-after |
On a 429 only: seconds to wait before retrying. |
When the limit is exceeded:
HTTP/1.1 429 Too Many Requests
retry-after: 42
content-type: application/json
{"statusCode":429,"error":"Too Many Requests","message":"Rate limit exceeded, retry in 1 minute"}
Retrying
Retry 429, 502, 503 and network errors with back-off โ and respect Retry-After. Do not blindly retry 4xx errors, and be careful with non-idempotent requests: a deploy that timed out on your side may still be running โ check its status before starting another.
async function withRetry(doRequest, attempts = 5) {
for (let i = 0; ; i++) {
const res = await doRequest();
if (![429, 502, 503].includes(res.status) || i >= attempts - 1) return res;
const wait = Number(res.headers.get('retry-after')) || Math.min(2 ** i, 30);
await new Promise((r) => setTimeout(r, wait * 1000));
}
}
$response = Http::withToken(env('ORCH_TOKEN'))
->retry(5, function (int $attempt, Exception $e) {
$after = $e->response?->header('Retry-After');
return $after ? ((int) $after) * 1000 : min(2 ** $attempt, 30) * 1000;
}, function (Exception $e) {
return in_array($e->response?->status(), [429, 502, 503], true);
})
->get('https://panel.example.com/api/sites');
import time
def with_retry(do_request, attempts=5):
for i in range(attempts):
res = do_request()
if res.status_code not in (429, 502, 503) or i == attempts - 1:
return res
time.sleep(int(res.headers.get("retry-after", 0)) or min(2 ** i, 30))