SaturnSQL Schedules API
Schedule saved queries to export to Google Sheets or Slack
Schedule saved queries to export to Google Sheets or Slack
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
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.curl "https://apis.io/api/v1/apis/saturnsql-com:saturnsql-com-schedules-api"
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.
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: 3.2.0
info:
title: SaturnSQL Schedules 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: Schedules
description: Schedule saved queries to export to Google Sheets or Slack
paths:
/schedules/{id}:
get:
tags:
- Schedules
summary: Get a schedule
description: Returns a single schedule by id, with its 10 most recent run logs. Requires a session token.
operationId: get_schedules
parameters:
- name: id
in: path
required: true
schema:
type: string
format: cuid
responses:
'200':
description: Schedule
content:
application/json:
schema:
$ref: '#/components/schemas/Schedule'
example:
id: cmr9s1
savedQueryId: cmr9q1
cronExpression: 0 7 * * *
timezone: UTC
startCell: A1
includeHeaders: true
enabled: true
nextRunAt: '2026-07-27T07:00:00.000Z'
lastRunAt: '2026-07-26T07:00:00.000Z'
lastError: null
destinationType: sheets
spreadsheetId: 1AbC...
spreadsheetName: Signups tracker
sheetName: Signups
slackChannelId: null
slackChannelName: null
'401':
description: Bad or missing credentials
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Schedule not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
put:
tags:
- Schedules
summary: Update a schedule
description: Updates cadence, destination, or enabled state of a schedule. Send only the fields you want to change. Requires a session token.
operationId: update_schedules
parameters:
- name: id
in: path
required: true
schema:
type: string
format: cuid
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
cronExpression:
type: string
timezone:
type: string
spreadsheetId:
type:
- string
- 'null'
spreadsheetName:
type:
- string
- 'null'
sheetName:
type:
- string
- 'null'
startCell:
type: string
includeHeaders:
type: boolean
enabled:
type: boolean
slackChannelId:
type:
- string
- 'null'
slackChannelName:
type:
- string
- 'null'
slackMessageTemplate:
type:
- string
- 'null'
example:
cronExpression: 30 8 * * 1
timezone: America/New_York
enabled: true
responses:
'200':
description: Updated
content:
application/json:
schema:
$ref: '#/components/schemas/Schedule'
example:
id: cmr9s1
savedQueryId: cmr9q1
cronExpression: 30 8 * * 1
timezone: America/New_York
startCell: A1
includeHeaders: true
enabled: true
nextRunAt: '2026-08-03T12:30:00.000Z'
lastRunAt: '2026-07-26T07:00:00.000Z'
lastError: null
destinationType: sheets
spreadsheetId: 1AbC...
spreadsheetName: Signups tracker
sheetName: Signups
slackChannelId: null
slackChannelName: null
'400':
description: Validation failed
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Bad or missing credentials
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Insufficient scope or plan restriction
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Resource not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
delete:
tags:
- Schedules
summary: Delete a schedule
description: Deletes a schedule by id. Requires a session token.
operationId: delete_schedules
parameters:
- name: id
in: path
required: true
schema:
type: string
format: cuid
responses:
'200':
description: Deleted
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
example:
success: true
'401':
description: Bad or missing credentials
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Schedule not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/schedules/{id}/run:
post:
tags:
- Schedules
summary: Run a schedule now
description: Triggers an immediate run of a schedule (runs the saved query and exports to its destination), independent of its cadence. Takes no request body. Available to API keys with the `execute` scope.
operationId: create_schedules_run
parameters:
- name: id
in: path
required: true
schema:
type: string
format: cuid
requestBody:
required: false
content:
application/json:
schema:
type: object
description: No body required — send an empty object or omit the body entirely.
responses:
'200':
description: Ran
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
spreadsheetUrl:
type: string
writtenRange:
type: string
slackDelivered:
type: boolean
example:
success: true
spreadsheetUrl: https://docs.google.com/spreadsheets/d/1AbC.../edit
writtenRange: Signups!A1:B44
slackDelivered: false
'401':
description: Bad or missing credentials
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Schedule not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Export failed
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/schedules:
get:
tags:
- Schedules
summary: List schedules
description: Lists scheduled exports of saved queries (to Google Sheets or Slack), company-wide. Available to API keys with the `read` scope.
operationId: list_schedules
parameters: []
responses:
'200':
description: Schedules
content:
application/json:
schema:
type: object
properties:
schedules:
type: array
items:
$ref: '#/components/schemas/Schedule'
example:
schedules:
- id: cmr9s1
savedQueryId: cmr9q1
cronExpression: 0 7 * * *
timezone: UTC
startCell: A1
includeHeaders: true
enabled: true
nextRunAt: '2026-07-27T07:00:00.000Z'
lastRunAt: '2026-07-26T07:00:00.000Z'
lastError: null
destinationType: sheets
spreadsheetId: 1AbC...
spreadsheetName: Signups tracker
sheetName: Signups
slackChannelId: null
slackChannelName: null
'401':
description: Bad or missing credentials
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
post:
tags:
- Schedules
summary: Create a schedule
description: Schedules a saved query to run on a cron cadence and export its result to ONE destination — Google Sheets (spreadsheetId/spreadsheetName + sheetName + startCell) OR Slack (slackChannelId). Scheduling is plan-gated. Available to API keys with both the `write` and `execute` scopes, since a schedule runs its saved query's SQL.
operationId: create_schedules
parameters: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- savedQueryId
- cronExpression
properties:
savedQueryId:
type: string
cronExpression:
type: string
description: 5-field cron expression, e.g. '0 7 * * *' for daily 7am
timezone:
type: string
description: IANA timezone, default UTC
spreadsheetId:
type: string
description: Google Sheets destination (existing sheet)
spreadsheetName:
type: string
description: 'Or create a new spreadsheet by name (with createNew: true)'
sheetName:
type: string
startCell:
type: string
description: A1 notation, default A1
includeHeaders:
type: boolean
description: Default true
createNew:
type: boolean
description: Create a new spreadsheet named spreadsheetName
slackChannelId:
type:
- string
- 'null'
description: Slack destination (instead of Sheets)
slackChannelName:
type:
- string
- 'null'
slackMessageTemplate:
type:
- string
- 'null'
example:
savedQueryId: cmr9q1
cronExpression: 0 7 * * *
timezone: UTC
spreadsheetId: 1AbC...
sheetName: Signups
startCell: A1
includeHeaders: true
responses:
'201':
description: Created
content:
application/json:
schema:
$ref: '#/components/schemas/Schedule'
example:
id: cmr9sNEW
savedQueryId: cmr9q1
cronExpression: 0 7 * * *
timezone: UTC
startCell: A1
includeHeaders: true
enabled: true
nextRunAt: '2026-07-27T07:00:00.000Z'
lastRunAt: null
lastError: null
destinationType: sheets
spreadsheetId: 1AbC...
spreadsheetName: null
sheetName: Signups
slackChannelId: null
slackChannelName: null
'400':
description: Validation failed / more than one destination / invalid cron expression
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Bad or missing credentials
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Scheduling not available on plan
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'409':
description: A schedule already exists for this query
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
Schedule:
type: object
properties:
id:
type: string
savedQueryId:
type: string
cronExpression:
type: string
description: 5-field cron expression evaluated in `timezone`, e.g. '0 9 * * 1' for Monday 9am
timezone:
type: string
description: IANA timezone, e.g. America/New_York
startCell:
type: string
description: A1 notation anchor for the export
includeHeaders:
type: boolean
enabled:
type: boolean
nextRunAt:
type:
- string
- 'null'
format: date-time
lastRunAt:
type:
- string
- 'null'
format: date-time
lastError:
type:
- string
- 'null'
destinationType:
type:
- string
- 'null'
enum:
- sheets
- slack
- null
spreadsheetId:
type:
- string
- 'null'
spreadsheetName:
type:
- string
- 'null'
sheetName:
type:
- string
- 'null'
slackChannelId:
type:
- string
- 'null'
slackChannelName:
type:
- string
- 'null'
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.'