Single Table Column

https://{your-workspace-slug}.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}.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.

Possible Responses
Status CodeDescriptionExample Response/Type Definition
200OK
type GetColumn = {
    name: string;
    type: "bool" | "int" | "float" | "string" | "text" | "email" | "multiple" | "link" | "object" | "datetime";
    link?: {
        table: string;
    };
    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 GetColumn = {
    id?: string;
    message: string;
};
401Authentication Error
{
  "message": "invalid API key"
}
404Example response
type GetColumn = {
    id?: string;
    message: string;
};
5XXUnexpected Error

Deletes a Column

DELETE  https://{your-workspace-slug}.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.

Possible Responses
Status CodeDescriptionExample Response/Type Definition
200Returns the migration ID.
{
  "migrationID": "mig_c7m19ilcefoebpqj12p0"
}
400Bad Request
type DeleteColumn = {
    id?: string;
    message: string;
};
401Authentication Error
{
  "message": "invalid API key"
}
404Example response
type DeleteColumn = {
    id?: string;
    message: string;
};
5XXUnexpected Error

Updates a Column

PATCH  https://{your-workspace-slug}.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
/**
 * @example {"name":"newName","description":"Sample new description"}
 */
type UpdateColumn = {
    /*
     * @minLength 1
     */
    name: string;
};
Possible Responses
Status CodeDescriptionExample Response/Type Definition
200Returns the migration ID.
{
  "migrationID": "mig_c7m19ilcefoebpqj12p0"
}
400Bad Request
type UpdateColumn = {
    id?: string;
    message: string;
};
401Authentication Error
{
  "message": "invalid API key"
}
404Example response
type UpdateColumn = {
    id?: string;
    message: string;
};
5XXUnexpected Error