Prompted edits
Prompted edits let users change imported data from the review step with a prompt. They can:
- Clean values and normalize formats
- Add, update, or remove rows before delivery
You choose how prompted edits work:
- Use managed prompted edits with
{ type: "managed" }when you want to run our standard prompt interpretation, code generation, and sandbox execution. - Use custom prompted edits with
{ type: "custom", promptedEditHandler }when you want to run your own prompt interpretation and code generation logic.
Prompted edits are disabled by default.
Managed Prompted Edits
For the hosted ExpressCSV AI path, pass { type: "managed" } to useExpressCSV().
Managed prompted edits are only available on paid plans. Usage is included under ExpressCSV fair-use limits.
How Prompted Edits Run
Managed prompted edits:
- Generate JavaScript for the requested operation
- Execute it in a sandbox
- Apply the result as proposed grid changes
The managed path supports two execution scopes:
| Scope | Use for | Notes |
|---|---|---|
row | Updating or deleting existing rows, or adding rows based on existing row data | Runs once per row and can read the current row plus rowIndex and totalRows. |
dataset | Adding new rows without reading existing rows | Runs once and can only add rows. |
If the prompt is ambiguous, impossible, or needs external data the importer does not have, the edit can return a no-op message instead of changing data.
Custom Prompted Edits
Pass type: "custom" when your own service should interpret prompts and return proposed changes. This avoids ExpressCSV's managed generation and sandbox path.
Your handler receives:
| Property | Description |
|---|---|
sessionId | ID for the current import run. Send it to your backend to correlate AI requests with the import being edited. |
prompt | The user's natural language request. |
fields | Editable field keys, display names, types, and sample values. |
rows | Current rows in display order, including rowId, rowIndex, and raw values for every editable field. |
totalRows | Total number of rows being edited. |
Return type: "no-op" when the request should not change data:
Return type: "success" with rowId-based changes when you have changes:
update: only the fields invalueschange on the row identified byrowIdremove: deletes rows byrowIdadd: creates new rows fromvalues
Use rowIndex only to interpret prompts about display position (for example "update the first 10 rows"):
- Select rows where
rowIndexis less than the cutoff, then returnupdatechanges using each row'srowId - Do not use
rowIndexas the stable identifier in returned changes; sorting, filtering, or row insertion can change display order