POST/api/orgs/{org_id}/trace-sql

Run a read-only SQL query

One read-only SELECT over your own requests, spans, sessions and scores. Joins, subqueries, WITH and UNION work; table functions, system tables, SETTINGS, FORMAT, comments and a second statement are refused. Every table is limited to your organization and to the window (start and end; the last 7 days by default, at most 90). Queries stop after 10 seconds or at the scan and memory limits. SQL has its own limit: about 100 queries a minute per organization, 2 at a time.

Authentication: Bearer API key in the Authorization header

Path parameters

  • org_idstringrequired

    Your organization id (uuid). GET /api/whoami returns it.

Request body

  • querystringrequired

    One SELECT, at most 16,000 characters.

  • limitinteger

    Rows to return, 1 to 10,000.

    Default: 1000
  • startstring

    Window start; the last 7 days by default.

  • endstring

    Window end, at most 90 days after start.

Responses

  • 200

    The rows.

    Response
    • columnsarray<object>
      columns
      • namestring
      • typestring

        The JSON type of the values.

    • rowsarray<array<any>>
    • truncatedboolean

      True when limit cut the answer.

    • elapsed_msinteger
    • startstring
    • endstring
  • 400

    A construct the SQL subset refuses (sql_not_allowed); the message names it.

    Response
    • errorstringrequired

      Human-readable message.

    • codestring

      Stable machine reason, when the route defines one (for example pro_required).

    • actionstring

      Stable remediation action, when the route defines one.

    • detailsobject

      Customer-safe string facts the caller needs to act (for example a suggested identifier).

  • 401

    Missing, unknown or revoked API key.

    Response
    • errorstringrequired

      Human-readable message.

    • codestring

      Stable machine reason, when the route defines one (for example pro_required).

    • actionstring

      Stable remediation action, when the route defines one.

    • detailsobject

      Customer-safe string facts the caller needs to act (for example a suggested identifier).

  • 404

    Unknown organization, or not the key's own organization.

    Response
    • errorstringrequired

      Human-readable message.

    • codestring

      Stable machine reason, when the route defines one (for example pro_required).

    • actionstring

      Stable remediation action, when the route defines one.

    • detailsobject

      Customer-safe string facts the caller needs to act (for example a suggested identifier).

  • 422

    The query hit a time, scan or memory limit (query_too_broad), or its result is too large (sql_result_too_large).

    Response
    • errorstringrequired

      Human-readable message.

    • codestring

      Stable machine reason, when the route defines one (for example pro_required).

    • actionstring

      Stable remediation action, when the route defines one.

    • detailsobject

      Customer-safe string facts the caller needs to act (for example a suggested identifier).

  • 429

    Too many reads. rate_limited: this organization's API-key reads of the request log are over about 10 per second (burst 30) or 4 in flight on one server (sessions are not limited). build_capacity: the shared analytics read slots are busy. Retry after Retry-After.

    Response
    • errorstringrequired

      Human-readable message.

    • codestring

      Stable machine reason, when the route defines one (for example pro_required).

    • actionstring

      Stable remediation action, when the route defines one.

    • detailsobject

      Customer-safe string facts the caller needs to act (for example a suggested identifier).

  • 502

    The query failed in the store (sql_failed).

    Response
    • errorstringrequired

      Human-readable message.

    • codestring

      Stable machine reason, when the route defines one (for example pro_required).

    • actionstring

      Stable remediation action, when the route defines one.

    • detailsobject

      Customer-safe string facts the caller needs to act (for example a suggested identifier).

  • 503

    This deployment has no observability store (observability_unavailable), or the store could not answer (trace_store_error). Retry shortly.

    Response
    • errorstringrequired

      Human-readable message.

    • codestring

      Stable machine reason, when the route defines one (for example pro_required).

    • actionstring

      Stable remediation action, when the route defines one.

    • detailsobject

      Customer-safe string facts the caller needs to act (for example a suggested identifier).

Request

curl -X POST 'https://api.experientiallabs.ai/api/orgs/3f6c2a1e-8b7d-4c2a-9e51-6a0d4b2f7c10/trace-sql' \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
  "query": "select model, count() as n from requests group by model order by n desc",
  "limit": 100
}'

Response

{
  "columns": [
    {
      "name": "model",
      "type": "string"
    },
    {
      "name": "n",
      "type": "number"
    }
  ],
  "rows": [
    [
      "gpt-6-luna",
      1284
    ]
  ],
  "truncated": false,
  "elapsed_ms": 84,
  "start": "2026-11-11T14:32:07Z",
  "end": "2026-11-18T14:32:07Z"
}

https://api.experientiallabs.ai/api/orgs/3f6c2a1e-8b7d-4c2a-9e51-6a0d4b2f7c10/trace-sql