Bulk Table Operations

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

This endpoint enables bulk operations on a given table. For now, we only allow bulk inserting.

An example bulk request looks like this:

// POST https://tutorial-ng7s8c.xata.sh/db/tutorial:main/tables/users/bulk
 
{
  "records": [
    {
      "email": "laurence@example.com",
      "full_name": "Laurence Fishburne",
      "team": "rec_c8hng2h26un90p8sr7k0"
    },
    {
      "email": "hugo@example.com",
      "full_name": "Hugo Weaving",
      "team": "rec_c8hng2h26un90p8sr7k0"
    },
    {
      "email": "joe@example.com",
      "full_name": "Joe Pantoliano",
      "team": "rec_c8hng2h26un90p8sr7k0"
    }
  ]
}

For more details, see the this section from the tutorial.

Expected parameters

NameDescriptionInRequiredSchema
db_branch_name

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

path✅string
table_name

The Table name

path✅string
columns

Column filters

query-array

Bulk Insert Records

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

Bulk insert records

Request Body Type Definition

type BulkInsertTableRecords = {
    records: 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 BulkInsertTableRecords = {
    recordIDs: string[];
} | {
    records: Record[];
};
 
/**
 * 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;