import_data
Import CSV or JSON rows into one Directus collection, or map a flat file across multiple related collections at once, with dry-run and merge options.
Instructions
Import rows from a CSV or JSON file into one collection, or into several related collections at once using a flat multi-collection file. Subject to the Directus IMPORT_MAX_FILE_SIZE limit (50mb by default).
Single-collection: pass collection; the file is a plain array of rows.
Batch (Directus 12.2+): omit collection; the file MUST be a JSON array of { "collection": string, "items": object[] } entries, e.g.
[{"collection":"authors","items":[{"name":"Ann"}]},{"collection":"articles","items":[{"title":"Hi","author":1}]}]
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | Batch import only. 'add' inserts, 'merge' upserts. Default: add. | |
| confirm | No | Confirm a destructive import | |
| dry_run | No | Batch import only. Report the changes without writing. | |
| filename | No | Filename for the upload; its extension selects the parser (.csv or .json) | |
| file_data | No | Base64-encoded file contents (alternative to file_path) | |
| file_path | No | Path to a local .csv or .json file | |
| collection | No | Target collection. Omit for a multi-collection batch import, in which case the file must be an array of { collection, items } entries rather than a bare row array. | |
| dangerously_allow_delete | No | Batch import only. Permit deletion of rows absent from the file. Requires confirm. |