{"title":"Load records and files","description":"Append JSON records, upload files, or upsert by primary key into Altertable, then verify the data with SQL using the CLI, SDKs, or HTTP API.","order":100,"askSuggestions":["Should I append, upload, or upsert my data?","Why is my appended record missing from the table?","How do I upsert rows from a CSV by primary key?"],"navigation":true,"routeId":"ingestDataHttpApi","body":{"code":"var Component=(()=>{var g=Object.create;var d=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var x=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),v=(r,e)=>{for(var t in e)d(r,t,{get:e[t],enumerable:!0})},h=(r,e,t,s)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let o of b(e))!k.call(r,o)&&o!==t&&d(r,o,{get:()=>e[o],enumerable:!(s=y(e,o))||s.enumerable});return r};var I=(r,e,t)=>(t=r!=null?g(w(r)):{},h(e||!r||!r.__esModule?d(t,\"default\",{value:r,enumerable:!0}):t,r)),S=r=>h(d({},\"__esModule\",{value:!0}),r);var u=x((T,p)=>{p.exports=_jsx_runtime});var D={};v(D,{default:()=>m,frontmatter:()=>A});var n=I(u()),A={title:\"Load records and files\",routeId:\"ingestDataHttpApi\",description:\"Append JSON records, upload files, or upsert by primary key into Altertable, then verify the data with SQL using the CLI, SDKs, or HTTP API.\",order:100,askSuggestions:[\"Should I append, upload, or upsert my data?\",\"Why is my appended record missing from the table?\",\"How do I upsert rows from a CSV by primary key?\"]};function f(r){let e={a:\"a\",code:\"code\",h1:\"h1\",h2:\"h2\",h3:\"h3\",li:\"li\",p:\"p\",pre:\"pre\",strong:\"strong\",table:\"table\",tbody:\"tbody\",td:\"td\",th:\"th\",thead:\"thead\",tr:\"tr\",ul:\"ul\",...r.components},{DocsCliPrerequisite:t,DocsDetails:s,DocsLakehouseIngestExamples:o,DocsPreviewDocument:c,DocsPreviewSection:i,DocsPrompt:l}=e;return t||a(\"DocsCliPrerequisite\",!0),s||a(\"DocsDetails\",!0),o||a(\"DocsLakehouseIngestExamples\",!0),c||a(\"DocsPreviewDocument\",!0),i||a(\"DocsPreviewSection\",!0),l||a(\"DocsPrompt\",!0),(0,n.jsxs)(c,{anchors:\"load-records-and-files set-up-with-your-agent steps 1-choose-an-ingest-mode 2-append-json-records 3-upload-files 4-upsert-by-primary-key verification troubleshooting\",children:[(0,n.jsxs)(i,{sectionId:\"load-records-and-files\",anchors:\"\",ancestors:\"\",index:\"0\",children:[(0,n.jsx)(e.h1,{id:\"load-records-and-files\",children:\"Load records and files\"}),`\n`,(0,n.jsxs)(e.p,{children:[\"Use append for new JSON records, upload for files, and upsert for rows that should update existing primary keys. You need a writable catalog and \",(0,n.jsx)(e.a,{href:\"/docs/administration/lakehouse-credentials\",children:\"lakehouse credentials\"}),\".\"]}),`\n`,(0,n.jsxs)(e.p,{children:[\"The steps below use the CLI. For application code, use the SDK or HTTP examples in step 2. Exact limits and request fields live in the \",(0,n.jsx)(e.a,{href:\"/docs/api-references/lakehouse\",children:\"HTTP API reference\"}),\".\"]}),`\n`]}),(0,n.jsxs)(i,{sectionId:\"set-up-with-your-agent\",anchors:\"\",ancestors:\"\",index:\"1\",children:[(0,n.jsx)(e.h2,{id:\"set-up-with-your-agent\",children:\"Set up with your agent\"}),`\n`,(0,n.jsx)(l,{children:(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:\"language-text\",children:`Help me load records or files into Altertable. Read https://altertable.ai/docs/lakehouse/ingest/http-api.md first.\n\nInspect the source format and any existing ingestion code. Confirm the destination environment, catalog, schema, and table. Choose append for new JSON records, upload for files, or upsert for updates with a stable primary key. Ask only for information you cannot inspect.\n\nUse the CLI for a one-off load or a supported SDK for application code. Keep lakehouse credentials in local or server-side secret configuration. Explain the chosen operation and obtain confirmation before writing data; do not overwrite an existing table.\n\nLoad a small representative sample, wait for insertion to finish, and query the destination. Compare the returned fields and values with the sample and inspect rejected or quarantined records. An accepted request is not sufficient verification. Summarize the result and show how to repeat the load.\n`})})}),`\n`,(0,n.jsx)(t,{}),`\n`]}),(0,n.jsxs)(i,{sectionId:\"steps\",anchors:\"\",ancestors:\"\",index:\"2\",children:[(0,n.jsx)(e.h2,{id:\"steps\",children:\"Steps\"}),`\n`]}),(0,n.jsxs)(i,{sectionId:\"1-choose-an-ingest-mode\",anchors:\"\",ancestors:\"steps\",index:\"3\",children:[(0,n.jsx)(e.h3,{id:\"1-choose-an-ingest-mode\",children:\"1. Choose an ingest mode\"}),`\n`,(0,n.jsxs)(e.table,{children:[(0,n.jsx)(e.thead,{children:(0,n.jsxs)(e.tr,{children:[(0,n.jsx)(e.th,{children:\"Operation\"}),(0,n.jsx)(e.th,{children:\"Use it for\"})]})}),(0,n.jsxs)(e.tbody,{children:[(0,n.jsxs)(e.tr,{children:[(0,n.jsx)(e.td,{children:\"Append\"}),(0,n.jsx)(e.td,{children:\"Add new JSON records, with automatic table creation and new columns\"})]}),(0,n.jsxs)(e.tr,{children:[(0,n.jsx)(e.td,{children:\"Upload\"}),(0,n.jsx)(e.td,{children:\"Create a table from a CSV, JSON, or Parquet file, or append file rows\"})]}),(0,n.jsxs)(e.tr,{children:[(0,n.jsx)(e.td,{children:\"Upsert\"}),(0,n.jsx)(e.td,{children:\"Update matching primary keys and insert new rows from a file\"})]})]})]}),`\n`,(0,n.jsxs)(e.p,{children:[\"Use \",(0,n.jsx)(e.a,{href:\"/docs/lakehouse/ingest/object-storage\",children:\"bucket synchronization\"}),\" for scheduled file imports from object storage.\"]}),`\n`]}),(0,n.jsxs)(i,{sectionId:\"2-append-json-records\",anchors:\"\",ancestors:\"steps\",index:\"4\",children:[(0,n.jsx)(e.h3,{id:\"2-append-json-records\",children:\"2. Append JSON records\"}),`\n`,(0,n.jsxs)(e.p,{children:[\"From the CLI, append a test record to a new table. Replace \",(0,n.jsx)(e.code,{children:\"my_catalog\"}),\" with your destination catalog:\"]}),`\n`,(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:\"language-altertable\",children:`altertable append '{\"event\":\"onboarding_test\",\"source\":\"cli\"}' --to my_catalog.main.events\n`})}),`\n`,(0,n.jsx)(e.p,{children:\"Append acknowledges accepted records before insertion finishes. Allow a few seconds, then query the table to verify that they arrived. An acknowledgement alone does not verify insertion.\"}),`\n`,(0,n.jsxs)(e.p,{children:[\"If a row fails insertion after retries, Altertable stores it in \",(0,n.jsx)(e.code,{children:\"altertable.main.quarantined_appends\"}),\". Inspect the error and original payload before correcting and resending it.\"]}),`\n`,(0,n.jsxs)(s,{title:\"Append from application code\",children:[(0,n.jsxs)(e.p,{children:[\"Use your \",(0,n.jsx)(e.a,{href:\"/docs/administration/lakehouse-credentials#verification\",children:\"lakehouse credentials\"}),\" to set \",(0,n.jsx)(e.code,{children:\"ALTERTABLE_USERNAME\"}),\" and \",(0,n.jsx)(e.code,{children:\"ALTERTABLE_PASSWORD\"}),\" before running cURL. Choose a \",(0,n.jsx)(e.a,{href:\"/docs/api-references/sdks#lakehouse-sdks\",children:\"published SDK\"}),\" before initializing a client:\"]}),(0,n.jsx)(o,{})]}),`\n`]}),(0,n.jsxs)(i,{sectionId:\"3-upload-files\",anchors:\"\",ancestors:\"steps\",index:\"5\",children:[(0,n.jsx)(e.h3,{id:\"3-upload-files\",children:\"3. Upload files\"}),`\n`,(0,n.jsx)(e.p,{children:\"To create a new table from a file:\"}),`\n`,(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:\"language-altertable\",children:`altertable upload users.csv --to my_catalog.main.users --mode create\n`})}),`\n`,(0,n.jsxs)(e.p,{children:[\"To add file rows to an existing table, use \",(0,n.jsx)(e.code,{children:\"--mode append\"}),\". Use \",(0,n.jsx)(e.code,{children:\"--mode overwrite\"}),\" only when you intend to replace the table with the uploaded data. See \",(0,n.jsx)(e.a,{href:\"/docs/api-references/lakehouse#post-upload\",children:\"upload behavior\"}),\" for supported formats and limits.\"]}),`\n`]}),(0,n.jsxs)(i,{sectionId:\"4-upsert-by-primary-key\",anchors:\"\",ancestors:\"steps\",index:\"6\",children:[(0,n.jsx)(e.h3,{id:\"4-upsert-by-primary-key\",children:\"4. Upsert by primary key\"}),`\n`,(0,n.jsxs)(e.p,{children:[\"If \",(0,n.jsx)(e.code,{children:\"users.csv\"}),\" contains a stable \",(0,n.jsx)(e.code,{children:\"id\"}),\" column, update matching rows and insert new ones with:\"]}),`\n`,(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:\"language-altertable\",children:`altertable upsert users.csv --to my_catalog.main.users --key id\n`})}),`\n`,(0,n.jsxs)(e.p,{children:[\"Check that the key is populated and identifies the rows you intend to update. See \",(0,n.jsx)(e.a,{href:\"/docs/api-references/lakehouse#post-upsert\",children:\"upsert behavior\"}),\" for HTTP requests and supported formats.\"]}),`\n`]}),(0,n.jsxs)(i,{sectionId:\"verification\",anchors:\"\",ancestors:\"\",index:\"7\",children:[(0,n.jsx)(e.h2,{id:\"verification\",children:\"Verification\"}),`\n`,(0,n.jsx)(e.p,{children:\"After uploading or upserting the file, inspect the destination:\"}),`\n`,(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:\"language-altertable\",children:`altertable query \"SELECT * FROM my_catalog.main.users LIMIT 10\"\n`})}),`\n`,(0,n.jsx)(e.p,{children:\"Compare the returned values with the file, including any rows you expected to update. For append, query its destination table after processing has completed.\"}),`\n`]}),(0,n.jsxs)(i,{sectionId:\"troubleshooting\",anchors:\"\",ancestors:\"\",index:\"8\",children:[(0,n.jsx)(e.h2,{id:\"troubleshooting\",children:\"Troubleshooting\"}),`\n`,(0,n.jsxs)(e.ul,{children:[`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:\"Unauthorized request:\"}),\" check the destination environment and lakehouse credentials.\"]}),`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:\"A new append row is missing:\"}),\" wait for processing, then inspect \",(0,n.jsx)(e.code,{children:\"altertable.main.quarantined_appends\"}),\" for failures.\"]}),`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:\"The file exceeds the request limit:\"}),\" consult the \",(0,n.jsx)(e.a,{href:\"/docs/api-references/lakehouse#post-upload\",children:\"endpoint limits\"}),\" and split the data when needed.\"]}),`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:\"Upsert changes unexpected rows:\"}),\" check the primary key column and its values before sending another request.\"]}),`\n`]})]})]})}function m(r={}){let{wrapper:e}=r.components||{};return e?(0,n.jsx)(e,{...r,children:(0,n.jsx)(f,{...r})}):f(r)}function a(r,e){throw new Error(\"Expected \"+(e?\"component\":\"object\")+\" `\"+r+\"` to be defined: you likely forgot to import, pass, or provide it.\")}return S(D);})();\n;return Component;"},"_id":"docs/lakehouse/ingest/http-api.mdx","_raw":{"sourceFilePath":"docs/lakehouse/ingest/http-api.mdx","sourceFileName":"http-api.mdx","sourceFileDir":"docs/lakehouse/ingest","contentType":"mdx","flattenedPath":"docs/lakehouse/ingest/http-api"},"type":"Docs","path":"/lakehouse/ingest/http-api","level":3,"parent":"lakehouse/ingest"}