curl -X POST "https://app.lance.so/api/v1/operations/export" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-o "leads-export.csv" \
-d '{
"selection": {
"mode": "manual",
"includedIds": [
"550e8400-e29b-41d4-a716-446655440000",
"6ba7b810-9dad-11d1-80b4-00c04fd430c8"
]
},
"exportFields": ["name", "emails", "phones", "jobTitle", "companyName"]
}'
curl -X POST "https://app.lance.so/api/v1/operations/export" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-o "leads-export.csv" \
-d '{
"selection": {
"mode": "bulk",
"startIndex": 0,
"targetCount": 100,
"excludedIds": ["excluded-id-1"],
"filters": {
"contact": {
"location": {
"any": {
"include": ["San Francisco, CA"]
}
}
}
}
}
}'
const response = await fetch("/api/v1/operations/export", {
method: "POST",
headers: {
Authorization: "Bearer <token>",
"Content-Type": "application/json",
},
body: JSON.stringify({
selection: {
mode: "manual",
includedIds: [
"550e8400-e29b-41d4-a716-446655440000",
"6ba7b810-9dad-11d1-80b4-00c04fd430c8",
],
},
exportFields: ["name", "emails", "phones", "jobTitle", "companyName"],
}),
});
// Get the export count from headers
const exportCount = response.headers.get("X-Export-Count");
// Download the CSV
const blob = await response.blob();
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "leads-export.csv";
a.click();
interface BulkSelectionPayload {
mode: "manual" | "bulk";
startIndex?: number;
targetCount?: number;
excludedIds?: string[];
includedIds?: string[];
filters?: PeopleSearchFilters;
}
interface ExportRequest {
selection: BulkSelectionPayload;
exportFields?: string[];
}
const response = await fetch("/api/v1/operations/export", {
method: "POST",
headers: {
Authorization: "Bearer <token>",
"Content-Type": "application/json",
},
body: JSON.stringify({
selection: {
mode: "manual",
includedIds: [
"550e8400-e29b-41d4-a716-446655440000",
"6ba7b810-9dad-11d1-80b4-00c04fd430c8",
],
},
exportFields: ["name", "emails", "phones", "jobTitle", "companyName"],
} satisfies ExportRequest),
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.error);
}
const exportCount = parseInt(response.headers.get("X-Export-Count") || "0", 10);
const blob = await response.blob();
Name,Email(s),Phone(s),Job Title,Company Name
John Smith,john@example.com,+1-555-0100,Software Engineer,Acme Corp
Jane Doe,"jane@example.com, jane.doe@personal.com",+1-555-0101,Product Manager,Tech Inc
{
"error": "No data to export"
}
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid selection mode"
}
}
{
"error": {
"code": "INTERNAL_ERROR",
"message": "No valid export fields specified"
}
}
Data Operations
Export to CSV
Export selected leads/prospects to a downloadable CSV file
POST
/
api
/
v1
/
operations
/
export
curl -X POST "https://app.lance.so/api/v1/operations/export" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-o "leads-export.csv" \
-d '{
"selection": {
"mode": "manual",
"includedIds": [
"550e8400-e29b-41d4-a716-446655440000",
"6ba7b810-9dad-11d1-80b4-00c04fd430c8"
]
},
"exportFields": ["name", "emails", "phones", "jobTitle", "companyName"]
}'
curl -X POST "https://app.lance.so/api/v1/operations/export" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-o "leads-export.csv" \
-d '{
"selection": {
"mode": "bulk",
"startIndex": 0,
"targetCount": 100,
"excludedIds": ["excluded-id-1"],
"filters": {
"contact": {
"location": {
"any": {
"include": ["San Francisco, CA"]
}
}
}
}
}
}'
const response = await fetch("/api/v1/operations/export", {
method: "POST",
headers: {
Authorization: "Bearer <token>",
"Content-Type": "application/json",
},
body: JSON.stringify({
selection: {
mode: "manual",
includedIds: [
"550e8400-e29b-41d4-a716-446655440000",
"6ba7b810-9dad-11d1-80b4-00c04fd430c8",
],
},
exportFields: ["name", "emails", "phones", "jobTitle", "companyName"],
}),
});
// Get the export count from headers
const exportCount = response.headers.get("X-Export-Count");
// Download the CSV
const blob = await response.blob();
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "leads-export.csv";
a.click();
interface BulkSelectionPayload {
mode: "manual" | "bulk";
startIndex?: number;
targetCount?: number;
excludedIds?: string[];
includedIds?: string[];
filters?: PeopleSearchFilters;
}
interface ExportRequest {
selection: BulkSelectionPayload;
exportFields?: string[];
}
const response = await fetch("/api/v1/operations/export", {
method: "POST",
headers: {
Authorization: "Bearer <token>",
"Content-Type": "application/json",
},
body: JSON.stringify({
selection: {
mode: "manual",
includedIds: [
"550e8400-e29b-41d4-a716-446655440000",
"6ba7b810-9dad-11d1-80b4-00c04fd430c8",
],
},
exportFields: ["name", "emails", "phones", "jobTitle", "companyName"],
} satisfies ExportRequest),
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.error);
}
const exportCount = parseInt(response.headers.get("X-Export-Count") || "0", 10);
const blob = await response.blob();
Name,Email(s),Phone(s),Job Title,Company Name
John Smith,john@example.com,+1-555-0100,Software Engineer,Acme Corp
Jane Doe,"jane@example.com, jane.doe@personal.com",+1-555-0101,Product Manager,Tech Inc
{
"error": "No data to export"
}
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid selection mode"
}
}
{
"error": {
"code": "INTERNAL_ERROR",
"message": "No valid export fields specified"
}
}
This endpoint exports selected leads to a CSV file. It supports both manual selection (specific IDs) and bulk selection (range-based with filters).
How It Works
- Resolve Selection: The selection payload is resolved to actual lead IDs based on the mode
- Field Selection: Determines which fields to include based on
exportFieldsor uses defaults - Generate CSV: Builds CSV content with headers and data rows
- File Download: Returns the CSV as a file attachment
The response is a binary CSV file download, not JSON. The
X-Export-Count
header contains the number of exported records.Request
Body Parameters
object
required
Selection criteria for which leads to export. Supports two modes: manual (explicit IDs) and bulk (range-based).
Show Selection Object
Show Selection Object
string
required
Selection mode type.Allowed values:
manual- Select specific leads by IDbulk- Select a range of leads based on filters and position
integer
Starting position for bulk selection (0-based). Only used in
bulk mode.Constraints: Must be >= 0integer
Number of leads to select starting from
startIndex. Only used in bulk mode.Constraints:- Minimum: 1
- Maximum: 1000
string[]
Array of lead IDs to exclude from bulk selection.Used to remove specific leads from the bulk range.
string[]
Array of lead IDs to explicitly include.
- In
manualmode: The complete list of leads to export - In
bulkmode: Additional leads to include outside the bulk range
object
Search filters to reproduce the exact search context. Required for
bulk mode to resolve the selection.See the People Search Filters section for the full filter schema.string[]
Array of field IDs to include in the export. If not specified, uses default
fields. Default fields:
name, emails, phones, linkedinUrl, city,
country, jobTitle, companyName See Available Export
Fields for all options.Response
The response is a CSV file download with the following headers:header
text/csv; charset=utf-8header
attachment; filename="lance-prospects-{YYYY - MM - DD}.csv" The filename
includes the current date.header
The number of records exported (as a string).
CSV Format
The CSV file contains:- Header row: Column labels based on selected fields
- Data rows: One row per lead with values for each selected field
- Values containing commas, quotes, or newlines are properly escaped
- UTF-8 encoding
Available Export Fields
Fields are organized by category. Use theid value in the exportFields array.
Contact Information
| Field ID | Label | Description |
|---|---|---|
name | Name | Full name (first + last) |
emails | Email(s) | All email addresses, comma-separated |
phones | Phone(s) | All phone numbers, comma-separated |
linkedinUrl | LinkedIn URL | Person’s LinkedIn profile URL |
Location Information
| Field ID | Label | Description |
|---|---|---|
city | City | Person’s city |
postalCode | Postal Code | Person’s postal code |
country | Country | Person’s country |
Professional Information
| Field ID | Label | Description |
|---|---|---|
jobTitle | Job Title | Current job title |
seniority | Seniority | Seniority level |
departments | Departments | Departments, comma-separated |
functions | Functions | Job functions, comma-separated |
industry | Industry (Person) | Person’s industry |
skills | Skills | Skills, comma-separated |
languages | Languages | Languages spoken, comma-separated |
Company Information
| Field ID | Label | Description |
|---|---|---|
companyName | Company Name | Current company name |
companyLegalName | Company Legal Name | Company’s legal registered name |
companyWebsite | Company Website | Company website URL |
companyLinkedin | Company LinkedIn | Company LinkedIn page URL |
companyPhone | Company Phone(s) | Company phone numbers |
companyCity | Company City (HQ) | Company headquarters city |
companyPostalCode | Company Postal Code (HQ) | Company headquarters postal code |
companyCountry | Company Country (HQ) | Company headquarters country |
companyIndustry | Company Industry | Company’s industry |
companyHeadcount | Company Headcount | Employee count range |
companyRevenue | Company Revenue | Revenue range |
companyFoundedYear | Company Founded Year | Year company was founded |
companySummary | Company Summary | AI-generated company summary |
curl -X POST "https://app.lance.so/api/v1/operations/export" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-o "leads-export.csv" \
-d '{
"selection": {
"mode": "manual",
"includedIds": [
"550e8400-e29b-41d4-a716-446655440000",
"6ba7b810-9dad-11d1-80b4-00c04fd430c8"
]
},
"exportFields": ["name", "emails", "phones", "jobTitle", "companyName"]
}'
curl -X POST "https://app.lance.so/api/v1/operations/export" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-o "leads-export.csv" \
-d '{
"selection": {
"mode": "bulk",
"startIndex": 0,
"targetCount": 100,
"excludedIds": ["excluded-id-1"],
"filters": {
"contact": {
"location": {
"any": {
"include": ["San Francisco, CA"]
}
}
}
}
}
}'
const response = await fetch("/api/v1/operations/export", {
method: "POST",
headers: {
Authorization: "Bearer <token>",
"Content-Type": "application/json",
},
body: JSON.stringify({
selection: {
mode: "manual",
includedIds: [
"550e8400-e29b-41d4-a716-446655440000",
"6ba7b810-9dad-11d1-80b4-00c04fd430c8",
],
},
exportFields: ["name", "emails", "phones", "jobTitle", "companyName"],
}),
});
// Get the export count from headers
const exportCount = response.headers.get("X-Export-Count");
// Download the CSV
const blob = await response.blob();
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "leads-export.csv";
a.click();
interface BulkSelectionPayload {
mode: "manual" | "bulk";
startIndex?: number;
targetCount?: number;
excludedIds?: string[];
includedIds?: string[];
filters?: PeopleSearchFilters;
}
interface ExportRequest {
selection: BulkSelectionPayload;
exportFields?: string[];
}
const response = await fetch("/api/v1/operations/export", {
method: "POST",
headers: {
Authorization: "Bearer <token>",
"Content-Type": "application/json",
},
body: JSON.stringify({
selection: {
mode: "manual",
includedIds: [
"550e8400-e29b-41d4-a716-446655440000",
"6ba7b810-9dad-11d1-80b4-00c04fd430c8",
],
},
exportFields: ["name", "emails", "phones", "jobTitle", "companyName"],
} satisfies ExportRequest),
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.error);
}
const exportCount = parseInt(response.headers.get("X-Export-Count") || "0", 10);
const blob = await response.blob();
Name,Email(s),Phone(s),Job Title,Company Name
John Smith,john@example.com,+1-555-0100,Software Engineer,Acme Corp
Jane Doe,"jane@example.com, jane.doe@personal.com",+1-555-0101,Product Manager,Tech Inc
{
"error": "No data to export"
}
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid selection mode"
}
}
{
"error": {
"code": "INTERNAL_ERROR",
"message": "No valid export fields specified"
}
}
Error Codes
| Status Code | Error Code | Description |
|---|---|---|
400 | - | No data to export (selection resolved to 0 leads) |
400 | VALIDATION_ERROR | Invalid request body or missing required fields |
500 | INTERNAL_ERROR | Server error during export generation |
Filters Reference
Forbulk mode, the filters object uses the People Search schema. Key filter sections include:
Contact Filters
fullName- Filter by person namelocation- Filter by location (city, country)seniority- Filter by seniority level (entry, mid-level, senior, director, c_suite, etc.)departmentAndFunction- Filter by department or functionskill- Filter by skillseducation- Filter by school, degree, or field of studyexperience- Filter by current or previous job titles
Account (Company) Filters
nameOrDomain- Filter by company name or domainindustry- Filter by company industrylocation- Filter by company locationemployeeSize- Filter by company size rangerevenue- Filter by company revenue rangetype- Filter by company type (public, private, etc.)
Notes
- Maximum bulk selection: 1000 leads per export
- Default fields: If no
exportFieldsspecified, exports: name, emails, phones, linkedinUrl, city, country, jobTitle, companyName - CSV escaping: Values with commas, quotes, or newlines are automatically quoted and escaped
- Filename: Automatically generated with current date:
lance-prospects-YYYY-MM-DD.csv - Authentication: Requires authentication; exports are scoped to the authenticated organization