Table Data

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

This endpoint enables mutating data into a given database table. To query data, please see the query endpoint. For a tutorial on using the Records API, see the Record API documentation.

Expected parameters

NameDescriptionInRequiredSchema
db_branch_name

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

pathstring
table_name

The Table name

pathstring
columns

Column filters

query-array

Insert Record

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

Insert a new Record into the Table

Request Body Type Definition

type InsertRecord = DataInputRecord;
 
/**
 * Xata input record
 */
type DataInputRecord = {
    [key: string]: RecordID | string | boolean | number | string[] | number[] | DateTime | ObjectValue | InputFileArray | InputFile | null;
};
 
/**
 * @maxLength 255
 * @minLength 1
 * @pattern [a-zA-Z0-9_-~:]+
 */
type RecordID = string;
 
/**
 * @format date-time
 */
type DateTime = string;
 
/**
 * Object column value
 */
type ObjectValue = {
    [key: string]: string | boolean | number | string[] | number[] | DateTime | ObjectValue;
};
 
/**
 * Array of file entries
 * 
 * @maxItems 50
 */
type InputFileArray = InputFileEntry[];
 
/**
 * Object representing a file
 */
type InputFile = {
    name: FileName;
    mediaType?: MediaType;
    /**
     * Base64 encoded content
     *
     * @maxLength 20971520
     */
    base64Content?: string;
    /**
     * Enable public access to the file
     */
    enablePublicUrl?: boolean;
    /**
     * Time to live for signed URLs
     */
    signedUrlTimeout?: number;
};
 
/**
 * Object representing a file in an array
 */
type InputFileEntry = {
    id?: FileItemID;
    name?: FileName;
    mediaType?: MediaType;
    /**
     * Base64 encoded content
     *
     * @maxLength 20971520
     */
    base64Content?: string;
    /**
     * Enable public access to the file
     */
    enablePublicUrl?: boolean;
    /**
     * Time to live for signed URLs
     */
    signedUrlTimeout?: number;
};
 
/**
 * File name
 * 
 * @maxLength 1024
 * @minLength 0
 * @pattern [0-9a-zA-Z!\-_\.\*'\(\)]*
 */
type FileName = string;
 
/**
 * Media type
 * 
 * @maxLength 255
 * @minLength 3
 * @pattern ^\w+/[-+.\w]+$
 */
type MediaType = string;
 
/**
 * Unique file identifier
 * 
 * @maxLength 255
 * @minLength 1
 * @pattern [a-zA-Z0-9_-~:]+
 */
type FileItemID = string;

Responses

type InsertRecord = Record | {
    id: string;
    xata: {
        version: number;
        createdAt: string;
        updatedAt: string;
    };
};
 
/**
 * Xata Table Record Metadata
 */
type Record = RecordMeta & {
    [key: string]: any;
};
 
/**
 * Xata Table Record Metadata
 */
type RecordMeta = {
    id: RecordID;
    xata: {
        /**
         * The record's version. Can be used for optimistic concurrency control.
         */
        version: number;
        /**
         * The time when the record was created.
         */
        createdAt?: string;
        /**
         * The time when the record was last updated.
         */
        updatedAt?: string;
        /**
         * The record's table name. APIs that return records from multiple tables will set this field accordingly.
         */
        table?: string;
        /**
         * Highlights of the record. This is used by the search APIs to indicate which fields and parts of the fields have matched the search.
         */
        highlight?: {
            [key: string]: string[] | {
                [key: string]: any;
            };
        };
        /**
         * The record's relevancy score. This is returned by the search APIs.
         */
        score?: number;
        /**
         * Encoding/Decoding errors
         */
        warnings?: string[];
    };
};
 
/**
 * @maxLength 255
 * @minLength 1
 * @pattern [a-zA-Z0-9_-~:]+
 */
type RecordID = string;