Table Schema

https://{your-workspace-slug}.xata.sh/db/{db_branch_name}/tables/{table_name}/schema/

This endpoint enables reading or updating the schema of a given table.

Expected Parameters
NameDescriptionInRequiredSchema
db_branch_nameThe DBBranchName matches the pattern `{db_name}:{branch_name}`. pathstring
table_nameThe Table namepathstring

Get Table Schema

GET  https://{your-workspace-slug}.xata.sh/db/{db_branch_name}/tables/{table_name}/schema/
Possible Responses
Status CodeDescriptionExample Response/Type Definition
200OK
type GetTableSchema = {
    columns: Column[];
};

type Column = {
    name: string;
    type: "bool" | "int" | "float" | "string" | "text" | "email" | "multiple" | "link" | "object" | "datetime";
    link?: {
        table: string;
    };
    columns?: Column[];
};
400Bad Request
type GetTableSchema = {
    id?: string;
    message: string;
};
401Authentication Error
{
  "message": "invalid API key"
}
404Example response
type GetTableSchema = {
    id?: string;
    message: string;
};
5XXUnexpected Error

Update Table Schema

PUT  https://{your-workspace-slug}.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";
    link?: {
        table: string;
    };
    columns?: Column[];
};
Possible Responses
Status CodeDescriptionExample Response/Type Definition
204No Content
400Bad Request
type SetTableSchema = {
    id?: string;
    message: string;
};
401Authentication Error
{
  "message": "invalid API key"
}
404Example response
type SetTableSchema = {
    id?: string;
    message: string;
};
409Example response
type SetTableSchema = {
    id?: string;
    message: string;
};
5XXUnexpected Error