SaturnSQL Reports API

Present a saved query as a form its audience fills in, without ever showing them the SQL

GitHub OpenAPI

Operations 2

PUT /queries/{id}/chart Set a report’s chart, or clear it #
GET /queries/{id}/report Get a report’s metadata #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/saturnsql-com:saturnsql-com-reports-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

saturnsql-com-reports-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: SaturnSQL Reports API
  description: 'HTTP API for the SaturnSQL database query platform. SaturnSQL connects to your PostgreSQL, MySQL, MSSQL, Oracle, Amazon Redshift, ClickHouse, DynamoDB and BigQuery databases and lets people — and AI agents — explore their schema and run queries through one authenticated surface, without ever handling raw database credentials. **Connecting an AI assistant (Claude, ChatGPT, Cursor, Claude Code)?** Use the hosted MCP server at `https://mcp.saturnsql.com/mcp` instead of calling this API. It signs the user in with OAuth, so no API key is handled, and exposes the same connections, schema and query tools. Setup: https://saturnsql.com/help/mcp-connector


    ## Authentication


    Two bearer credentials are accepted on the `Authorization` header:


    - **API key** (recommended for scripts, CI and integrations) — a long-lived, scoped, revocable key in the `sat_live_...` format, created in Settings → API Keys. - **JWT session token** — obtained from `POST /auth/login`; expires after 24 hours and requires the TOTP step when MFA is enrolled. This is what the web app uses. ```

    Authorization: Bearer sat_live_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    ```


    ### API key scopes


    A key carries one or more scopes. Everything not in the list below fails closed — a key can never manage other keys, users, billing, or connections. | Scope | Grants |

    |-------|--------|

    | `read` | `GET /connections`, `GET /schema/{connectionId}`, `GET /schema/context`, `GET /queries`, `GET /queries/{id}`, `GET /queries/history` |

    | `execute` | `POST /queries/execute` (run SQL), `POST /queries/{id}/run` (run a saved query from values) |

    | `write` | `POST /queries`, `PUT /queries` (save / update saved queries); with `execute` also `POST /schedules` (create a schedule, which runs its saved query) |


    Give an agent the narrowest scope it needs: `read` alone to explore schema and saved queries, add `execute` only when it must run SQL, add `write` only when it should persist queries. Name the key after the agent and set an expiry. ## Building queries and insights with an AI agent


    The intended agent loop is **discover → understand → query → (optionally) save**. Every call is scoped to the company the key belongs to, and only connections the key''s owner can see are reachable. ### 1. Discover connections


    List the databases available to the key and pick a `connectionId`:


    ```

    curl -s https://saturnsql.com/api/connections \

    -H ''Authorization: Bearer sat_live_...''

    ```


    Each connection reports its `id`, `name`, database `type` and whether it is read-only. ### 2. Understand the schema


    Pull the tables, columns and types so the agent writes SQL against the real structure — never guess table or column names:


    ```

    # Full schema for a connection

    curl -s ''https://saturnsql.com/api/schema/CONNECTION_ID'' \

    -H ''Authorization: Bearer sat_live_...''


    # Relevance-ranked subset for a goal (best for large databases)

    curl -s ''https://saturnsql.com/api/schema/context?connection_id=CONNECTION_ID&intent=monthly%20revenue%20by%20plan'' \

    -H ''Authorization: Bearer sat_live_...''

    ```


    `GET /schema/context` accepts `connection_id` (required), `intent` (a natural-language description of what you''re after), `tables` (comma-separated allowlist) and `current_sql`, and returns only the slice of schema relevant to that intent. Feed it straight into your SQL-generation prompt to keep context small and accurate. ### 3. Run read-only queries


    Execute generated SQL and get rows back (`execute` scope required):


    ```

    curl -s https://saturnsql.com/api/queries/execute \

    -H ''Authorization: Bearer sat_live_...'' \

    -H ''Content-Type: application/json'' \

    -d ''{"connectionId":"CONNECTION_ID","sql":"SELECT plan, count(*) AS n FROM companies GROUP BY plan ORDER BY n DESC","limit":100}''

    ```


    `limit` defaults to 1000 and caps at 10000. The response returns the result rows plus column metadata.'
  version: 1.0.0
  contact:
    name: SaturnSQL Support
    email: support@saturnsql.com
servers:
- url: https://saturnsql.com/api
  description: Production server
security:
- BearerAuth: []
- ApiKeyAuth: []
tags:
- name: Reports
  description: Present a saved query as a form its audience fills in, without ever showing them the SQL
paths:
  /queries/{id}/chart:
    put:
      tags:
      - Reports
      summary: Set a report’s chart, or clear it
      description: Stores a ChartSpec on a saved query, or clears it with `null` to go back to deciding from the result shape. The spec is stored verbatim and not validated against columns, because the columns only exist after a run; a spec that stops fitting falls back to the guess at render time rather than erroring. Owner only, and its own route rather than a field on PUT /queries so that choosing a chart cannot collide with that endpoint’s optimistic-concurrency baseline. Session token only; API keys cannot reach this.
      operationId: update_queries_chart
      security:
      - BearerAuth: []
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          format: cuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - chart
              properties:
                chart:
                  allOf:
                  - $ref: '#/components/schemas/ChartSpec'
                  description: The spec to store, or null to go back to deciding from the shape
            example:
              chart:
                type: bar
                x: region
                series:
                - revenue
      responses:
        '200':
          description: The stored configuration
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  chart:
                    allOf:
                    - $ref: '#/components/schemas/ChartSpec'
              example:
                success: true
                chart:
                  type: bar
                  x: region
                  series:
                  - revenue
        '400':
          description: Chart must be an object or null
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Bad or missing credentials
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Editor access required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Query not found, or the caller does not own it
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /queries/{id}/report:
    get:
      tags:
      - Reports
      summary: Get a report’s metadata
      description: 'Everything needed to present a saved query as a form: title, description, which connection and database the numbers come from, the variables to fill in, and the chart configuration. Never returns the SQL, so this is the endpoint to use when a caller should be able to run a query without reading it. Scoped to the caller’s company and to their own or shared queries; anything else is a 404 rather than a 403, so the endpoint cannot be used to discover query ids. Available to API keys with the `read` scope.'
      operationId: get_queries_report
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          format: cuid
      responses:
        '200':
          description: Report metadata
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReportMeta'
              example:
                id: clx1report
                title: Acquired Vehicles Log
                description: Every vehicle acquired in the window.
                connection:
                  name: Sales DB
                  database: consumer_hub_prod
                variables:
                - name: start_date
                  type: date
                  required: true
                  default:
                    kind: relative
                    value: 30_days_ago
                chart:
                  type: area
                  x: day
                  series:
                  - signups
        '401':
          description: Bad or missing credentials
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Insufficient scope
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Query not found, or not shared with the caller
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
          description: Human-readable error message
        details:
          type: object
          additionalProperties: true
          description: Optional field-level validation details
      required:
      - error
      example:
        error: Insufficient scope
    QueryVariable:
      type: object
      description: One `{{name}}` variable declared by a saved query. Values are supplied to POST /queries/{id}/run and substituted server side.
      required:
      - name
      - type
      properties:
        name:
          type: string
          description: Matches `[A-Za-z_][A-Za-z0-9_]*`
        type:
          type: string
          enum:
          - date
          - text
          - number
          - boolean
          - dropdown
        required:
          type: boolean
          description: An empty value for a required variable is a 422, not an empty substitution.
        default:
          type:
          - object
          - 'null'
          description: Used when the value is absent. A `relative` default is only valid on a `date` variable and resolves against the caller time zone (or the schedule time zone).
          properties:
            kind:
              type: string
              enum:
              - fixed
              - relative
            value:
              type: string
              description: Literal for `fixed`; one of today, yesterday, 7_days_ago, 30_days_ago, 90_days_ago, start_of_this_month, start_of_last_month, end_of_last_month, start_of_this_year for `relative`.
        options:
          type: array
          items:
            type: string
          description: Dropdown only, non-empty. A value outside this list is a 422.
    ReportMeta:
      type: object
      description: 'What the report page needs to render a saved query as a form. Deliberately excludes the SQL: the report page is the one place a query is not meant to be read as SQL, so this is strictly less than GET /queries/{id}.'
      properties:
        id:
          type: string
        title:
          type: string
        description:
          type:
          - string
          - 'null'
        connection:
          type:
          - object
          - 'null'
          description: Where the numbers come from. Null when the query has no connection, in which case it cannot be run.
          properties:
            name:
              type: string
            database:
              type: string
        variables:
          type: array
          description: The filters a reader fills in. Supply values to POST /queries/{id}/run.
          items:
            $ref: '#/components/schemas/QueryVariable'
        chart:
          allOf:
          - $ref: '#/components/schemas/ChartSpec'
          description: Null means decide from the result shape, which is the common case.
    ChartSpec:
      type: object
      description: 'How a report should be drawn. Stored verbatim and interpreted at render time, since the columns a spec refers to only exist after a run: a spec naming a column the SELECT list no longer returns falls back to the shape-derived guess rather than failing.


        With no spec stored, the result shape decides — see the "saved query is also a report page" section of the API guide for the rules an agent should write SQL against.'
      required:
      - type
      properties:
        type:
          type: string
          enum:
          - line
          - area
          - bar
          - scatter
          - share
          - number
          - none
          description: '`none` suppresses the chart for good, which is why it is distinct from a null `chart`. `share` is never guessed and must be set explicitly: its shape is identical to `bar` and nothing in the data says which is meant.'
        x:
          type: string
          description: Column for the x axis or the category. Absent for `number`.
        series:
          type: array
          items:
            type: string
          maxItems: 3
          description: 'Measure columns, in order. Capped at 3: the validated palette separates three series by lightness and a fourth has no colour.'
        group:
          type: string
          description: Low-cardinality column splitting a scatter into groups.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 24h session token from POST /auth/login
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: sat_live_...
      description: 'Long-lived scoped API key (sat_live_ prefix), created in Settings. Scopes: read, execute.'