Documentation
Queries

Execute SQL Query

Execute SQL queries against your server's database. All queries are automatically scoped to the specified server for security.

POST
/
api
/
developer
/
projects
/
{projectId}
/
servers
/
{serverId}
/
database
/
query
curl -L -X POST 'https://flux.postacksolutions.com/api/developer/projects/{projectId}/servers/{serverId}/database/query' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "query": "SELECT * FROM end_users WHERE server_id = ? LIMIT 10",
    "args": []
  }'
200
{
  "columns": ["id", "server_id", "name", "email", "created_at"],
  "rows": [
    ["user_123", "server_abc", "John Doe", "john@example.com", "2024-01-15T10:30:00Z"],
    ["user_456", "server_abc", "Jane Smith", "jane@example.com", "2024-01-15T11:00:00Z"]
  ],
  "rowsAffected": 2,
  "executionTime": 15,
  "success": true
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your developer access token.

Path Parameters

projectId
string
required

The unique identifier of the project

serverId
string
required

The unique identifier of the server

Request Body

application/json

SQL query and parameters

query
string
required

The SQL query to execute. Only single statements are allowed (no semicolons). Maximum length: 10KB.

Security: All queries must include WHERE server_id = ? for server-scoped tables (end_users, conversations, messages, files).

Parameter Handling:

  • SELECT queries: Do NOT include server_id in the args array. The endpoint automatically adds the authenticated server ID.
  • UPDATE/DELETE queries: You can include server_id in args, but the endpoint will replace it with the authenticated server ID for security.
  • INSERT queries: Must include server_id in the VALUES clause. Ensure correct parameter order in args.
args
array

Optional array of query parameters for parameterized queries.

Important:

  • SELECT: Use empty array [] - server_id is added automatically
  • UPDATE/DELETE: Include your parameters (e.g., primary key), then server_id as last param (will be replaced with authenticated value)
  • INSERT: Include all values in order, including server_id

Response

200
application/json

Successful query execution response

columns
array<string>

Array of column names from the query result

rows
array<array>

Array of rows, where each row is an array of values matching the columns order

rowsAffected
number

Number of rows affected by the query (for INSERT, UPDATE, DELETE statements)

executionTime
number

Query execution time in milliseconds

success
boolean

Whether the query executed successfully