Lakehouse API
Use the Altertable HTTP API to run SQL, estimate query scans, upload files, upsert by primary key, append event-style JSON records, validate SQL, and request autocomplete suggestions without opening a database protocol connection.
If you are working from a terminal, the CLI wraps the query, upload, upsert, and append endpoints with profile-based authentication.
Download the deployed OpenAPI contract for machine-readable request and response schemas.
Authentication
Authenticate every request with HTTP Basic Auth using your environment’s lakehouse credentials. Base64-encode lakehouse_username:lakehouse_password and store the result for the request examples below:
Then send the encoded value in the Authorization header:
Authorization: Basic <ALTERTABLE_BASIC_AUTH_TOKEN>
The Python and Ruby SDKs construct the header from your lakehouse username and password during client initialization.
POST /query
- Authentication
- HTTP Basic Auth
- Permission
- Query access to referenced catalogs
Parameters
- statementstring· body · Required
- The SQL statement to execute.
- catalogstring· body · Optional
- Catalog to use for unqualified table names.
- schemastring· body · Optional
- Schema to use for unqualified table names.
- session_idstring· body · Optional
- Reuse an existing query session.
- timezonestring· body · Optional
- IANA timezone for the session. Defaults to UTC.
- compute_sizeXS | S | M | L | XL | 2XL | 3XL | 4XL | AUTO· body · Optional
- Choose a compute tier or infer one from the SQL. AUTO cannot be combined with session_id.
- dialectstring· body · Optional
- Source SQL dialect to transpile to DuckDB before execution.
- limitinteger· body · Optional
- Limit the number of returned rows.
- offsetinteger· body · Optional
- Skip this many rows before returning results.
- formatdefault | csv | jsonl | parquet· body · Optional
- Choose the streamed output format. Defaults to the Altertable metadata, column names, and row stream.
- ephemeralboolean· body · Optional
- Create an ephemeral session. Defaults to false.
- sanitizeboolean· body · Optional
- Automatically limit returned rows. Defaults to false.
- paramsobject | array· body · Optional
- Named ($name) or positional ($1) bind values. Values must be JSON scalars.
- requested_bystring· body · Optional
- Caller identifier recorded in query logs.
- query_idUUID· body · Optional
- Assign a query identifier instead of generating one.
Response format
The default response uses JSONL (JSON Lines) for efficient streaming:
- First line: query metadata, including the session, query, and Worker identifiers
- Second line: an array of column names
- Remaining lines: one JSON array per result row, in column order
Set format to csv, jsonl, or parquet when you need a standard data stream without the Altertable metadata and column-name lines. The jsonl format emits one JSON object per row.
Response statuses
Status | Description |
|---|---|
200 | Execute a SQL query and return streaming data in the requested format |
400 | Invalid SQL query or sanitization failed |
401 | Authentication required |
POST /upload
- Authentication
- HTTP Basic Auth
- Permission
- Write access to the destination catalog
Parameters
- catalogstring· query · Required
- Catalog to ingest data into.
- schemastring· query · Required
- Schema within the catalog.
- tablestring· query · Required
- Table to create or insert into.
- modecreate | append | create_append | overwrite· query · Required
- How the uploaded data changes the destination table.
Request body
Binary file data. The server infers CSV, JSON, or Parquet from the Content-Type header when present, otherwise from magic bytes in the payload:
- CSV: Comma-separated values with header row
- JSON: JSON array of objects or JSONL (one JSON object per line)
- Parquet: Apache Parquet columnar format (most efficient)
Ingestion modes
create: Create a new table with the uploaded data (fails if the table already exists)append: Append the uploaded data to an existing table (preserves existing data)create_append: Create the table if missing; otherwise append to itoverwrite: Drop the existing table and recreate it with the uploaded data (replaces all data)
Request bodies can contain up to 100 GiB.
Response statuses
Status | Description |
|---|---|
200 | File uploaded successfully |
400 | Invalid request (e.g., malformed file) |
401 | Authentication required |
POST /upsert
- Authentication
- HTTP Basic Auth
- Permission
- Write access to the destination catalog
Parameters
- catalogstring· query · Required
- Catalog to ingest data into.
- schemastring· query · Required
- Schema within the catalog.
- tablestring· query · Required
- Table to merge rows into.
- primary_keystring· query · Required
- Column or comma-separated columns used to match existing rows.
- cursor_fieldstring· query · Optional
- Cursor column or comma-separated columns. Higher values win on primary-key collisions; NULL is lowest.
The request body contains binary CSV, JSON, or Parquet data and can be up to 100 GiB. Matching rows are updated and new rows are inserted.
Response statuses
Status | Description |
|---|---|
200 | File upserted successfully |
400 | Invalid request (e.g., malformed file or missing primary_key) |
401 | Authentication required |
POST /append
- Authentication
- HTTP Basic Auth
- Permission
- Write access to the destination catalog
Parameters
- catalogstring· query · Required
- Catalog to append data to.
- schemastring· query · Required
- Schema within the catalog.
- tablestring· query · Required
- Table to append data to.
- syncboolean· query · Optional
- Wait for processing to finish before returning.
The request body can be one JSON object or an array of objects, up to 32 MiB. For larger files, use /upload with mode=append.
Use task_id with GET /tasks/{task_id} to poll asynchronous processing. When sync=true, the response waits until the append task finishes.
The response confirms that Altertable accepted the records for asynchronous processing. Rows that still fail after retries are written to altertable.main.quarantined_appends with the destination catalog, schema, table, error, original payload, and retry count.
Automatic table management
- Infer column types from JSON values
- Create the table when it does not exist
- Add columns when later payloads contain new fields
- Make accepted data queryable within seconds
Numbers become BIGINT or DOUBLE, strings become VARCHAR, booleans become BOOLEAN, arrays and objects become JSON, and RFC3339 timestamps become TIMESTAMP.
You can also create the table manually when you need explicit types, constraints, or defaults. Append respects the existing schema and only adds missing columns.
Response statuses
Status | Description |
|---|---|
200 | Append data to a table |
400 | Invalid request |
401 | Authentication required |
403 | Catalog not found, or no write access to it |
Response fields
- error_codenull | AppendErrorCode· Optional
- error_messagestring | null· Optional
- Human-readable error message if the data was not successfully appended
- okboolean· Required
- Indicates whether the data was successfully enqueued for processing
- task_idstring | null· Optional
- Task ID that can be used to track the processing status of this batch via GET /tasks/{task_id}
POST /explain
- Authentication
- HTTP Basic Auth
- Permission
- Query access to referenced catalogs
Parameters
- statementstring· body · Required
- SQL statement to estimate.
- catalogstring· body · Optional
- Catalog to use for unqualified table names.
- schemastring· body · Optional
- Schema to use for unqualified table names.
- session_idstring· body · Optional
- Existing session to use for the estimate.
- include_planboolean· body · Optional
- Include the raw EXPLAIN plan in the response.
The response reports per-table row estimates and, when available, file and byte estimates after filter pruning. It also returns totals across all scanned tables and connection errors for catalogs that could not be attached. Each table uses the TableScanEstimate response type.
Response statuses
Status | Description |
|---|---|
200 | Explain result for the SQL statement |
400 | Invalid request parameters |
401 | Authentication required |
Response fields
- connections_errorsobject· Required
- Connection errors for attached catalogs
- errorstring | null· Optional
- Error message if the explain failed
- planarray· Optional
- Raw EXPLAIN JSON plan (wrapped in array for API compatibility)
- scanned_bytes_estimateinteger | null· Optional
- Estimated bytes to scan after filter pruning
- scanned_files_estimateinteger | null· Optional
- Estimated files to scan after filter pruning
- statementstring· Required
- The statement that was explained
- tablesTableScanEstimate[]· Required
- Per-table scan estimates
- total_bytesinteger | null· Optional
- Total bytes across all table scans
- total_filesinteger | null· Optional
- Total files across all table scans
POST /validate
- Authentication
- HTTP Basic Auth
- Permission
- Query access to referenced catalogs
Parameters
- statementstring· body · Required
- SQL statement to validate.
- catalogstring· body · Optional
- Catalog to use for validation.
- schemastring· body · Optional
- Schema to use for validation.
- session_idstring· body · Optional
- Existing session to use for validation.
Response statuses
Status | Description |
|---|---|
200 | Validation result for the SQL statement |
400 | Invalid request parameters |
401 | Authentication required |
Response fields
- connections_errorsobject· Required
- Connection errors for attached catalogs
- errorstring | null· Optional
- Error message if the statement is invalid
- statementstring· Required
- The statement that was validated
- validboolean· Required
- Whether the SQL statement is valid
POST /autocomplete
- Authentication
- HTTP Basic Auth
- Permission
- Query access to referenced catalogs
Parameters
- statementstring· body · Required
- Partial SQL statement.
- catalogstring· body · Optional
- Catalog used to scope suggestions.
- schemastring· body · Optional
- Schema used to scope suggestions.
- session_idstring· body · Optional
- Existing session used for catalog context.
- max_suggestionsinteger· body · Optional
- Maximum suggestions to return. Defaults to 20 and cannot exceed 200.
The response includes the original statement, connection errors by catalog when present, and suggestions with their type, score, and replacement start position. See AutocompleteSuggestion for the fields in each suggestion.
Response statuses
Status | Description |
|---|---|
200 | SQL autocomplete suggestions |
400 | Invalid request parameters |
401 | Authentication required |
Response fields
- connections_errorsobject· Required
- statementstring· Required
- suggestionsAutocompleteSuggestion[]· Required
GET /query/{query_id}
- Authentication
- HTTP Basic Auth
- Permission
- Access to the query
Parameters
- query_idUUID· path · Required
- Query identifier returned when execution started.
Response statuses
Status | Description |
|---|---|
200 | Query log |
401 | Authentication required |
404 | Query not found |
Response fields
Use the query_id returned by POST /query. Running-query progress fields are included when available. The optional stats object uses QueryStats.
- client_interfaceSessionKind· Required
- duration_msinteger | null· Optional
- end_timestring | null· Optional
- errorstring | null· Optional
- fingerprintinteger | null· Optional
- querystring· Required
- requested_bystring | null· Optional
- session_catalogstring | null· Optional
- session_idstring· Required
- session_schemastring | null· Optional
- start_timestring· Required
- statsnull | QueryStats· Optional
- threadsinteger· Required
- user_agentstring | null· Optional
- uuidstring· Required
- visibleboolean· Required
- percentagenumber· When available
- rows_processedinteger· When available
- total_rowsinteger· When available
GET /tasks/{task_id}
- Authentication
- HTTP Basic Auth
- Permission
- Access to the task
Parameters
- task_idUUID· path · Required
- Task identifier returned by an asynchronous request.
Task status is pending or completed.
Response statuses
Status | Description |
|---|---|
200 | Task status |
400 | Invalid task ID |
401 | Authentication required |
Response fields
- statusTaskStatus· Required
- Current status of the task
- task_idstring· Required
- The task ID
Nested response types
The endpoint responses use these nested types. Query status includes query statistics, explain returns table scan estimates, and autocomplete returns suggestions.
AutocompleteSuggestion
- extra_charstring | null· Optional
- suggestionstring· Required
- suggestion_scoreinteger· Required
- suggestion_startinteger· Required
- suggestion_typestring· Required
TableScanEstimate
- estimated_rowsinteger· Required
- Estimated number of rows in the table
- filtersstring | null· Optional
- Filters applied to the table
- scanned_bytes_estimateinteger | null· Optional
- Estimated bytes to scan after filter pruning based on column min/max stats
- scanned_files_estimateinteger | null· Optional
- Estimated files to scan after filter pruning based on column min/max stats
- table_namestring· Required
- Name of the table
- total_bytesinteger | null· Optional
- Total bytes across all data files
- total_filesinteger | null· Optional
- Total number of data files for this table
QueryStats
- cachingnull | CachingStats· Optional
- scannull | ScanStats· Optional
CachingStats
- data_bytes_hitsinteger· Required
- data_bytes_missesinteger· Required
- data_hitsinteger· Required
- data_missesinteger· Required
ScanStats
- estimated_result_rowsinteger· Required
- estimated_scanned_rowsinteger· Required
SessionKind
ArrowFlightSQL, HTTP, Postgres.
AppendErrorCode
invalid-data.
TaskStatus
pending, completed.