ScalixScalix Docs
Sign up

Database API

Database API to run single and batch SQL queries, read query logs, and get anomaly detection, optimization, scaling, and natural-language-to-SQL help.

REST API endpoints for Database. 13 operations.

Detect database anomalies

plaintext
POST /api/v1/anomalies

Analyzes recent activity and returns a report of detected database anomalies.

Auth: Bearer API key

Responses

StatusDescription
200Anomaly report
401Missing or invalid API key
500Internal error

operationId: detectAnomalies

Translate natural language to SQL

plaintext
POST /api/v1/nl-to-sql

Generates a SQL statement from a natural-language description of the desired query.

Auth: Bearer API key

Responses

StatusDescription
200Generated SQL
401Missing or invalid API key
500Internal error

operationId: naturalLanguageToSql

Get query optimization suggestions

plaintext
POST /api/v1/optimize

Analyzes the tenant's database and returns indexing and query optimization suggestions.

Auth: Bearer API key

Responses

StatusDescription
200Optimization suggestions
401Missing or invalid API key
500Internal error

operationId: optimizeQuery

List recent query logs

plaintext
GET /api/v1/query-logs/{tenant_id}

Returns recent query-log entries for a tenant, newest first.

Auth: Bearer API key

Parameters

NameInTypeRequiredDescription
tenant_idpathstringYesTenant id (UUID)
limitqueryinteger (int64)NoMax entries to return (default 100, max 1000)

Responses

StatusDescription
200Recent query log entries
401Missing or invalid API key
500Internal error

operationId: listQueryLogs

Get scaling suggestions

plaintext
GET /api/v1/scaling

Returns capacity and scaling recommendations for the tenant's database.

Auth: Bearer API key

Responses

StatusDescription
200Scaling suggestions
401Missing or invalid API key
500Internal error

operationId: getScalingSuggestions

Execute a SQL query

plaintext
POST /api/v1/sql

Runs a parameterized SQL statement against the tenant's database and returns the result set.

Auth: Bearer API key

Request body

application/json (required) — schema SqlRequest.

Responses

StatusDescription
200Query results
400Invalid SQL
401Missing or invalid API key
429Rate limit exceeded
500Internal error

operationId: executeSql

Execute a batch of SQL queries

plaintext
POST /api/v1/sql/batch

Runs multiple SQL statements in one request; each query executes independently and returns its own result set.

Auth: Bearer API key

Request body

application/json (required) — schema BatchSqlRequest.

Responses

StatusDescription
200Array of query results
401Missing or invalid API key
500Internal error

operationId: batchSql

List databases

plaintext
GET /v1/databases

Lists the project's databases. include_deleted=true also returns soft-deleted databases still inside the recovery grace window.

Auth: Bearer API key

Parameters

NameInTypeRequiredDescription
include_deletedquerybooleanNoAlso return soft-deleted databases restorable within the grace window

Responses

StatusDescription
200Databases in the project
401Missing or invalid API key

operationId: listDatabases

Create a database

plaintext
POST /v1/databases

Creates a ScalixNova database in the project on the requested PostgreSQL major version (16 default, 17, or 18). The version is fixed at creation; branches and point-in-time restores keep it.

Auth: Bearer API key

Request body

application/json (required) — schema CreateDatabaseRequest.

Responses

StatusDescription
201Database created
400Invalid name, isolation, or pg_version (message lists the supported versions)
401Missing or invalid API key
409A database with this name already exists in the org
501Dedicated tier not provisionable on this deployment

operationId: createDatabase

Delete a database

plaintext
DELETE /v1/databases/{id}

Soft-deletes the database: it is hidden from listings and restorable via POST /v1/databases/{id}/restore until the grace window ends, after which it is purged permanently.

Auth: Bearer API key

Parameters

NameInTypeRequiredDescription
idpathstringYesDatabase id

Responses

StatusDescription
200Database scheduled for deletion
401Missing or invalid API key
404Database not found

operationId: deleteDatabase

Get a database

plaintext
GET /v1/databases/{id}

Fetches one database by id, including its PostgreSQL version and isolation tier.

Auth: Bearer API key

Parameters

NameInTypeRequiredDescription
idpathstringYesDatabase id

Responses

StatusDescription
200The database
401Missing or invalid API key
404Database not found

operationId: getDatabase

Restore a soft-deleted database

plaintext
POST /v1/databases/{id}/restore

Undoes a delete within the recovery grace window; the database returns to active with its data, version, and tier intact.

Auth: Bearer API key

Parameters

NameInTypeRequiredDescription
idpathstringYesDatabase id

Responses

StatusDescription
200Database restored to active
401Missing or invalid API key
404Database not found or past the grace window

operationId: restoreDatabase

Get or create the project's default database

plaintext
POST /v1/databases/provision

Idempotent: returns the project's default database connection info, creating the database (on the default PostgreSQL version) if none exists.

Auth: Bearer API key

Responses

StatusDescription
200Connection info for the project's default database
401Missing or invalid API key

operationId: provisionDatabase