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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
// 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
Name | Description | In | Required | Schema |
---|---|---|---|---|
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
POSThttps://{your-workspace-slug}.{region}.xata.sh/db/db_branch_name/tables/table_name/bulk
Bulk insert records
Request Body Type Definition
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
type BulkInsertTableRecords = { records: DataInputRecord[]; }; /** * Xata input record */ type DataInputRecord = { [key: string]: RecordID | string | boolean | number | string[] | number[] | DateTime | ObjectValue | InputFileArray | InputFileEntry | 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 InputFileEntry = { 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 1 * @pattern [0-9a-zA-Z!\-_\.\*'\(\)]+ */ type FileName = string; /** * Media type * * @maxLength 255 * @minLength 3 * @pattern ^\w+/[-+.\w]+$ */ type MediaType = string;
Status Code | Description | Example Response/Type Definition |
---|---|---|
200 | OK |
|
400 | Response with multiple errors of the bulk execution |
|
401 | Authentication Error |
|
404 | Example response |
|
422 | Example response |
|
5XX | Unexpected Error |