Database

Execute a SQL query.

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

post/api/v1/sql

Request

  • Base URL: https://api.scalix.world
  • URL: https://api.scalix.world/api/v1/sql
  • Auth: HTTP bearer

Request body

querystring required

The SQL statement, with $1, $2, … placeholders for params.

paramsobject nullable

Positional bind parameters for the placeholders, in order.

timeline_idstring nullable

Branch timeline to run the query against, as returned by scalix_db_branch_create (optionally in its db_<timeline> connection-string form). Omit for the project's primary. A timeline that is not a branch of this project is rejected — it never falls back to the primary (F17).

Example request

{
  "query": "SELECT * FROM users WHERE id = $1"
}

Response

Query results

rowsobject required

Rows; each row is an array of cell values aligned to columns.

row_countinteger required

Number of rows returned (or affected).

commandstring required

The SQL command tag (e.g. SELECT, INSERT).

duration_msnumber double required

Server-side execution time in milliseconds.

Example response

{
  "columns": [
    {
      "name": "id",
      "type_oid": 23,
      "type_name": "int4"
    }
  ],
  "command": "SELECT"
}

Changes

No recorded changes to this operation across all 1 revision of this API.