curl --request POST \
--url https://api.lemlist.com/api/companies/lists/{listId}/entities \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"companyIds": [
"cpn_xxxxxxxxxxxxxxxxx",
"cpn_yyyyyyyyyyyyyyyyy"
]
}
'import requests
url = "https://api.lemlist.com/api/companies/lists/{listId}/entities"
payload = { "companyIds": ["cpn_xxxxxxxxxxxxxxxxx", "cpn_yyyyyyyyyyyyyyyyy"] }
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({companyIds: ['cpn_xxxxxxxxxxxxxxxxx', 'cpn_yyyyyyyyyyyyyyyyy']})
};
fetch('https://api.lemlist.com/api/companies/lists/{listId}/entities', 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/companies/lists/{listId}/entities")
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 \"companyIds\": [\n \"cpn_xxxxxxxxxxxxxxxxx\",\n \"cpn_yyyyyyyyyyyyyyyyy\"\n ]\n}"
response = http.request(request)
puts response.read_body<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.lemlist.com/api/companies/lists/{listId}/entities",
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([
'companyIds' => [
'cpn_xxxxxxxxxxxxxxxxx',
'cpn_yyyyyyyyyyyyyyyyy'
]
]),
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;
}Add or Remove Companies in a List
Add companies to a static company list, or remove them with ?action=remove.
curl --request POST \
--url https://api.lemlist.com/api/companies/lists/{listId}/entities \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"companyIds": [
"cpn_xxxxxxxxxxxxxxxxx",
"cpn_yyyyyyyyyyyyyyyyy"
]
}
'import requests
url = "https://api.lemlist.com/api/companies/lists/{listId}/entities"
payload = { "companyIds": ["cpn_xxxxxxxxxxxxxxxxx", "cpn_yyyyyyyyyyyyyyyyy"] }
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({companyIds: ['cpn_xxxxxxxxxxxxxxxxx', 'cpn_yyyyyyyyyyyyyyyyy']})
};
fetch('https://api.lemlist.com/api/companies/lists/{listId}/entities', 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/companies/lists/{listId}/entities")
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 \"companyIds\": [\n \"cpn_xxxxxxxxxxxxxxxxx\",\n \"cpn_yyyyyyyyyyyyyyyyy\"\n ]\n}"
response = http.request(request)
puts response.read_body<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.lemlist.com/api/companies/lists/{listId}/entities",
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([
'companyIds' => [
'cpn_xxxxxxxxxxxxxxxxx',
'cpn_yyyyyyyyyyyyyyyyy'
]
]),
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;
}?action=remove. The list must be a static company list (clt_xxx); dynamic lists (auto-populated by filter rules) and contact lists are rejected.
POST ?action=remove, not DELETE. A DELETE request body is dropped by our stack, so DELETE on this path is not supported and returns 405 Method Not Allowed.Add vs remove
| Action | Request | Result |
|---|---|---|
| Add | POST with { "companyIds": [...] } | Companies are added. Those already in the list are silently skipped (counted in alreadyInList). |
| Remove | POST ?action=remove with { "companyIds": [...] } | Companies are removed. Those not in the list are silently skipped (removedCount reflects associations actually removed). |
Typical workflow
- Find or create a list — use
GET /companies/liststo find an existing static list, orPOST /companies/liststo create one (clt_xxx). - Find companies — use
GET /companieswithsearchorlistIdto get company IDs (cpn_xxx). - Add or remove — call this endpoint with the company IDs and list ID. Up to 1,000 companies per request.
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 company list (clt_xxx format). Must be a static company list.
^clt_[a-zA-Z0-9]+$Query Parameters
Omit to add the companies to the list. Set to remove to remove them from the list.
remove Body
Array of company IDs (cpn_xxx format) to add to or remove from the list. Required, non-empty, maximum 1,000 per request.
1 - 1000 elements^cpn_[a-zA-Z0-9]+$Response
Companies added to or removed from the list successfully. The response body depends on action.
Number of companies added to the list (add only).
Number of companies that were already in the list and therefore skipped (add only).
Number of list associations actually removed (remove only). Companies that were not in the list are not counted.
Was this page helpful?