ScalixScalix Docs
Sign up

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:

json
{
  "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

CodeHTTPDescription
AUTH_FAILED401Missing, expired, or malformed token
FORBIDDEN403Insufficient scope or wrong tenant

Request errors

CodeHTTPDescription
BAD_REQUEST400Invalid request structure
VALIDATION_ERROR422JSON parsing or type mismatch
NOT_FOUND404Resource doesn't exist
ALREADY_EXISTS409Duplicate constraint violation
PAYLOAD_TOO_LARGE413Request body exceeds limit

Rate limiting

CodeHTTPDescription
RATE_LIMITED429Too many requests
DESTRUCTIVE_RATE_LIMIT429Hourly 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.

PlanDestructive ops / hour
free2
starter5
pro10
team20
business50
enterpriseunlimited

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.

  1. 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-Token response header.

  2. 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 for DROP TABLE a cannot confirm DROP 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

CodeHTTPDescription
NOT_CONFIGURED501Feature not enabled for this project
DATABASE_UNAVAILABLE503The service's backing database is unreachable — a dependency outage, retry shortly (not a platform bug; distinct from INTERNAL_ERROR)
INTERNAL_ERROR500Unexpected server error
BAD_GATEWAY502Backend service unavailable
GATEWAY_TIMEOUT504Backend service didn't respond

Auth-specific errors

CodeHTTPDescription
AUTH_FAILED401Sign-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.
FORBIDDEN403Action not permitted for this account or token — includes an unverified email attempting a gated action.
BAD_REQUEST400Malformed request, including a failed bot-prevention (captcha) check.

Database-specific errors

CodeHTTPDescription
QUERY_BLOCKED403Query 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_ERROR400Query failed to execute (syntax error, constraint violation, timeout, parameter conversion failure, empty statement, or other database error).
CONFIRMATION_REQUIRED428Destructive statement needs the two-step confirmation handshake — see above.
APPROVAL_REQUIRED202A 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:

typescript
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}`);
  }
}