Table Columns

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

This endpoint allows working with a table's columns.

Expected parameters

NameDescriptionInRequiredSchema
db_branch_name

Failed to compile MDX

pathstring
table_name

The Table name

pathstring

List Table Columns

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

Retrieves the list of table columns and their definition. This endpoint returns the column list with object columns being reported with their full dot-separated path (flattened).

Responses

{
    "columns": [
        {
            "name": "name",
            "type": "string"
        },
        {
            "name": "email",
            "type": "email"
        },
        {
            "name": "settings.plan",
            "type": "string"
        },
        {
            "name": "settings.dark",
            "type": "bool"
        }
    ]
}

Create New Column

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

Adds a new column to the table. The body of the request should contain the column definition.

Request Body Type Definition

/**
 * @example {"name":"columnName","type":"string"}
 */
type AddTableColumn = 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 AddTableColumn = {
    /**
     * @minLength 1
     */
    migrationID: string;
    parentMigrationID: string;
    status: MigrationStatus;
};
 
type MigrationStatus = "completed" | "pending" | "failed";