Table Schema
https://{your-workspace-slug}.{region}.xata.sh/db/db_branch_name/tables/table_name/schema
This endpoint enables reading or updating the schema of a given table.
Expected parameters
Name | Description | In | Required | Schema |
---|---|---|---|---|
db_branch_name | The DBBranchName matches the pattern | path | ✅ | string |
table_name | The Table name | path | ✅ | string |
Get Table Schema
GEThttps://{your-workspace-slug}.{region}.xata.sh/db/db_branch_name/tables/table_name/schema
Responses
type GetTableSchema = {
columns: Column[];
};
type Column = {
name: string;
type: "bool" | "int" | "float" | "string" | "text" | "email" | "multiple" | "link" | "object" | "datetime" | "vector" | "file[]" | "file" | "json";
link?: ColumnLink;
vector?: ColumnVector;
file?: ColumnFile;
["file[]"]?: ColumnFile;
notNull?: boolean;
defaultValue?: string;
unique?: boolean;
columns?: Column[];
};
type ColumnLink = {
table: string;
};
type ColumnVector = {
/**
* @maximum 10000
* @minimum 2
*/
dimension: number;
};
type ColumnFile = {
defaultPublicAccess?: boolean;
};
type GetTableSchema = {
id?: string;
message: string;
};
{
"message": "invalid API key"
}
type GetTableSchema = {
id?: string;
message: string;
};
type GetTableSchema = void;
type GetTableSchema = void;
Update Table Schema
PUThttps://{your-workspace-slug}.{region}.xata.sh/db/db_branch_name/tables/table_name/schema
Request Body Type Definition
type SetTableSchema = {
columns: Column[];
};
type Column = {
name: string;
type: "bool" | "int" | "float" | "string" | "text" | "email" | "multiple" | "link" | "object" | "datetime" | "vector" | "file[]" | "file" | "json";
link?: ColumnLink;
vector?: ColumnVector;
file?: ColumnFile;
["file[]"]?: ColumnFile;
notNull?: boolean;
defaultValue?: string;
unique?: boolean;
columns?: Column[];
};
type ColumnLink = {
table: string;
};
type ColumnVector = {
/**
* @maximum 10000
* @minimum 2
*/
dimension: number;
};
type ColumnFile = {
defaultPublicAccess?: boolean;
};
Responses
type SetTableSchema = {
/**
* @minLength 1
*/
migrationID: string;
parentMigrationID: string;
status: MigrationStatus;
};
type MigrationStatus = "completed" | "pending" | "failed";
type SetTableSchema = void;
type SetTableSchema = {
id?: string;
message: string;
};
{
"message": "invalid API key"
}
type SetTableSchema = {
id?: string;
message: string;
};
type SetTableSchema = {
id?: string;
message: string;
};
type SetTableSchema = void;
type SetTableSchema = void;