# File Import / Export

Import and export contacts and companies via CSV

## Upload a CSV file

 - [POST /leads/api/file-imports/upload-csv](https://api.getsales.io/bundled/file-import-export/uploadcsv.md): Uploads a CSV file and returns a preview with auto-detected column mappings. This is the first step of a two-step import flow:

1. Upload — call this endpoint with the file and import type.
   The response includes csv_headers (columns found in the file),
   csv_preview (first 10 rows), and matches (auto-detected
   column mappings).

2. Import — call import-leads or import-companies with the
   confirmed column mapping to start background processing.


Max file size is 15 MB. The CSV is parsed with auto-detected delimiters (comma, semicolon, or pipe).

## Import contacts from uploaded file

 - [POST /leads/api/file-imports/{uuid}/import-leads](https://api.getsales.io/bundled/file-import-export/importleadsfromfile.md): Starts background import of contacts from a previously uploaded CSV. Pass the confirmed column mapping in the columns field — keys are field names, values are 0-indexed column numbers from the CSV.

The uploaded file must have type csv_leads. At least one of linkedin_id, work_email, or personal_email must be mapped.

Processing happens asynchronously in batches of 1,000 rows. The returned object has status: in_progress — poll by UUID or use webhooks to track completion.

## Import companies from uploaded file

 - [POST /leads/api/file-imports/{uuid}/import-companies](https://api.getsales.io/bundled/file-import-export/importcompaniesfromfile.md): Starts background import of companies from a previously uploaded CSV. The uploaded file must have type csv_accounts. At least one of linkedin_id or name must be mapped.

Processing happens asynchronously in batches of 1,000 rows.

## Export contacts to CSV

 - [POST /leads/api/file-exports/leads](https://api.getsales.io/bundled/file-import-export/exportleads.md): Starts an asynchronous CSV export of contacts matching the given filter. The export runs in the background in batches of 1,000 rows.

When complete, use the download endpoint with the file name from the export result to download the CSV file.

The filter uses the same structure as the mass action filter — you can export all contacts, a specific list, contacts matching a search query, or a hand-picked set of UUIDs.

## Export companies to CSV

 - [POST /leads/api/file-exports/companies](https://api.getsales.io/bundled/file-import-export/exportcompanies.md): Starts an asynchronous CSV export of companies matching the given filter. Works the same as the contact export — runs in background batches, use download to retrieve the file when done.

## Download an exported file

 - [POST /leads/api/file-exports/download](https://api.getsales.io/bundled/file-import-export/downloadexport.md): Downloads a completed CSV export file. Pass the file_name from the export result. The response is a binary CSV stream.

The export must have status: done and a non-null result.files array before you can download.

