Export leads to a destination
export_leadsPush leads into a connected destination: 'close' (CRM — uses the account's saved field mapping), 'ghl' (GoHighLevel sub-account), 'google_sheets' (new spreadsheet, or pass spreadsheet_id for one LeadMarina created before), or a file — 'csv' | 'xlsx' | 'json' (a 7-day download link in the answer; not emailed). Exports EITHER one search's leads (pass search_id) or the whole library (set all=true). Either can be narrowed with the same filter rows as query_leads — with search_id they apply within that search. Leads go out best-ranked first (rank, then id), the order of the leads table. LIMITS PER CALL, which differ by destination because CRMs take one API call per lead: csv/xlsx 50,000 · json 25,000 · google_sheets 5,000 · close/ghl 1,000. For a big library going to a CRM, export csv and import the file instead. If more leads match than the limit, the response sets truncated=true and returns next_cursor — relay that to the user, the export was partial; to send the next batch, call export_leads again with the SAME destination, search_id or all, and filters, plus cursor=next_cursor — for google_sheets also spreadsheet_id from this response, or the next batch goes into a new spreadsheet (up to 50,000 leads a spreadsheet; past that the response has no spreadsheet_id and the next batch starts a new one, or export csv). A next_cursor with not_sent means the destination's time limit cut this batch short: the same call with that cursor sends the rest. An all=true export spread over several calls reads the library live, so a lead that a search running between calls finds again can be skipped or sent twice; for one consistent copy, export the library in a single csv/xlsx (up to 50,000 leads) or json (up to 25,000) call while no search is running. Close, GoHighLevel and a LeadMarina-created sheet passed as spreadsheet_id UPDATE previously exported leads in place (matched by Google CID), never touching the user's own CRM notes/columns — unless update_existing is false (then Close skips leads it already has, and a sheet appends every row); a file or a new sheet is a fresh copy every time — so do not repeat a call that succeeded. Or pass campaign_id instead of search_id to export one advanced search's leads.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| all | No | Export the whole library instead of one search. | |
| cursor | No | Continue an export: the next_cursor a previous export_leads call returned. Pass it with the same search_id/all and filters. | |
| filters | No | Optional query_leads-style filter rows: within the search when search_id is given, across the library with all=true. | |
| search_id | No | Export this search's leads. | |
| campaign_id | No | Only this advanced search's leads (an id from run_advanced_search or list_advanced_searches). Not with search_id. | |
| destination | Yes | Where the leads go. | |
| sheet_title | No | google_sheets without spreadsheet_id: the new spreadsheet's title (up to 100 characters). | |
| spreadsheet_id | No | google_sheets only: add to this existing LeadMarina-created sheet instead of a new one. | |
| update_existing | No | close, and google_sheets with spreadsheet_id: true (default) refreshes leads already there. false: Close sends only leads it hasn't had yet (the rest are skipped, not duplicated); a sheet appends every lead as a new row. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | No | File exports only: the file name. | |
| note | No | ||
| limit | No | The per-call limit that applied, when truncated. | |
| outcome | Yes | Human-readable result, e.g. added/updated counts. | |
| warning | No | Present when the per-call limit or this call's time limit left leads unsent: what happened and how to send them. Leads the destination refused are not covered here — outcome counts them as failed. | |
| exported | Yes | Leads sent to the destination. | |
| not_sent | No | Leads of this batch the destination's time limit did not reach. | |
| truncated | No | True when more leads matched than this destination's limit — the export was PARTIAL. | |
| next_cursor | No | Present when the per-call limit or this call's time limit left matching leads unsent: pass it as cursor, with the same destination (for google_sheets, plus the spreadsheet_id this response returned), search_id/all and filters, to send them. It does not offer again a lead the destination refused (counted as failed in outcome). | |
| data_sources | No | Where the sources, licences and notices are for emails and owner names that may come from open datasets and public records. Pass it on with any of this data you share. | |
| download_url | No | File exports only: 7-day download link. | |
| spreadsheet_id | No | Google Sheets only: pass it as spreadsheet_id to send the next batch into this same spreadsheet. Absent once the spreadsheet holds 50,000 leads. | |
| spreadsheet_url | No | Google Sheets only: the spreadsheet the leads went to (it does not expire). |