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
Name | Description | In | Required | Schema |
---|---|---|---|---|
db_branch_name | The DBBranchName matches the pattern | path | ✅ | string |
table_name | The Table name | path | ✅ | string |
List Table Columns
GEThttps://{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"
}
]
}
type GetTableColumns = {
id?: string;
message: string;
};
{
"message": "invalid API key"
}
type GetTableColumns = {
id?: string;
message: string;
};
type GetTableColumns = void;
type GetTableColumns = void;
Create New Column
POSThttps://{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";
type AddTableColumn = {
id?: string;
message: string;
};
{
"message": "invalid API key"
}
type AddTableColumn = {
id?: string;
message: string;
};
type AddTableColumn = void;
type AddTableColumn = void;