curl --request POST \
--url https://api.lemlist.com/api/campaigns/{campaignId}/leads/import \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"filterId": "16"
}
'import requests
url = "https://api.lemlist.com/api/campaigns/{campaignId}/leads/import"
payload = { "filterId": "16" }
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({filterId: '16'})
};
fetch('https://api.lemlist.com/api/campaigns/{campaignId}/leads/import', 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}/leads/import")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"filterId\": \"16\"\n}"
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}/leads/import",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'filterId' => '16'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"ok": true,
"importPending": true,
"reason": "campaign_paused"
}{
"error": "This campaign already imports from the CRM filter \"Q4 prospects\": change or unlink it in lemlist"
}The authentication you supplied is incorrect{
"error": "Campaign not found"
}Import Leads from CRM
Links a campaign to a filter of your connected CRM and imports its records as leads, now and as the filter picks up new ones.
curl --request POST \
--url https://api.lemlist.com/api/campaigns/{campaignId}/leads/import \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"filterId": "16"
}
'import requests
url = "https://api.lemlist.com/api/campaigns/{campaignId}/leads/import"
payload = { "filterId": "16" }
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({filterId: '16'})
};
fetch('https://api.lemlist.com/api/campaigns/{campaignId}/leads/import', 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}/leads/import")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"filterId\": \"16\"\n}"
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}/leads/import",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'filterId' => '16'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"ok": true,
"importPending": true,
"reason": "campaign_paused"
}{
"error": "This campaign already imports from the CRM filter \"Q4 prospects\": change or unlink it in lemlist"
}The authentication you supplied is incorrect{
"error": "Campaign not found"
}importPending: true and the reason.Authorizations
Body
Filter ID returned by Get CRM Filters
Salesforce only, for a list view scoped to its owner ("My leads", "My contacts"…): the team member the view is read as. They must have their own Salesforce account connected in lemlist. Leave it out in every other case (reports, views not scoped to an owner); it is ignored for HubSpot and Pipedrive, where your team's CRM connection is used.
Response
The campaign is linked to the filter; the import runs in the background, or waits until reason is lifted when importPending is true.
Present with importPending. campaign_paused: resume the campaign. campaign_archived: unarchive then resume it. campaign_crm_sync_paused: fix the cause shown in the campaign's import history in lemlist. The first import starts about an hour after that.
campaign_paused, campaign_archived, campaign_crm_sync_paused Was this page helpful?