# File Operations

Upload and import CSV files into your CRM, and export contacts or companies to CSV. File imports run asynchronously — upload first, then trigger import-leads or import-companies. Exports return a queued job; use `/file-exports/download` once the job completes.


## Upload a CSV file

 - [POST /leads/api/file-imports/upload-csv](https://api.grinfi.io/openapi/file-operations/uploadcsvfile.md): Upload a CSV file to be imported as contacts or companies. Returns a file-import record with a UUID. Pass that UUID to import-leads or import-companies to actually create the records.

Note: the only validated type value at the time of writing is csv_leads. Companies CSV may require a different mechanism — check with support.

## Import contacts from uploaded file

 - [POST /leads/api/file-imports/{uuid}/import-leads](https://api.grinfi.io/openapi/file-operations/importleadsfromfile.md): Trigger contact import from a previously uploaded CSV file. Required field: columns — an ordered list of column-mapping objects describing how to map CSV columns to contact fields.

## Import companies from uploaded file

 - [POST /leads/api/file-imports/{uuid}/import-companies](https://api.grinfi.io/openapi/file-operations/importcompaniesfromfile.md): Trigger company import from a previously uploaded CSV file.

## Export contacts to CSV

 - [POST /leads/api/file-exports/leads](https://api.grinfi.io/openapi/file-operations/exportleadstocsv.md): Queue a CSV export of contacts matching the filter. Returns a file-export record with status queued. Once the job completes, use download to retrieve the file.

## Export companies to CSV

 - [POST /leads/api/file-exports/companies](https://api.grinfi.io/openapi/file-operations/exportcompaniestocsv.md): Queue a CSV export of companies matching the filter.

## Download an exported file

 - [POST /leads/api/file-exports/download](https://api.grinfi.io/openapi/file-operations/downloadexportfile.md): Retrieve a previously generated export file by name. The file_name is returned as part of the export record once the job completes.

