---
title: "Export leads based on a search query"
method: POST
path: "/export/lead/"
tags: ["exports"]
---

# Export leads based on a search query

`POST /export/lead/`

You will receive a link to the generated file via email once the export is done.

The exported file is GZIP compressed to make your download and our upload faster. The `content-encoding` HTTP header will be set to `gzip` and the `content-type` HTTP header will be set to `text/csv` for CSV exports or `application/json` for JSON exports.

Parameters:
  - `s_query/results_limit/sort` (optional) - The [Advanced Filtering API](https://developer.close.com/api/resources/advanced-filtering) parameters used to narrow the exported results down. By default, all leads are exported.
  - `format` - Format of the exported file. The choices are: `csv`, `json`. JSON is recommended for raw backups or data migrations.
  - `type` - Type of the export.
    - `leads` - For CSV exports, it results in one row per lead. For JSON exports, this is the recommended type and is a superset of the other two types.
    - `contacts` - For CSV exports, it results in one row per contact.
    - `lead_opps` - For CSV exports, it results in one row per opportunity.
  - `date_format` (optional) - Controls the format of date objects. Note: this only works with the `csv` format.
    - `original` (default) - A date format that includes microseconds and timezone information.
        - Date: `[YYYY]-[MM]-[DD]`
        - Date w/ time: `[YYYY]-[MM]-[DD] [hh]:[mm]:[ss.sssss]±[hh]:[mm]`
    - `iso8601` (recommended) - An [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) compatible date representation that does not include microseconds.
        - Date: `[YYYY]-[MM]-[DD]`
        - Date w/ time: `[YYYY]-[MM]-[DD]T[hh]:[mm]:[ss]±[hh]:[mm]`
    - `excel` - An Excel compatible date format. Dates are always in UTC, do not include timezone information or microseconds, and use a 12 hour clock with an AM or PM designation.
        - Date: `[YYYY]-[MM]-[DD]`
        - Date w/ time: `[YYYY]-[MM]-[DD] [hh]:[mm]:[ss] [AM|PM]`
  - `fields` (optional) - By default we return all the data fields in each export type. If you only need specific fields exported, you can explicitly list them in `fields` to get smaller exports.
  - `include_activities` (optional) - Activities aren't included in any exports by default. If you want all your Activities exported as well, pass `"include_activities": true`. Note: this only works for `leads` type with `json` format.
  - `include_smart_fields` (optional) - Smart Fields aren't included in any exports by default. If you want all of them exported as well, pass `"include_smart_fields": true`. Note: this only works for `leads` type with `json` format or any type formatted as `csv`. Smart fields are calculated fields, like number of emails on a lead.
  - `send_done_email` - Set to `false` if you don't want to get a confirmation email after the bulk action is done.

## Response `200`

Successful response

- Export
  - `created_by` string, nullable, required
  - `date_created` string, date-time, required
  - `date_format` 'original' | 'iso8601' | 'excel', required
  - `date_updated` string, date-time, required
  - `download_url` string, nullable, required
  - `fields` string[], required
  - `format` 'csv' | 'json', required
  - `id` string, required
  - `limit` integer, nullable
  - `n_docs` integer, nullable, required
  - `n_docs_processed` integer, required
  - `organization_id` string, required
  - `params` JSONDict
  - `query` string, nullable
  - `results_limit` integer, nullable
  - `s_query` JSONDict
  - `send_done_email` boolean, required
  - `sort` JSONDict[], nullable
  - `status` 'created' | 'started' | 'in_progress' | 'done' | 'error', required
  - `type` 'leads' | 'contacts' | 'lead_opps' | 'opps' | 'opportunities', required
  - `updated_by` string, nullable, required

## Other responses

- `400` — Bad request
- `401` — Unauthorized
- `404` — Not found

---

[API](https://skmtc.dev/close/apis/close-api.md) · [All operations](https://skmtc.dev/close/apis/close-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/close/close-api/revisions/59969f4fe8c1/schema)
