Databases
Create and manage databases. Each database has its own default catalog and can attach other catalogs under an alias. A query sees only the catalogs of the database it names.
List databases
/v1/databasesList databases, newest first, one page at a time. If has_more is true, pass next_cursor as cursor to get the next page.
search matches names that contain the text. To get the one database with an exact name, use GET /v1/databases/by-name. batch lists only the databases a bulk create made.
Query parameters
| Name | Type | Description |
|---|---|---|
limit | integer | Databases per page, 1 to 100. Defaults to 100. |
cursor | string | next_cursor from the previous page. |
search | string | Return only databases whose name contains this text, ignoring case. |
batch | string | Return only databases from this bulk-create batch, ordered by ID. |
Response 200 — One page of databases
| Name | Type | Description |
|---|---|---|
count | integer | Number of databases returned in this page. |
databases (required) | DatabaseSummary[] | |
has_more | boolean | Whether more databases exist after this page. |
limit | integer | Page size used for this response. |
next_cursor | string | Cursor for the next page. Present only when has_more is true. |
Fields of databases
| Name | Type | Description |
|---|---|---|
databases[].created_at | string | When the database was created. |
databases[].default_catalog (required) | string | Name of the database's own catalog in SQL. |
databases[].default_schema (required) | string | Schema that unqualified table names resolve to. |
databases[].expires_at | string | |
databases[].forked_from | ForkedFromInfo | |
databases[].id (required) | string | |
databases[].name | string |
Example response
{
"count": 0,
"databases": [
{
"created_at": "2026-01-01T00:00:00Z",
"default_catalog": "string",
"default_schema": "string",
"expires_at": "2026-01-01T00:00:00Z",
"forked_from": {
"database_id": "dbidk9p34y6n3wd25rq4f5zr37e3p3",
"description": "string",
"forked_at": "2026-01-01T00:00:00Z",
"name": "string",
"snapshot_id": 0
},
"id": "string",
"name": "string"
}
],
"has_more": true,
"limit": 0,
"next_cursor": "string"
}
Create database
/v1/databasesCreate a database. Each database gets its own default catalog with a main schema, so default.main.<table> works right away. You can declare more schemas and tables in schemas.
name is a label and does not have to be unique. Set if_not_exists to get back the database that already has this name (status 200) instead of creating a new one; the rest of the request is then ignored. Set expires_at to have the database deleted after that time. Deletion never happens earlier, but can happen later.
Request body
| Name | Type | Description |
|---|---|---|
default_catalog | string | Name of the database's own catalog in SQL. Defaults to default. Lowercase letters, digits and _, not starting with a digit. Some names are reserved, such as hotdata and information_schema. |
default_schema | string | Schema that unqualified table names resolve to. Defaults to the only schema in schemas if there is exactly one, otherwise main. |
expires_at | string | When the database expires: a future RFC 3339 timestamp, or a duration such as 90m, 24h or 7d. Omit for no expiry. |
if_not_exists | boolean | If a database with this name exists, return it with 200 instead of creating another. Requires name; the rest of the request is ignored on a match. |
name | string | Display name. Need not be unique. Defaults to a name based on the database ID. |
schemas | DatabaseDefaultSchemaDecl[] | Schemas and tables to create with the database. |
Fields of schemas
| Name | Type | Description |
|---|---|---|
schemas[].name (required) | string | |
schemas[].tables | DatabaseDefaultTableDecl[] | Tables to create in the schema. You can also add tables later. |
schemas[].tables[].constant_per_key | string[] | Columns that always hold the same value for rows with the same key. Makes keyed loads faster, but if it is not true, keyed loads silently duplicate rows. |
schemas[].tables[].key | string[] | Columns that identify a row. Required for delete, update and upsert loads unless the load request gives its own key. |
schemas[].tables[].layout | TableLayout | How a table's data files are written. Set when the table is created and fixed after that. - analytical (default): data pages sized for scans. - point_lookup: small data pages, so fetching rows by ID is cheap, as vector search results do. Scans of the table read more pages. |
schemas[].tables[].name (required) | string | |
schemas[].tables[].partition_by | TablePartitionKey[] | Columns to partition the table by, in order. Cannot be changed later. |
schemas[].tables[].sorted_by | TableSortKey[] | Columns to sort the table by, in order. Cannot be changed later, and a sorted table cannot be indexed. |
Example request
{
"schemas": [
{
"name": "sales"
}
]
}
Response 200 — if_not_exists was set and a database with this name already exists. It is returned unchanged.
| Name | Type | Description |
|---|---|---|
created | boolean | true if this call created the database; false if if_not_exists returned an existing one. |
default_catalog (required) | string | Name of the database's own catalog in SQL. |
default_connection_id (required) | string | ID of the connection behind the database's own catalog. Use it to load tables through the connection endpoints, or to attach this catalog to another database. |
default_schema (required) | string | Schema that unqualified table names resolve to. |
expires_at | string | When the database expires. |
forked_from | ForkedFromInfo | |
id (required) | string | |
name | string |
Example response
{
"created": true,
"default_catalog": "string",
"default_connection_id": "string",
"default_schema": "string",
"expires_at": "2026-01-01T00:00:00Z",
"forked_from": {
"database_id": "dbidk9p34y6n3wd25rq4f5zr37e3p3",
"description": "string",
"forked_at": "2026-01-01T00:00:00Z",
"name": "string",
"snapshot_id": 0
},
"id": "string",
"name": "string"
}
Response 201 — Database created
| Name | Type | Description |
|---|---|---|
created | boolean | true if this call created the database; false if if_not_exists returned an existing one. |
default_catalog (required) | string | Name of the database's own catalog in SQL. |
default_connection_id (required) | string | ID of the connection behind the database's own catalog. Use it to load tables through the connection endpoints, or to attach this catalog to another database. |
default_schema (required) | string | Schema that unqualified table names resolve to. |
expires_at | string | When the database expires. |
forked_from | ForkedFromInfo | |
id (required) | string | |
name | string |
Example response
{
"created": true,
"default_catalog": "string",
"default_connection_id": "string",
"default_schema": "string",
"expires_at": "2026-01-01T00:00:00Z",
"forked_from": {
"database_id": "dbidk9p34y6n3wd25rq4f5zr37e3p3",
"description": "string",
"forked_at": "2026-01-01T00:00:00Z",
"name": "string",
"snapshot_id": 0
},
"id": "string",
"name": "string"
}
Errors
| Status | Description |
|---|---|
400 | Invalid request |
409 | if_not_exists was set and more than one database has this name. |
500 | Internal server error |
Create many databases at once
/v1/databases/bulkCreate many databases from one template, in the background. The response returns at once with a batch_id and a job to poll.
Pass schemas to declare the same tables in every database. List the databases a batch created with GET /v1/databases?batch=<batch_id>.
Request body
| Name | Type | Description |
|---|---|---|
count (required) | integer | How many databases to create. Range: 1–10000 |
default_catalog | string | Name of each database's own catalog in SQL. Defaults to default. |
default_schema | string | Schema that unqualified table names resolve to in each database. |
expires_at | string | When the databases expire: a future RFC 3339 timestamp, or a duration such as 24h, 90m or 7d. |
idempotency_key | string | Key that makes the request safe to retry. A repeated key returns the original batch, even if the rest of the request differs. |
name_template | string | Name pattern for the databases. Must contain {index}, which becomes each database's zero-padded position (tenant-00 to tenant-99 for a count of 100); a batch suffix is added to each name. |
schemas | DatabaseDefaultSchemaDecl[] | Schemas and tables to create in every database. |
Fields of schemas
| Name | Type | Description |
|---|---|---|
schemas[].name (required) | string | |
schemas[].tables | DatabaseDefaultTableDecl[] | Tables to create in the schema. You can also add tables later. |
schemas[].tables[].constant_per_key | string[] | Columns that always hold the same value for rows with the same key. Makes keyed loads faster, but if it is not true, keyed loads silently duplicate rows. |
schemas[].tables[].key | string[] | Columns that identify a row. Required for delete, update and upsert loads unless the load request gives its own key. |
schemas[].tables[].layout | TableLayout | How a table's data files are written. Set when the table is created and fixed after that. - analytical (default): data pages sized for scans. - point_lookup: small data pages, so fetching rows by ID is cheap, as vector search results do. Scans of the table read more pages. |
schemas[].tables[].name (required) | string | |
schemas[].tables[].partition_by | TablePartitionKey[] | Columns to partition the table by, in order. Cannot be changed later. |
schemas[].tables[].sorted_by | TableSortKey[] | Columns to sort the table by, in order. Cannot be changed later, and a sorted table cannot be indexed. |
Example request
{
"count": 100,
"default_catalog": "default",
"default_schema": "main",
"expires_at": "7d",
"idempotency_key": "3f6b1c1e-9a2b-4a5f-9a1e-2f0d6a7c8b91",
"name_template": "tenant-{index}",
"schemas": [
{
"name": "sales"
}
]
}
Response 202 — Batch accepted. Databases are created in the background.
| Name | Type | Description |
|---|---|---|
batch_id (required) | string | |
cancel_requested (required) | boolean | True once cancellation is requested. Databases already created are kept. |
count (required) | integer | Number of databases requested. |
created_count (required) | integer | Number of databases created so far. |
expires_at | string | |
job_id | string | ID of the job creating the databases. Poll it for status. |
status_url | string |
Example response
{
"batch_id": "string",
"cancel_requested": true,
"count": 0,
"created_count": 0,
"expires_at": "2026-01-01T00:00:00Z",
"job_id": "string",
"status_url": "string"
}
Errors
| Status | Description |
|---|---|
400 | Invalid count, template, or expiry |
409 | A batch with this idempotency key is already running |
Get a database batch
/v1/databases/bulk/{batch_id}Get a batch: how many databases were requested and how many exist so far. Poll this to follow progress.
Path parameters
| Name | Type | Description |
|---|---|---|
batch_id (required) | string | Batch ID |
Response 200 — The batch
| Name | Type | Description |
|---|---|---|
batch_id (required) | string | |
cancel_requested (required) | boolean | True once cancellation is requested. Databases already created are kept. |
count (required) | integer | Number of databases requested. |
created_count (required) | integer | Number of databases created so far. |
expires_at | string | |
job_id | string | ID of the job creating the databases. Poll it for status. |
status_url | string |
Example response
{
"batch_id": "string",
"cancel_requested": true,
"count": 0,
"created_count": 0,
"expires_at": "2026-01-01T00:00:00Z",
"job_id": "string",
"status_url": "string"
}
Errors
| Status | Description |
|---|---|
404 | Batch not found |
Delete a database batch
/v1/databases/bulk/{batch_id}Stop a batch and delete the databases it created, then the batch.
This works only while no database in the batch holds loaded data. Declared but unloaded tables are fine. If any database has data, the request returns 409; delete those databases one at a time.
Path parameters
| Name | Type | Description |
|---|---|---|
batch_id (required) | string | Batch ID |
Response 200 — Batch deleted
| Name | Type | Description |
|---|---|---|
batch_id (required) | string | |
deleted_count (required) | integer | How many databases were removed. |
Example response
{
"batch_id": "string",
"deleted_count": 0
}
Errors
| Status | Description |
|---|---|
404 | Batch not found |
409 | Some databases in the batch hold loaded data |
Look up a database by name
/v1/databases/by-nameGet the database with this exact name. Matching ignores case only for unaccented Latin letters; all other characters must match exactly.
Returns 409 if more than one database has the name. Use the database ID for those.
Query parameters
| Name | Type | Description |
|---|---|---|
name (required) | string | Full name of the database. Case is ignored for ASCII letters only. |
Response 200 — Database details
| Name | Type | Description |
|---|---|---|
attachments (required) | DatabaseAttachmentInfo[] | Catalogs attached from other connections or databases. |
created_at | string | When the database was created. |
default_catalog (required) | string | Name of the database's own catalog in SQL. |
default_connection_id (required) | string | ID of the connection behind the database's own catalog. Use it to load tables through the connection endpoints, or to attach this catalog to another database. |
default_schema (required) | string | Schema that unqualified table names resolve to. |
expires_at | string | When the database expires. |
forked_from | ForkedFromInfo | |
id (required) | string | |
name | string |
Fields of attachments
| Name | Type | Description |
|---|---|---|
attachments[].alias | string | Name of the catalog in SQL. When absent, use the connection's name. |
attachments[].connection_id (required) | string |
Example response
{
"attachments": [
{
"alias": "string",
"connection_id": "string"
}
],
"created_at": "2026-01-01T00:00:00Z",
"default_catalog": "string",
"default_connection_id": "string",
"default_schema": "string",
"expires_at": "2026-01-01T00:00:00Z",
"forked_from": {
"database_id": "dbidk9p34y6n3wd25rq4f5zr37e3p3",
"description": "string",
"forked_at": "2026-01-01T00:00:00Z",
"name": "string",
"snapshot_id": 0
},
"id": "string",
"name": "string"
}
Errors
| Status | Description |
|---|---|
400 | The name parameter is empty or too long |
404 | No database has that name |
409 | More than one database has that name |
Count databases
/v1/databases/countCount the databases in the workspace. search and batch filter the same way as on GET /v1/databases.
Query parameters
| Name | Type | Description |
|---|---|---|
search | string | Count only databases whose name contains this text, ignoring case. |
batch | string | Count only databases from this bulk-create batch. |
Response 200 — Number of matching databases
| Name | Type | Description |
|---|---|---|
total (required) | integer | Total databases matching the filters, across all pages. |
Example response
{
"total": 0
}
Get database
/v1/databases/{database_id}Get a database by ID. To find one by name, use GET /v1/databases/by-name.
Path parameters
| Name | Type | Description |
|---|---|---|
database_id (required) | string | Database ID |
Response 200 — Database details
| Name | Type | Description |
|---|---|---|
attachments (required) | DatabaseAttachmentInfo[] | Catalogs attached from other connections or databases. |
created_at | string | When the database was created. |
default_catalog (required) | string | Name of the database's own catalog in SQL. |
default_connection_id (required) | string | ID of the connection behind the database's own catalog. Use it to load tables through the connection endpoints, or to attach this catalog to another database. |
default_schema (required) | string | Schema that unqualified table names resolve to. |
expires_at | string | When the database expires. |
forked_from | ForkedFromInfo | |
id (required) | string | |
name | string |
Fields of attachments
| Name | Type | Description |
|---|---|---|
attachments[].alias | string | Name of the catalog in SQL. When absent, use the connection's name. |
attachments[].connection_id (required) | string |
Example response
{
"attachments": [
{
"alias": "string",
"connection_id": "string"
}
],
"created_at": "2026-01-01T00:00:00Z",
"default_catalog": "string",
"default_connection_id": "string",
"default_schema": "string",
"expires_at": "2026-01-01T00:00:00Z",
"forked_from": {
"database_id": "dbidk9p34y6n3wd25rq4f5zr37e3p3",
"description": "string",
"forked_at": "2026-01-01T00:00:00Z",
"name": "string",
"snapshot_id": 0
},
"id": "string",
"name": "string"
}
Errors
| Status | Description |
|---|---|
404 | Database not found |
Delete database
/v1/databases/{database_id}Delete a database and its default catalog. Catalogs attached to it are detached, not deleted.
Returns 409 while another database has this database's catalog attached; detach it there first. After expires_at the database is deleted anyway, and the other database loses access.
Path parameters
| Name | Type | Description |
|---|---|---|
database_id (required) | string | Database ID |
Response 204 — Database deleted
Errors
| Status | Description |
|---|---|
404 | Database not found |
409 | Another database has this database's catalog attached |
Attach catalog to database
/v1/databases/{database_id}/catalogsAttach a catalog so its tables can be queried in this database. To query across two databases, pass the other database's default_connection_id as connection_id.
The catalog is read-only here and nothing is copied. It answers to alias, or to its own name if you omit it. That name cannot be default or a reserved name, so attaching another database's default catalog needs an alias. Attaching is not transitive: you do not see the attached catalog's own attachments.
Path parameters
| Name | Type | Description |
|---|---|---|
database_id (required) | string | Database ID |
Request body
| Name | Type | Description |
|---|---|---|
alias | string | Name to use for the catalog in SQL. Defaults to the connection's name. |
connection_id (required) | string |
Example request
{
"alias": "warehouse",
"connection_id": "connk9p34y6n3wd25rq4f5zr37e3p3"
}
Response 204 — Catalog attached
Errors
| Status | Description |
|---|---|
400 | Invalid request |
404 | Database or connection not found |
409 | The catalog is already attached, or the alias is already in use |
Detach catalog from database
/v1/databases/{database_id}/catalogs/{connection_id}Detach a catalog from a database. The catalog and its data are not deleted.
Path parameters
| Name | Type | Description |
|---|---|---|
database_id (required) | string | Database ID |
connection_id (required) | string | Connection ID |
Response 204 — Catalog detached
Errors
| Status | Description |
|---|---|
400 | Cannot detach a database's own default catalog |
404 | Database or attachment not found |
Fork database
/v1/databases/{database_id}/forkCreate a new database that starts as a copy of an existing one: same schemas, tables, data and attached catalogs. The two are independent after that; the source does not change.
Indexes come across and work at once, except vector indexes that use the ivf algorithm and indexes not up to date with the table's latest load. Create those again on the fork. A fork shares the source's storage at first, so it adds no stored bytes until it is written to or maintenance rewrites a table.
Path parameters
| Name | Type | Description |
|---|---|---|
database_id (required) | string | Source database ID |
Request body
| Name | Type | Description |
|---|---|---|
description | string | Why the fork was taken, shown in the fork's lineage. Up to 4096 bytes. |
expires_at | string | When the fork expires: a future RFC 3339 timestamp, or a duration such as 24h or 7d. Defaults to the source's expiry, if it has one. |
name | string | Display name for the fork. Defaults to the source's name plus a short suffix. |
All fields are optional. Send only the ones you want to set.
Response 201 — Database forked
| Name | Type | Description |
|---|---|---|
created | boolean | true if this call created the database; false if if_not_exists returned an existing one. |
default_catalog (required) | string | Name of the database's own catalog in SQL. |
default_connection_id (required) | string | ID of the connection behind the database's own catalog. Use it to load tables through the connection endpoints, or to attach this catalog to another database. |
default_schema (required) | string | Schema that unqualified table names resolve to. |
expires_at | string | When the database expires. |
forked_from | ForkedFromInfo | |
id (required) | string | |
name | string |
Example response
{
"created": true,
"default_catalog": "string",
"default_connection_id": "string",
"default_schema": "string",
"expires_at": "2026-01-01T00:00:00Z",
"forked_from": {
"database_id": "dbidk9p34y6n3wd25rq4f5zr37e3p3",
"description": "string",
"forked_at": "2026-01-01T00:00:00Z",
"name": "string",
"snapshot_id": 0
},
"id": "string",
"name": "string"
}
Errors
| Status | Description |
|---|---|
400 | The source database cannot be forked |
404 | Source database not found |
409 | The source database changed during the fork. Retry the request. |
Get database lineage
/v1/databases/{database_id}/lineageShow where a database was forked from and what was forked from it.
ancestors lists the fork chain up to the original, nearest first. forks lists databases forked directly from this one, newest first; fork_count is the full total when the list is cut short. Deleted databases stay in the record with exists set to false. A database with no forks returns empty lists and itself as root_id.
Path parameters
| Name | Type | Description |
|---|---|---|
database_id (required) | string | Database ID |
Query parameters
| Name | Type | Description |
|---|---|---|
forks_limit | integer | Number of direct forks to list, 1 to 100. Defaults to 25. |
Response 200 — Database lineage
| Name | Type | Description |
|---|---|---|
ancestors (required) | LineageAncestorInfo[] | Databases this one descends from, nearest parent first. Deleted ones stay in the list with exists: false. Empty when this is not a fork. |
ancestors_truncated (required) | boolean | True when ancestors stops before reaching root_id. |
database_id (required) | string | The database this lineage describes. |
fork_count (required) | integer | Total number of databases forked directly from this one. |
forks (required) | LineageForkInfo[] | Databases forked directly from this one, newest first, including deleted ones. Limited by forks_limit. |
root_id (required) | string | The original database at the top of the fork chain. Equal to database_id when this database is not a fork. |
Fields of ancestors
| Name | Type | Description |
|---|---|---|
ancestors[].database_id (required) | string | |
ancestors[].description | string | Why that fork was taken, if given. |
ancestors[].exists (required) | boolean | False if the database has been deleted. |
ancestors[].forked_at | string | When the next database down the chain was forked from this one. |
ancestors[].name | string | The database's current name, or its name at fork time if deleted. |
ancestors[].snapshot_id | integer | Point in time of this database's data that the next database down the chain copied. |
Fields of forks
| Name | Type | Description |
|---|---|---|
forks[].database_id (required) | string | |
forks[].description | string | Why the fork was taken, if given. |
forks[].exists (required) | boolean | False if the fork has been deleted. |
forks[].forked_at | string | When the fork was taken. |
forks[].name | string | The fork's name. Absent once the fork is deleted. |
forks[].snapshot_id | integer | Point in time of this database's data that the fork copied. |
Example response
{
"ancestors": [
{
"database_id": "string",
"description": "string",
"exists": true,
"forked_at": "2026-01-01T00:00:00Z",
"name": "string",
"snapshot_id": 0
}
],
"ancestors_truncated": true,
"database_id": "string",
"fork_count": 0,
"forks": [
{
"database_id": "string",
"description": "string",
"exists": true,
"forked_at": "2026-01-01T00:00:00Z",
"name": "string",
"snapshot_id": 0
}
],
"root_id": "string"
}
Errors
| Status | Description |
|---|---|
404 | Database not found |
Add schema to database default catalog
/v1/databases/{database_id}/schemasAdd a schema, and optionally its tables, to the database's default catalog. Names are stored in lowercase.
Path parameters
| Name | Type | Description |
|---|---|---|
database_id (required) | string | Database ID |
Request body
| Name | Type | Description |
|---|---|---|
name (required) | string | |
tables | AddManagedTableDecl[] | Tables to create in the schema. You can also add tables later. |
Fields of tables
| Name | Type | Description |
|---|---|---|
tables[].constant_per_key | string[] | Columns that always hold the same value for rows with the same key. Makes keyed loads faster, but if it is not true, keyed loads silently duplicate rows. |
tables[].key | string[] | Columns that identify a row. Required for delete, update and upsert loads unless the load request gives its own key. |
tables[].layout | TableLayout | How a table's data files are written. Set when the table is created and fixed after that. - analytical (default): data pages sized for scans. - point_lookup: small data pages, so fetching rows by ID is cheap, as vector search results do. Scans of the table read more pages. |
tables[].name (required) | string | |
tables[].partition_by | TablePartitionKey[] | Columns to partition the table by, in order. Cannot be changed later. |
tables[].partition_by[].column (required) | string | Column the key reads. |
tables[].partition_by[].transform (required) | string | How the key is derived from the column: identity (the value itself), year, month, day or hour. |
tables[].sorted_by | TableSortKey[] | Columns to sort the table by, in order. Cannot be changed later, and a sorted table cannot be indexed. |
tables[].sorted_by[].column (required) | string | Column to sort by. |
tables[].sorted_by[].direction | string | asc (default) or desc. Null in a response when it was not set. |
tables[].sorted_by[].nulls | string | Where nulls go: first or last. Defaults to last for asc and first for desc; null in a response when it was not set. |
Example request
{
"name": "sales",
"tables": [
{
"constant_per_key": [
"event_date"
],
"key": [
"order_id"
],
"layout": "analytical",
"name": "orders"
}
]
}
Response 201 — Schema added
| Name | Type | Description |
|---|---|---|
connection_id (required) | string | ID of the connection that holds the schema. For a database, this is its default_connection_id. |
schema (required) | string | |
tables (required) | string[] |
Example response
{
"connection_id": "string",
"schema": "string",
"tables": [
"string"
]
}
Errors
| Status | Description |
|---|---|
400 | Invalid identifier |
404 | Database not found |
409 | Schema already exists |
Add table to database default catalog
/v1/databases/{database_id}/schemas/{schema}/tablesAdd an empty table to a schema in the database's default catalog. Names are stored in lowercase. You do not have to declare tables first: a load creates the table if it is missing.
Path parameters
| Name | Type | Description |
|---|---|---|
database_id (required) | string | Database ID |
schema (required) | string | Schema name |
Request body
| Name | Type | Description |
|---|---|---|
constant_per_key | string[] | Columns that always hold the same value for rows with the same key. Makes keyed loads faster, but if it is not true, keyed loads silently duplicate rows. |
key | string[] | Columns that identify a row. Required for delete, update and upsert loads unless the load request gives its own key. |
layout | TableLayout | How a table's data files are written. Set when the table is created and fixed after that. - analytical (default): data pages sized for scans. - point_lookup: small data pages, so fetching rows by ID is cheap, as vector search results do. Scans of the table read more pages. |
name (required) | string | |
partition_by | TablePartitionKey[] | Columns to partition the table by, in order. Cannot be changed later. |
sorted_by | TableSortKey[] | Columns to sort the table by, in order. Cannot be changed later, and a sorted table cannot be indexed. |
Fields of partition_by
| Name | Type | Description |
|---|---|---|
partition_by[].column (required) | string | Column the key reads. |
partition_by[].transform (required) | string | How the key is derived from the column: identity (the value itself), year, month, day or hour. |
Fields of sorted_by
| Name | Type | Description |
|---|---|---|
sorted_by[].column (required) | string | Column to sort by. |
sorted_by[].direction | string | asc (default) or desc. Null in a response when it was not set. |
sorted_by[].nulls | string | Where nulls go: first or last. Defaults to last for asc and first for desc; null in a response when it was not set. |
Example request
{
"constant_per_key": [
"event_date"
],
"key": [
"order_id"
],
"layout": "analytical",
"name": "orders",
"partition_by": [
{
"column": "created_at",
"transform": "day"
}
],
"sorted_by": [
{
"column": "created_at",
"direction": "asc",
"nulls": "last"
}
]
}
Response 201 — Table added
| Name | Type | Description |
|---|---|---|
connection_id (required) | string | |
schema (required) | string | |
table (required) | string |
Example response
{
"connection_id": "string",
"schema": "string",
"table": "string"
}
Errors
| Status | Description |
|---|---|
400 | Invalid identifier |
404 | Database or schema not found |
409 | Table already exists |
Declare which columns are constant per key
/v1/databases/{database_id}/schemas/{schema}/tables/{table}/constant-per-keySet which columns never change for a given key. Keyed loads (delete, update, upsert) use this to search fewer files. You can change it at any time; it applies from the next load. Send an empty array to clear it.
Only declare columns that really are constant per key. If they are not, a keyed load can leave duplicate rows.
Path parameters
| Name | Type | Description |
|---|---|---|
database_id (required) | string | Database ID |
schema (required) | string | Schema name |
table (required) | string | Table name |
Request body
| Name | Type | Description |
|---|---|---|
constant_per_key | string[] | Columns that always hold the same value for rows with the same key. Replaces the current list; send [] to clear it. If it is not true, keyed loads silently duplicate rows. |
Example request
{
"constant_per_key": [
"event_date"
]
}
Response 200 — The table's declaration as it now stands
| Name | Type | Description |
|---|---|---|
connection_id (required) | string | ID of the connection that holds the table. For a database, this is its default_connection_id. |
constant_per_key (required) | string[] | Columns now set as constant per key. Empty means none. |
schema (required) | string | Schema name, in lowercase. |
table (required) | string | Table name, in lowercase. |
Example response
{
"connection_id": "string",
"constant_per_key": [
"string"
],
"schema": "string",
"table": "string"
}
Errors
| Status | Description |
|---|---|
400 | An invalid column name, or a table with no key |
404 | Database, schema or table not found |
409 | The setting changed at the same time. Retry. |
Load database table from inline data, upload, or query result
/v1/databases/{database_id}/schemas/{schema}/tables/{table}/loadsLoad data into a table in the database's default catalog. Give exactly one source: data (inline CSV, up to 2 MiB), upload_id (a CSV, JSON or Parquet file from POST /v1/uploads) or result_id (a saved query result). The table and its schema are created if they do not exist. mode sets how the rows apply.
Set async to run an upload or inline load as a background job; a result_id load always runs inline. If maintenance is running on the table, the load waits up to 60 seconds before it starts. If another write holds the table, you get 409 with RESOURCE_LOCKED and a Retry-After header.
Path parameters
| Name | Type | Description |
|---|---|---|
database_id (required) | string | Database ID |
schema (required) | string | Schema name |
table (required) | string | Table name |
Request body
| Name | Type | Description |
|---|---|---|
async | boolean | Run the load in the background and return a job ID to poll. Default: false |
async_after_ms | integer | With async: true, wait up to this many milliseconds for the load before falling back to a job ID. Must be between 1000 and 30000. Min: 1000 |
columns | object | Column types for inline data, by column name. Must list every CSV column; omit to detect types from the data. Each value is a type name such as BIGINT or DECIMAL(10,2), or an object such as {"type": "DECIMAL", "precision": 10, "scale": 2}. Types: VARCHAR, TEXT, STRING, CHAR, BOOLEAN, TINYINT, SMALLINT, INTEGER, BIGINT, UTINYINT, USMALLINT, UINTEGER, UBIGINT, REAL, FLOAT, DOUBLE, DECIMAL, NUMERIC, DATE, TIME, TIMESTAMP, TIMESTAMPTZ, BINARY, BLOB, UUID, JSON. |
data | string | CSV text with a header row, up to 2 MiB. Larger data fails with 413 (INLINE_DATA_TOO_LARGE); upload it and use upload_id instead. |
format | string | File format of the upload: csv, json (one object per line) or parquet. Defaults to detection from the upload's content type, then its contents. Inline data accepts only csv; not allowed with result_id. |
idempotency_key | string | Your own key, such as a UUID, that makes a load of inline data safe to retry: a retry with the same key returns the first result and loads nothing. Up to 255 characters. Reusing a key for different data returns 409 IDEMPOTENCY_KEY_CONFLICT; a retry while the first attempt still runs returns a different 409, so wait and retry. |
key | string[] | Key columns for delete, update and upsert, overriding the table's key. Use the same key on every load of a table. |
mode (required) | string | How to apply the data. The first load into a table must be replace. - replace: the data becomes the table's contents. - append: adds the rows. They must include every existing column (use null for missing values); new columns are added. - delete: removes rows whose key matches a row in the data. - update: replaces rows whose key matches; other rows in the data are ignored. - upsert: like update, but inserts rows whose key does not match. delete, update and upsert need a key, from the table or from key. |
result_id | string | ID of a saved query result. The rows are copied, so the table keeps them after the result expires. |
upload_id | string | ID of a finalized upload. Two loads cannot use the same upload at once; the second gets 409. |
Example request
{
"mode": "replace",
"data": "order_id,customer_id,amount\n1001,42,1999\n1002,7,4550\n",
"format": "csv",
"columns": {
"order_id": "BIGINT",
"customer_id": "BIGINT",
"amount": {
"type": "DECIMAL",
"precision": 10,
"scale": 2
}
}
}
Response 200 — Table loaded
| Name | Type | Description |
|---|---|---|
arrow_schema_json (required) | string | The table's schema, as a JSON string. |
connection_id (required) | string | ID of the connection that holds the table. |
row_count (required) | integer | Total rows in the table after the load. |
schema_name (required) | string | Schema of the table. |
table_name (required) | string | Table that was loaded. |
Example response
{
"arrow_schema_json": "string",
"connection_id": "string",
"row_count": 0,
"schema_name": "string",
"table_name": "string"
}
Response 202 — The load is running in the background. Poll the returned job.
| Name | Type | Description |
|---|---|---|
id (required) | string | Job ID. |
status (required) | JobStatus | Status of a background job. succeeded, partially_succeeded and failed are final; keep polling while it is pending or running. - pending: queued, or waiting to retry. - running: in progress. - succeeded: finished; all its work succeeded. - partially_succeeded: finished with a result, but some of its work failed (for example, some databases in a bulk creation). See error_message. - failed: failed and will not be retried. See error_message. |
status_url (required) | string | Path to poll for the job's status. |
Example response
{
"id": "string",
"status": "pending",
"status_url": "string"
}
Errors
| Status | Description |
|---|---|
400 | Invalid request, such as a bad mode, not exactly one data source, data that cannot be parsed, or a result that failed to compute |
404 | Database, upload, or result not found, or the table was deleted |
409 | Conflict: the upload was already used or is in use, the result is not ready, or the data changes a column's type in a way that cannot be widened. The table is unchanged. With RESOURCE_LOCKED, another write holds the table; retry after the Retry-After delay. |
413 | Inline data is over 2 MiB (INLINE_DATA_TOO_LARGE). Upload the file and load it by upload_id. |
503 | The catalog is busy (CATALOG_BUSY). The load may already have written its data, so check the table or use an idempotency key before you retry after the Retry-After delay. |