Start Campaign Stats Export
curl --request GET \
--url https://api.lemlist.com/api/campaigns/{campaignId}/export/start \
--header 'Authorization: Basic <encoded-value>'import requests
url = "https://api.lemlist.com/api/campaigns/{campaignId}/export/start"
headers = {"Authorization": "Basic <encoded-value>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Basic <encoded-value>'}};
fetch('https://api.lemlist.com/api/campaigns/{campaignId}/export/start', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));require 'uri'
require 'net/http'
url = URI("https://api.lemlist.com/api/campaigns/{campaignId}/export/start")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Basic <encoded-value>'
response = http.request(request)
puts response.read_body<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.lemlist.com/api/campaigns/{campaignId}/export/start",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"_id": "axp_Vv6lJOc8NlVVmDud5",
"id": "axp_Vv6lJOc8NlVVmDud5",
"teamId": "tea_c123fg5h8ijKL9noP",
"campaignId": "cam_A1B2C3D4E5F6G7H8I9",
"campaignName": "Insights Outreach 2024",
"status": "pending",
"startedAt": "2024-07-09T13:43:52.124Z",
"progressIndex": 0,
"progressTime": 1720532632124,
"progressLastStepDuration": 0,
"progressType": "starting",
"progress": 0,
"total": 0
}"Bad team""Campaign not found"Campaigns
Start Campaign Stats Export
Initiates an asynchronous export of campaign statistics to a CSV file.
GET
/
campaigns
/
{campaignId}
/
export
/
start
Start Campaign Stats Export
curl --request GET \
--url https://api.lemlist.com/api/campaigns/{campaignId}/export/start \
--header 'Authorization: Basic <encoded-value>'import requests
url = "https://api.lemlist.com/api/campaigns/{campaignId}/export/start"
headers = {"Authorization": "Basic <encoded-value>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Basic <encoded-value>'}};
fetch('https://api.lemlist.com/api/campaigns/{campaignId}/export/start', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));require 'uri'
require 'net/http'
url = URI("https://api.lemlist.com/api/campaigns/{campaignId}/export/start")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Basic <encoded-value>'
response = http.request(request)
puts response.read_body<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.lemlist.com/api/campaigns/{campaignId}/export/start",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"_id": "axp_Vv6lJOc8NlVVmDud5",
"id": "axp_Vv6lJOc8NlVVmDud5",
"teamId": "tea_c123fg5h8ijKL9noP",
"campaignId": "cam_A1B2C3D4E5F6G7H8I9",
"campaignName": "Insights Outreach 2024",
"status": "pending",
"startedAt": "2024-07-09T13:43:52.124Z",
"progressIndex": 0,
"progressTime": 1720532632124,
"progressLastStepDuration": 0,
"progressType": "starting",
"progress": 0,
"total": 0
}"Bad team""Campaign not found"You first start an export, get an export ID, and then periodically check the status of the export with the Get Campaign Export Status endpoint.
You should stop polling as soon as you have a status that is different than “pending”.
Multiple exports on the same campaign can be done simultaneously as it is export ID based.
How it works
- Start the export: Call this endpoint to initiate the export process. You’ll receive an
exportIdin the response. - Check status: Use the
exportIdwith the Get Campaign Export Status endpoint to periodically check the export status. - Download: Once the status is
"done", use the provided URL to download the CSV file.
The export is ID-based rather than campaign-based, allowing multiple simultaneous exports of the same campaign (e.g., one by a user in the application and another by a script).
Response
The response includes:- exportId: Use this to check the export status
- status: Will be
"pending"initially, then"done"or"error" - progress information: Track the export progress
Next steps
After starting an export, use the Get Campaign Export Status endpoint to monitor progress and retrieve the download URL when ready.Authorizations
Basic authentication header of the form Basic <encoded-value>, where <encoded-value> is the base64-encoded string username:password.
Path Parameters
The unique identifier of the campaign to export
Response
Export started successfully
The unique identifier of the export
The unique identifier of the export (same as _id)
The team identifier
The campaign identifier
The name of the campaign
Current status of the export
Available options:
pending, done, error When the export was started
Current progress index
Timestamp of progress
Duration of last step in milliseconds
Type of current progress step
Number of items processed
Total number of items to process
Was this page helpful?