How to Import Excel or CSV Into Your App Through Its API Without Duplicates
Importing a spreadsheet through an API fails in predictable ways: time limits cut the job, retries create duplicates and rate limits reject bursts. The fix is a durable import that tracks every row, gives each one an idempotency key and slows down when your API asks it to.
5 min read / Updated:
Import your first file with QaaliaShort answer: treat the import as a job, not a loop. Map the columns once, store every row with its own status, send each row with an idempotency key that never changes between retries, pause and lower concurrency on 429 or 503, and never blindly retry a timeout. Then the job can stop at any point and resume without creating a single duplicate. This guide covers the method and how an AI agent runs it in Qaalia; for the broader picture see AI agents for bulk operations, and for the design behind it, durable bulk tasks.
Why do spreadsheet imports create duplicates?
- The job dies midway: a serverless function or a script hits its time limit after a few hundred rows, and nobody knows exactly where it stopped.
- The retry starts from the top: without per-row state, re-running the job sends rows that already succeeded.
- Timeouts are ambiguous: a request that timed out may have been saved. Retrying it can apply it twice.
- Rate limits: your API rejects a burst with
429, and a naive loop either gives up or hammers it. - The model as the loop: asking a chat model to emit one tool call per row is slow, expensive and loses track over hundreds of rows.
What makes an API import safe to retry?
| Technique | What it prevents | What your API needs |
|---|---|---|
| Idempotency key per row | The same row applied twice after a retry | Accept an Idempotency-Key header (sent by the Qaalia Connector) or enforce a natural unique key such as an email |
| Per-row status stored outside the process | Lost progress when the job is cut | Nothing |
| Adaptive pacing | Failing on bursts | Return 429 or 503 |
| No automatic retry on timeout | A write applied twice | Respond quickly; queue slow work in the background |
| Clear conflict errors | Counting existing records as failures | Return 409 or a message like "already exists" |
| Mapping check before the first call | Hundreds of rows sent with a wrong column | Mark required fields in your schema |
How do you import a spreadsheet through your API with Qaalia?
- Connect your app as a system: paste its OpenAPI spec or address (or connect it with the Qaalia Connector if it runs on your machine) and set the permission of the operation that creates records.
- Attach the file: XLSX, XLS or CSV in Qaalia Chat, or upload it from your own app with the attachments API. Spreadsheets can weigh up to 4 MB, CSV up to 6 MB.
- Ask in plain words: for example "Enroll the students from this file in their courses". The agent reads the columns and maps them to the operation's fields, combining columns when needed (such as first and last name).
- Let the mapping be checked: values are converted to the types your operation expects, and if half or more of the rows are missing a required field, the import stops before touching your system so the mapping can be fixed.
- Approve once, if required: when the operation needs approval, you approve the whole batch once, not every row.
- Follow the progress: watch it live in Qaalia Chat, or poll the task from your app through the API, and read the final summary with the rows that need attention.
How does Qaalia avoid duplicates and lost progress?
The model does not send the rows one by one. It declares the operation and the column mapping, and Qaalia builds the rows from the file and executes them itself, up to 100,000 rows per batch. Every row is stored with its own status and its own idempotency key, so the batch survives interruptions and continues across several runs of the worker; a row that was already done is never sent again. When the call goes through the Qaalia Connector, your local API also receives an Idempotency-Key header on every request. A row whose call timed out is not retried automatically, because your system may have saved it: it is reported as an error to review.
How does it handle rate limits?
Concurrency starts at 4 calls at a time and rises to 8 while your API answers well. A timeout halves it. On a rate-limit response (429, 503 or a "rate limit exceeded" message) those rows go back to the queue untouched, the batch pauses (2, 4, 8 seconds and so on up to 60; operations of systems you already had also honor Retry-After) and then continues one call at a time. The pacing is saved, so it survives between runs. A slow API simply takes longer; the import still finishes.
What does the result look like?
At the end, the agent gets a summary instead of thousands of results: total rows, how many succeeded, how many failed and up to 25 failed rows with their data and error. Rows rejected because the record already exists (a 409 or a "duplicate" or "already exists" message) are counted separately as already existing, not as failures. From your app, the long-task endpoint returns the status, progress and events, and you can cancel the task. In terms of usage, each real call to your system counts as one execution, and retrying the same operation does not count again.
FAQ
Which Excel or CSV columns can be mapped or combined?
Any column of the header row, by its name (case and accents do not matter) or by its position. A template can combine several, such as "{First name} {Last name}" or "Course {course}". For Excel you can pick the sheet; by default the first one is used.
How many rows can one import have?
Up to 100,000 rows per batch. The agent can process a file in row ranges.
Does Qaalia send my API an Idempotency-Key header for each row?
When your app is connected through the Qaalia Connector, yes: every call to your local API carries one. Systems that Qaalia calls over the internet do not receive the header, but Qaalia still never re-sends a row it already completed, so give your API a natural unique key as well.
What should my API return so the import works well?
A quick 2xx on success, 409 or an "already exists" message for duplicates, 429 or 503 when it needs the client to slow down, and clear error messages the agent can report.
Can I start the import from my own app instead of Qaalia Chat?
Yes. Upload the file with the attachments API, send the request to the agent endpoint with your API key and poll the long task for its progress.
Related resources
AI Agents for Bulk Operations: Import Hundreds of Records Without Errors
How to let an AI agent process hundreds or thousands of records from a spreadsheet into your system without timeouts, duplicates or lost progress.
MCP Tool Approval: Allow, Require Approval or Block Each Tool
How MCP tool approval works: allow, require approval or block per tool, what the reviewer sees, what happens on timeout and how changed tools are handled.
How to Connect an AI Agent to Your API (Safely) in 2026
Step-by-step guide to let an AI agent call your own API: describe operations, set permissions, keep credentials safe, handle retries and test it, with or without code.

