string
Personalize Email
curl --request POST \
--url https://api.example.com/v1/lexi/personalize-email \
--header 'Content-Type: application/json' \
--data '
{
"contact_id": "<string>",
"intent": "<string>",
"template": "<string>",
"tone": "<string>",
"length": "<string>",
"language": "<string>"
}
'import requests
url = "https://api.example.com/v1/lexi/personalize-email"
payload = {
"contact_id": "<string>",
"intent": "<string>",
"template": "<string>",
"tone": "<string>",
"length": "<string>",
"language": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
contact_id: '<string>',
intent: '<string>',
template: '<string>',
tone: '<string>',
length: '<string>',
language: '<string>'
})
};
fetch('https://api.example.com/v1/lexi/personalize-email', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v1/lexi/personalize-email",
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([
'contact_id' => '<string>',
'intent' => '<string>',
'template' => '<string>',
'tone' => '<string>',
'length' => '<string>',
'language' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/lexi/personalize-email"
payload := strings.NewReader("{\n \"contact_id\": \"<string>\",\n \"intent\": \"<string>\",\n \"template\": \"<string>\",\n \"tone\": \"<string>\",\n \"length\": \"<string>\",\n \"language\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/v1/lexi/personalize-email")
.header("Content-Type", "application/json")
.body("{\n \"contact_id\": \"<string>\",\n \"intent\": \"<string>\",\n \"template\": \"<string>\",\n \"tone\": \"<string>\",\n \"length\": \"<string>\",\n \"language\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/lexi/personalize-email")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"contact_id\": \"<string>\",\n \"intent\": \"<string>\",\n \"template\": \"<string>\",\n \"tone\": \"<string>\",\n \"length\": \"<string>\",\n \"language\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"subject": "<string>",
"body_text": "<string>",
"body_html": "<string>",
"personalization_notes": [
{}
],
"reading_time_seconds": 123,
"credits_remaining": 123
}
}Lexi AI
Personalize Email
Generate a personalized email draft for a specific contact, optionally based on a template
POST
/
v1
/
lexi
/
personalize-email
Personalize Email
curl --request POST \
--url https://api.example.com/v1/lexi/personalize-email \
--header 'Content-Type: application/json' \
--data '
{
"contact_id": "<string>",
"intent": "<string>",
"template": "<string>",
"tone": "<string>",
"length": "<string>",
"language": "<string>"
}
'import requests
url = "https://api.example.com/v1/lexi/personalize-email"
payload = {
"contact_id": "<string>",
"intent": "<string>",
"template": "<string>",
"tone": "<string>",
"length": "<string>",
"language": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
contact_id: '<string>',
intent: '<string>',
template: '<string>',
tone: '<string>',
length: '<string>',
language: '<string>'
})
};
fetch('https://api.example.com/v1/lexi/personalize-email', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v1/lexi/personalize-email",
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([
'contact_id' => '<string>',
'intent' => '<string>',
'template' => '<string>',
'tone' => '<string>',
'length' => '<string>',
'language' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/lexi/personalize-email"
payload := strings.NewReader("{\n \"contact_id\": \"<string>\",\n \"intent\": \"<string>\",\n \"template\": \"<string>\",\n \"tone\": \"<string>\",\n \"length\": \"<string>\",\n \"language\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/v1/lexi/personalize-email")
.header("Content-Type", "application/json")
.body("{\n \"contact_id\": \"<string>\",\n \"intent\": \"<string>\",\n \"template\": \"<string>\",\n \"tone\": \"<string>\",\n \"length\": \"<string>\",\n \"language\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/lexi/personalize-email")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"contact_id\": \"<string>\",\n \"intent\": \"<string>\",\n \"template\": \"<string>\",\n \"tone\": \"<string>\",\n \"length\": \"<string>\",\n \"language\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"subject": "<string>",
"body_text": "<string>",
"body_html": "<string>",
"personalization_notes": [
{}
],
"reading_time_seconds": 123,
"credits_remaining": 123
}
}This endpoint consumes 2 AI credits per call. If the workspace balance is insufficient, the API returns
402 insufficient_credits.Request
Headers
Authorization: Bearer wbk_your_api_key_here
Content-Type: application/json
string
Optional UUID for retry deduplication.
Body Parameters
string
required
UUID of the contact the email is for.
string
required
High-level purpose of the email, in natural language. Examples:
"schedule an intro call", "follow up on proposal", "check-in after six weeks of silence".string
Optional template body. Merge tokens (
{{first_name}}, {{company}}) are resolved and the output is personalized around the template’s voice.string
default:"professional"
One of
professional, warm, formal, casual.string
default:"medium"
short (~50 words), medium (~120 words), or long (~250 words).string
default:"en"
ISO 639-1 language code.
Response
object
X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, and X-Request-ID.
curl -X POST \
https://data.leadlex.com/functions/v1/api-gateway/v1/lexi/personalize-email \
-H "Authorization: Bearer wbk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"contact_id": "123e4567-e89b-12d3-a456-426614174000",
"intent": "follow up on proposal",
"tone": "warm"
}'
import requests
API_KEY = "wbk_your_api_key_here"
BASE_URL = "https://data.leadlex.com/functions/v1/api-gateway"
r = requests.post(
f"{BASE_URL}/v1/lexi/personalize-email",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
},
json={
"contact_id": "123e4567-e89b-12d3-a456-426614174000",
"intent": "follow up on proposal",
"tone": "warm",
},
)
print(r.json()["data"]["subject"])
const res = await fetch(
'https://data.leadlex.com/functions/v1/api-gateway/v1/lexi/personalize-email',
{
method: 'POST',
headers: {
'Authorization': 'Bearer wbk_your_api_key_here',
'Content-Type': 'application/json',
},
body: JSON.stringify({
contact_id: '123e4567-e89b-12d3-a456-426614174000',
intent: 'follow up on proposal',
}),
}
);
const { data } = await res.json();
console.log(data.subject, data.body_text);
Example Response
{
"data": {
"subject": "Quick follow-up on the Series B engagement proposal",
"body_text": "Hi Jane,\n\nHope the week has been smooth on your end. Wanted to circle back on the flat-fee engagement proposal we shared last Tuesday and see if anything could use another pass or clarification before you share internally...",
"body_html": "<p>Hi Jane,</p><p>Hope the week has been smooth on your end. Wanted to circle back on the flat-fee engagement proposal we shared last Tuesday and see if anything could use another pass or clarification before you share internally...</p>",
"personalization_notes": [
"Referenced the proposal date from the last email thread",
"Used warm tone aligned with prior correspondence"
],
"reading_time_seconds": 28,
"credits_remaining": 4840
}
}
Errors
| Status | Code | Description |
|---|---|---|
| 400 | validation_error | Missing contact_id or intent |
| 401 | invalid_key | Invalid or expired API key |
| 402 | insufficient_credits | Workspace credit balance is exhausted |
| 403 | insufficient_permissions | Missing write:ai permission |
| 404 | not_found | Contact not found |
| 429 | rate_limited | Rate limit exceeded |