> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://reference.flatfile.com/api-reference/records/insert/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://reference.flatfile.com/_mcp/server. # Insert records POST https://api.x.flatfile.com/v1/sheets/{sheetId}/records Content-Type: application/json Adds records to a workbook sheet Reference: https://reference.flatfile.com/api-reference/records/insert ## Authentication - `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer `, where token is your auth token. ## Request ### Path parameters - `sheetId` (string, required) — ID of sheet ### Body (application/json) This endpoint expects a list of map from string to CellValue. - `list of map from string to CellValue` ## Response ### 200 - `data` (RecordsResponseData, required) ## Errors ### 400 Bad Request Error - `errors` (list of Error, required) ### 404 Not Found Error - `errors` (list of Error, required) ## Types ### CellValue - `valid` (boolean, optional) - `messages` (list of ValidationMessage, optional) - `value` (CellValueUnion, optional) - `layer` (string, optional) - `updatedAt` (datetime, optional) - `metadata` (map from string to any, optional, deprecated) — Deprecated, use record level metadata instead. ### RecordsResponseData - `success` (boolean, required) - `commitId` (string, optional) — Commit ID - `counts` (RecordCounts, optional) - `records` (list of RecordWithLinks, optional) — List of Record objects, including links to related rows - `versionId` (string, optional, deprecated) — Deprecated, use `commitId` instead. ### Error - `message` (string, required) - `key` (string, optional) ### ValidationMessage Record data validation messages - `field` (string, optional) - `type` (enum, optional) - Allowed values: `error`, `warn`, `info` - `source` (enum, optional) - Allowed values: `required-constraint`, `unique-constraint`, `custom-logic`, `unlinked`, `invalid-option`, `is-artifact` - `message` (string, optional) - `path` (string, optional) — This JSONPath is based on the root of mapped cell object. ### CellValueUnion ### RecordCounts - `total` (integer, required) - `valid` (integer, required) - `error` (integer, required) - `byField` (map from string to FieldRecordCounts, optional) — Counts for valid, error, and total records grouped by field key - `errorsByField` (map from string to integer, optional, deprecated) ### RecordWithLinks A single row of data in a Sheet, including links to related rows - `id` (string, required) — Record ID - `values` (map from string to CellValueWithLinks, required) — A single row of data in a Sheet, including links to related rows - `valid` (boolean, optional) - `messages` (list of ValidationMessage, optional) - `metadata` (map from string to any, optional) - `config` (RecordConfig, optional) — Configuration of a record or specific fields in the record ### FieldRecordCounts - `total` (integer, required) - `valid` (integer, required) - `error` (integer, required) - `empty` (integer, required) ### CellValueWithLinks - `layer` (string, optional) - `links` (list of Record, optional) — List of Record objects - `messages` (list of ValidationMessage, optional) - `updatedAt` (datetime, optional) - `valid` (boolean, optional) - `value` (CellValueUnion, optional) - `metadata` (map from string to any, optional, deprecated) — Deprecated, use record level metadata instead. ### RecordConfig Configuration of a record or specific fields in the record - `readonly` (boolean, optional) - `fields` (map from string to CellConfig, optional) - `markedForDeletion` (boolean, optional) ### Record A single row of data in a Sheet - `id` (string, required) — Record ID - `values` (map from string to CellValue, required) — A single row of data in a Sheet - `commitId` (string, optional) — Commit ID - `config` (RecordConfig, optional) — Configuration of a record or specific fields in the record - `metadata` (map from string to any, optional) - `valid` (boolean, optional) — Auto-generated value based on whether the record contains a field with an error message. Cannot be set via the API. - `messages` (list of ValidationMessage, optional, deprecated) — This record level `messages` property is deprecated and no longer stored or used. Use the `messages` property on the individual cell values instead. This property will be removed in a future release. - `versionId` (string, optional, deprecated) — Deprecated, use `commitId` instead. ### CellConfig CellConfig - `readonly` (boolean, optional) ## Examples **Request** ```json [ { "firstName": { "valid": true, "messages": [], "value": "John" }, "lastName": { "valid": true, "messages": [], "value": "Smith" }, "email": { "valid": true, "messages": [], "value": "john.smith@example.com" } } ] ``` **Response** ```json { "data": { "success": true, "commitId": "us_vr_YOUR_ID", "counts": { "total": 1000, "valid": 1000, "error": 0 }, "records": [ { "id": "us_rc_YOUR_ID", "values": { "firstName": { "messages": [], "updatedAt": "2023-11-20T16:59:40.286Z", "valid": true, "value": "John" }, "lastName": { "messages": [], "updatedAt": "2023-11-20T16:59:40.286Z", "valid": true, "value": "Smith" }, "email": { "messages": [], "updatedAt": "2023-11-20T16:59:40.286Z", "valid": true, "value": "john.smith@example.com" } }, "valid": true, "metadata": {}, "config": {} } ], "versionId": "us_vr_YOUR_ID" } } ``` **SDK Code** ```python Example0 import requests url = "https://api.x.flatfile.com/v1/sheets/us_sh_YOUR_ID/records" payload = [ { "firstName": { "valid": True, "messages": [], "value": "John" }, "lastName": { "valid": True, "messages": [], "value": "Smith" }, "email": { "valid": True, "messages": [], "value": "john.smith@example.com" } } ] headers = { "X-Disable-Hooks": "true", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```typescript Example0 import { FlatfileClient } from "@flatfile/api"; const client = new FlatfileClient({ token: "YOUR_TOKEN" }); await client.records.insert("us_sh_YOUR_ID", [{ "firstName": { value: "John", messages: [], valid: true }, "lastName": { value: "Smith", messages: [], valid: true }, "email": { value: "john.smith@example.com", messages: [], valid: true } }]); ``` ```go Example0 package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.x.flatfile.com/v1/sheets/us_sh_YOUR_ID/records" payload := strings.NewReader("[\n {\n \"firstName\": {\n \"valid\": true,\n \"messages\": [],\n \"value\": \"John\"\n },\n \"lastName\": {\n \"valid\": true,\n \"messages\": [],\n \"value\": \"Smith\"\n },\n \"email\": {\n \"valid\": true,\n \"messages\": [],\n \"value\": \"john.smith@example.com\"\n }\n }\n]") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-Disable-Hooks", "true") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby Example0 require 'uri' require 'net/http' url = URI("https://api.x.flatfile.com/v1/sheets/us_sh_YOUR_ID/records") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["X-Disable-Hooks"] = 'true' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "[\n {\n \"firstName\": {\n \"valid\": true,\n \"messages\": [],\n \"value\": \"John\"\n },\n \"lastName\": {\n \"valid\": true,\n \"messages\": [],\n \"value\": \"Smith\"\n },\n \"email\": {\n \"valid\": true,\n \"messages\": [],\n \"value\": \"john.smith@example.com\"\n }\n }\n]" response = http.request(request) puts response.read_body ``` ```java Example0 import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.x.flatfile.com/v1/sheets/us_sh_YOUR_ID/records") .header("X-Disable-Hooks", "true") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("[\n {\n \"firstName\": {\n \"valid\": true,\n \"messages\": [],\n \"value\": \"John\"\n },\n \"lastName\": {\n \"valid\": true,\n \"messages\": [],\n \"value\": \"Smith\"\n },\n \"email\": {\n \"valid\": true,\n \"messages\": [],\n \"value\": \"john.smith@example.com\"\n }\n }\n]") .asString(); ``` ```php Example0 request('POST', 'https://api.x.flatfile.com/v1/sheets/us_sh_YOUR_ID/records', [ 'body' => '[ { "firstName": { "valid": true, "messages": [], "value": "John" }, "lastName": { "valid": true, "messages": [], "value": "Smith" }, "email": { "valid": true, "messages": [], "value": "john.smith@example.com" } } ]', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'X-Disable-Hooks' => 'true', ], ]); echo $response->getBody(); ``` ```csharp Example0 using RestSharp; var client = new RestClient("https://api.x.flatfile.com/v1/sheets/us_sh_YOUR_ID/records"); var request = new RestRequest(Method.POST); request.AddHeader("X-Disable-Hooks", "true"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "[\n {\n \"firstName\": {\n \"valid\": true,\n \"messages\": [],\n \"value\": \"John\"\n },\n \"lastName\": {\n \"valid\": true,\n \"messages\": [],\n \"value\": \"Smith\"\n },\n \"email\": {\n \"valid\": true,\n \"messages\": [],\n \"value\": \"john.smith@example.com\"\n }\n }\n]", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Example0 import Foundation let headers = [ "X-Disable-Hooks": "true", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ [ "firstName": [ "valid": true, "messages": [], "value": "John" ], "lastName": [ "valid": true, "messages": [], "value": "Smith" ], "email": [ "valid": true, "messages": [], "value": "john.smith@example.com" ] ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.x.flatfile.com/v1/sheets/us_sh_YOUR_ID/records")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```