Database Table by Name
https://{your-workspace-slug}.{region}.xata.sh/db/db_branch_name/tables/table_name
This endpoint provides a way to mutate a specific table on a database.
Expected parameters
Name | Description | In | Required | Schema |
---|---|---|---|---|
db_branch_name | The DBBranchName matches the pattern | path | ✅ | string |
table_name | The Table name | path | ✅ | string |
Create Table
PUThttps://{your-workspace-slug}.{region}.xata.sh/db/db_branch_name/tables/table_name
Creates a new table with the given name. Returns 422 if a table with the same name already exists.
Responses
{
"branchName": "mydb_main",
"tableName": "mytable",
"status": "completed"
}
type CreateTable = void;
type CreateTable = {
id?: string;
message: string;
};
{
"message": "invalid API key"
}
type CreateTable = {
id?: string;
message: string;
};
type CreateTable = {
id?: string;
message: string;
};
type CreateTable = void;
type CreateTable = void;
Delete Table
DELETEhttps://{your-workspace-slug}.{region}.xata.sh/db/db_branch_name/tables/table_name
Deletes the table with the given name.
Responses
type DeleteTable = {
status: MigrationStatus;
};
type MigrationStatus = "completed" | "pending" | "failed";
type DeleteTable = {
id?: string;
message: string;
};
{
"message": "invalid API key"
}
type DeleteTable = void;
type DeleteTable = void;
type DeleteTable = void;
Update Table
PATCHhttps://{your-workspace-slug}.{region}.xata.sh/db/db_branch_name/tables/table_name
Update table. Currently there is only one update operation supported: renaming the table by providing a new name.
In the example below, we rename a table from “users” to “people”:
// PATCH /db/test:main/tables/users
{
"name": "people"
}
Request Body Type Definition
type UpdateTable = {
/**
* @minLength 1
*/
name: string;
};
Responses
type UpdateTable = {
/**
* @minLength 1
*/
migrationID: string;
parentMigrationID: string;
status: MigrationStatus;
};
type MigrationStatus = "completed" | "pending" | "failed";
type UpdateTable = {
id?: string;
message: string;
};
{
"message": "invalid API key"
}
type UpdateTable = {
id?: string;
message: string;
};
type UpdateTable = {
id?: string;
message: string;
};
type UpdateTable = void;
type UpdateTable = void;