Prompted edits
Prompted edits let users change imported data from the review step with a prompt. They can clean values, normalize formats, add rows, update rows, or remove rows before the final import is delivered to your app.
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", edit }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 Usage Limits
Managed prompted edits are not available on the free plan. Paid plans include usage under ExpressCSV fair-use limits.
How Prompted Edits Run
Managed prompted edits generate JavaScript for the requested operation, execute it in a sandbox, and 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 the proposed changes. The React SDK keeps your handler stable across renders and delegates edit requests through the importer iframe.
Your handler receives:
| Property | Description |
|---|---|
sessionId | The current import session ID. |
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 changes only the fields included in values; remove deletes rows by rowId; add creates new rows.
Use rowIndex only to interpret prompts that refer to the row's current display position. For example, a prompt like "update the first 10 rows" should select rows where rowIndex is less than 10, then return update changes using each selected row's rowId. Do not use rowIndex as the stable identifier in the returned changes, because sorting, filtering, or row insertion can change where a row appears.