Add Custom Variables on Leads
curl --request POST \
--url https://api.lemlist.com/api/leads/{leadId}/variables \
--header 'Authorization: Basic <encoded-value>'import requests
url = "https://api.lemlist.com/api/leads/{leadId}/variables"
headers = {"Authorization": "Basic <encoded-value>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Basic <encoded-value>'}};
fetch('https://api.lemlist.com/api/leads/{leadId}/variables', 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/leads/{leadId}/variables")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.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/leads/{leadId}/variables",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
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;
}{
"ok": true
}
Leads
Add Custom Variables on Leads
Adds new custom variables to a lead.
POST
/
leads
/
{leadId}
/
variables
Add Custom Variables on Leads
curl --request POST \
--url https://api.lemlist.com/api/leads/{leadId}/variables \
--header 'Authorization: Basic <encoded-value>'import requests
url = "https://api.lemlist.com/api/leads/{leadId}/variables"
headers = {"Authorization": "Basic <encoded-value>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Basic <encoded-value>'}};
fetch('https://api.lemlist.com/api/leads/{leadId}/variables', 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/leads/{leadId}/variables")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.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/leads/{leadId}/variables",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
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;
}{
"ok": true
}
To add custom fields, you can add as many as you want in the body of your request with the desired value for these new fields.
A write that would create a company not yet in lemlist requires the “Create companies” permission on the API key’s user, otherwise it fails with
The purpose of this endpoint is first and foremost to create new variables, even though we have to give them specific values on a specific lead. That’s why you’ll get errors if you give variable names that already exist on a lead.By default, lemlist includes several variables related to leads:
email, firstName, lastName, picture, phone, linkedinUrl, companyName, companyDomain, and icebreaker.Beware, you cannot add a new variable with the same name as an existing variable (default or custom).Company fields —
companyName, companyDomain, companyIndustry, any company-prefixed key — are written on the company record the lead is linked to, the same record every other lead linked to it reads, not on that lead alone. The response says so: warnings carries a company-fields-write-company-record entry naming those keys in params.fields. It is informational, your request went through. To edit a company on purpose, use Upsert Company.403 COMPANY_CREATE_NOT_ALLOWED and nothing is written.
On a lead with no linked contact, a write that would create one requires the “Create contacts” permission on the API key’s user, otherwise it fails with 403 CONTACT_CREATE_NOT_ALLOWED and nothing is written.
The error names that user (The user jane@acme.com does not have the permission to create contacts [CONTACT_CREATE_NOT_ALLOWED]). When the API key’s user is no longer in the team, it fails with 403 API_USER_NOT_IN_TEAM instead (The user jane@acme.com is no longer in this team: ask a current member to create a new API key or reconnect [API_USER_NOT_IN_TEAM]).
Variable values may contain line breaks (
\n) — for example for multi-line text custom fields. They are stored and returned as-is: in HTML emails a \n is rendered as a line break, while LinkedIn and SMS keep it native.Authorizations
Query Parameters
Was this page helpful?