Query database using SQL
https://{your-workspace-slug}.{region}.xata.sh/db/db_branch_name/sql
This endpoint performs the SQL query across the entire database branch. Set your SQL query in the parameter query
.
Expected parameters
Name | Description | In | Required | Schema |
---|---|---|---|---|
db_branch_name | The DBBranchName matches the pattern | path | ✅ | string |
SQL Query
POSThttps://{your-workspace-slug}.{region}.xata.sh/db/db_branch_name/sql
Run an SQL query across the database branch.
Request Body Type Definition
/**
* @example {"statement":"select * from users;"}
*/
type SqlQuery = {
/**
* The SQL statement.
*
* @minLength 1
*/
statement: string;
/**
* The query parameter list.
*/
params?: any[] | null;
/**
* The consistency level for this request.
*
* @default strong
*/
consistency?: "strong" | "eventual";
};
Responses
type SqlQuery = {
records?: SQLRecord[];
warning?: string;
};
/**
* Xata Table SQL Record
*/
type SQLRecord = {
[key: string]: any;
};
type SqlQuery = {
records?: SQLRecord[];
warning?: string;
};
/**
* Xata Table SQL Record
*/
type SQLRecord = {
[key: string]: any;
};
type SqlQuery = {
id?: string;
message: string;
};
{
"message": "invalid API key"
}
type SqlQuery = {
id?: string;
message: string;
};
type SqlQuery = {
id?: string;
message: string;
};
type SqlQuery = void;
type SqlQuery = void;