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_nameThe DBBranchName matches the pattern `{db_name}:{branch_name}`. pathstring
table_nameThe Table namepathstring
column_nameThe Column namepathstring

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. To refer to sub-objects, the column name can contain dots. For example address.country.

Status CodeDescriptionExample Response/Type Definition
200OK
type GetColumn = {
    name: string;
    type: "bool" | "int" | "float" | "string" | "text" | "email" | "multiple" | "link" | "object" | "datetime";
    link?: ColumnLink;
    notNull?: boolean;
    defaultValue?: string;
    unique?: boolean;
    columns?: Column[];
};

type ColumnLink = {
    table: string;
};

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

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. To refer to sub-objects, the column name can contain dots. For example address.country.

Request Body Example
{
  "name": "newName",
  "description": "Sample new description"
}

Request Body Type Definition

1
2
3
4
5
6
7
8
9
/**
 * @example {"name":"newName","description":"Sample new description"}
 */
type UpdateColumn = {
    /*
     * @minLength 1
     */
    name: string;
};
Status CodeDescriptionExample Response/Type Definition
200Schema migration response with ID and migration status.
type UpdateColumn = {
    /*
     * @minLength 1
     */
    migrationID: string;
    parentMigrationID: string;
    status: MigrationStatus;
};

type MigrationStatus = "completed" | "pending" | "failed";
400Bad Request
type UpdateColumn = {
    id?: string;
    message: string;
};
401Authentication Error
{
  "message": "invalid API key"
}
404Example response
type UpdateColumn = {
    id?: string;
    message: string;
};
5XXUnexpected Error

Delete Column

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

Deletes the specified column. To refer to sub-objects, the column name can contain dots. For example address.country.

Status CodeDescriptionExample Response/Type Definition
200Schema migration response with ID and migration status.
type DeleteColumn = {
    /*
     * @minLength 1
     */
    migrationID: string;
    parentMigrationID: string;
    status: MigrationStatus;
};

type MigrationStatus = "completed" | "pending" | "failed";
400Bad Request
type DeleteColumn = {
    id?: string;
    message: string;
};
401Authentication Error
{
  "message": "invalid API key"
}
404Example response
type DeleteColumn = {
    id?: string;
    message: string;
};
5XXUnexpected Error