Single Table Column

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

This endpoint allows working with a single column from a given table.

Expected parameters

NameDescriptionInRequiredSchema
db_branch_name

The DBBranchName matches the pattern {db_name}:{branch_name}.

pathstring
table_name

The Table name

pathstring
column_name

The Column name

pathstring

Get Column Information

GET
https://{your-workspace-slug}.{region}.xata.sh/db/db_branch_name/tables/table_name/columns/column_name

Get the definition of a single column.

Responses

type GetColumn = {
    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 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[];
};

Update Column

PATCH
https://{your-workspace-slug}.{region}.xata.sh/db/db_branch_name/tables/table_name/columns/column_name

Update column with partial data. Can be used for renaming the column by providing a new "name" field.

Request Body Type Definition

/**
 * @example {"name":"newName","description":"Sample new description"}
 */
type UpdateColumn = {
    /**
     * @minLength 1
     */
    name: string;
};

Responses

type UpdateColumn = {
    /**
     * @minLength 1
     */
    migrationID: string;
    parentMigrationID: string;
    status: MigrationStatus;
};
 
type MigrationStatus = "completed" | "pending" | "failed";

Delete Column

DELETE
https://{your-workspace-slug}.{region}.xata.sh/db/db_branch_name/tables/table_name/columns/column_name

Deletes the specified column.

Responses

type DeleteColumn = {
    /**
     * @minLength 1
     */
    migrationID: string;
    parentMigrationID: string;
    status: MigrationStatus;
};
 
type MigrationStatus = "completed" | "pending" | "failed";