Errors
Error reference for the Scalix Cloud API: the JSON error envelope, error codes, HTTP status mappings, and guidance for handling failures.
Error response format
All errors follow this format:
{
"error": "Invalid API key",
"code": "AUTH_FAILED",
"request_id": "req_abc123",
"docs_url": "https://docs.scalix.world/api-reference/errors#AUTH_FAILED"
}Error codes
Authentication and authorization
| Code | HTTP | Description |
|---|---|---|
AUTH_FAILED | 401 | Missing, expired, or malformed token |
FORBIDDEN | 403 | Insufficient scope or wrong tenant |
Request errors
| Code | HTTP | Description |
|---|---|---|
BAD_REQUEST | 400 | Invalid request structure |
VALIDATION_ERROR | 422 | JSON parsing or type mismatch |
NOT_FOUND | 404 | Resource doesn't exist |
ALREADY_EXISTS | 409 | Duplicate constraint violation |
PAYLOAD_TOO_LARGE | 413 | Request body exceeds limit |
Rate limiting
| Code | HTTP | Description |
|---|---|---|
RATE_LIMITED | 429 | Too many requests |
DESTRUCTIVE_RATE_LIMIT | 429 | Hourly cap on destructive database operations reached (per API key, by plan) |
Check X-RateLimit-Reset header for when to retry.
DESTRUCTIVE_RATE_LIMIT is separate from request rate limiting: it caps
destructive SQL (see the confirmation gate below for what counts) per API
key per rolling hour, and the response carries retry_after in seconds.
| Plan | Destructive ops / hour |
|---|---|
| free | 2 |
| starter | 5 |
| pro | 10 |
| team | 20 |
| business | 50 |
| enterprise | unlimited |
Unknown/unpriced plans fall back to the free cap (fail-closed). Every completed confirmation (below) counts against the budget.
Destructive operation confirmation (428)
Destructive statements require an explicit two-step confirmation on the SQL
endpoints. The gated set (classified server-side): DROP DATABASE,
DROP TABLE, DROP INDEX, DROP SCHEMA, TRUNCATE, ALTER TABLE … DROP …,
and DELETE without a WHERE clause. A targeted DELETE … WHERE (and all
other statements) run without confirmation.
-
The first request returns
428 Precondition Required:json{ "confirmation_token": "cf_...", "action": "DROP TABLE users", "message": "Destructive operation requires confirmation. Re-submit with the X-Scalix-Confirm header set to confirmation_token.", "code": "CONFIRMATION_REQUIRED", "expires_in": 300 }The token is also returned in the
X-Scalix-Confirmation-Tokenresponse header. -
Re-submit the identical statement with
X-Scalix-Confirm: <confirmation_token>. The token is single-use, expires after 300 seconds, and is bound to both the exact statement and the API key that requested it — a token forDROP TABLE acannot confirmDROP TABLE b.
Over MCP, scalix_db_query accepts the same handshake without header access:
pass the token from the 428 body back as the confirm_token argument.
Keys flagged require-approval use a stronger human-in-the-loop gate instead:
the first request returns 202 Accepted with code: APPROVAL_REQUIRED, an
approval_id and a poll_url, and the statement runs only after a human
approves (X-Scalix-Approval: <approval_id> on the retry); see Approvals.
Server errors
| Code | HTTP | Description |
|---|---|---|
NOT_CONFIGURED | 501 | Feature not enabled for this project |
DATABASE_UNAVAILABLE | 503 | The service's backing database is unreachable — a dependency outage, retry shortly (not a platform bug; distinct from INTERNAL_ERROR) |
INTERNAL_ERROR | 500 | Unexpected server error |
BAD_GATEWAY | 502 | Backend service unavailable |
GATEWAY_TIMEOUT | 504 | Backend service didn't respond |
Auth-specific errors
| Code | HTTP | Description |
|---|---|---|
AUTH_FAILED | 401 | Sign-in failed. Returned identically for a wrong password, a non-existent account, and a locked account — the reason is deliberately not disclosed to prevent account enumeration and lockout probing. |
FORBIDDEN | 403 | Action not permitted for this account or token — includes an unverified email attempting a gated action. |
BAD_REQUEST | 400 | Malformed request, including a failed bot-prevention (captcha) check. |
Database-specific errors
| Code | HTTP | Description |
|---|---|---|
QUERY_BLOCKED | 403 | Query rejected by policy — a write with a read-only key, a forbidden DDL/schema change, or a firewall rule (incl. CREATE EXTENSION — extensions are pre-installed; pgvector lives behind the Vectors API). |
QUERY_ERROR | 400 | Query failed to execute (syntax error, constraint violation, timeout, parameter conversion failure, empty statement, or other database error). |
CONFIRMATION_REQUIRED | 428 | Destructive statement needs the two-step confirmation handshake — see above. |
APPROVAL_REQUIRED | 202 | A require-approval key hit a destructive statement — human approval flow, see above. |
Handling errors
The TypeScript SDK returns a { data, error, response } envelope instead of
throwing:
import { executeSql } from "@scalix-world/sdk";
const { data, error, response } = await executeSql({
body: { query: "SELECT * FROM users" },
});
if (error) {
if (error.code === "AUTH_FAILED") {
// Refresh token or re-authenticate
} else if (error.code === "RATE_LIMITED") {
const resetAt = Number(response.headers.get("x-ratelimit-reset"));
await sleep(resetAt * 1000 - Date.now());
} else {
console.error(`Error ${error.code}: ${error.error}`);
}
}