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
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
Body
Filter ID returned by Get CRM Filters
Salesforce only: lead or contact list views, or report. Ignored by HubSpot and Pipedrive. Defaults to lead when your Salesforce connection allows Leads, contact otherwise.
lead, contact, report 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.
all (or true) skips contacts already in another campaign, activeOnly skips only contacts still active in another campaign, off (or false, the default) imports everyone.
Enrichments to run on every imported lead, as an array or a |-separated string (e.g. find_email|verify). Consumes credits for each lead.
find_email, find_phone, verify, linkedin_enrichment 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 and true when no lead is imported yet: the campaign is in a state the import waits on, named by reason.
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?