Create email leads
Use POST /v2/pub/leads/email to add a new lead that LeadTruffle follows up with by email. The lead's message is treated as their email to the business, and an email agent's AI replies from the business's own email address and handles the conversation. The endpoint reference has the full schema.
To text a lead instead, see Create SMS leads and start texting. To email someone who is already a contact, use the Inbox API.
Before you start
- A full-access API key. Lead endpoints need a key with full access (no restricted permissions); a restricted key gets
403API_KEY_RESTRICTED. - The business's own email domain. Email leads and email agents only work with a domain the business owns, set up with LeadTruffle and with verified DNS records (Settings → Email in LeadTruffle). The shared LeadTruffle email domain cannot be used. Without one, requests return
403CUSTOM_EMAIL_DOMAIN_REQUIRED. - An email agent. Email agents are created in LeadTruffle (Email Gateway). List them with
GET /v2/pub/agents/email; only agents withcanCreateLeads: truecan start conversations. - Consent. Only submit leads who asked to be contacted, and follow email rules such as CAN-SPAM.
- Monthly lead limit. Every new lead counts toward the account's monthly lead limit (its custom limit, or its plan's). At the limit, requests return
MONTHLY_LEAD_LIMIT_EXCEEDEDuntil it resets. - One channel per lead. An email lead and an SMS lead for the same person block each other for 30 days, so choose one.
Send the request
curl --request POST \
--url 'https://pub-api.leadtruffle.com/api/v2/pub/leads/email' \
--header 'X-API-Key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"email": "jane@example.com",
"name": "Jane Doe",
"phone": "+15551234567",
"message": "Need a quote for a new furnace."
}'
Send emailAgentId to choose the agent. Leave it out to use the default agent, or the only agent that can start conversations. If several can and none is the default, the request returns 400 EMAIL_AGENT_REQUIRED with the choices in eligibleAgentIds. If eligibleAgentIds is empty, no email agent can start conversations: stop and ask a business admin to set one up or turn one on in LeadTruffle (Email Gateway).
What comes back
A 202 means the lead was accepted, not finished:
{
"success": true,
"data": {
"status": "QUEUED",
"requestId": "0c6f2a4e-5d1b-4d0a-9a41-2b8c6f1e7d3a",
"emailAgentId": "415f2b29-39e6-4182-9d6f-ec2d817f01c2",
"emailAgentAddress": "leads@mail.acmehvac.com"
}
}
The agent's AI reads the message first, then emails the lead. The lead inquiry is usually created within a minute, so its IDs are not in this response. The AI does not create a lead from a message it judges to be spam or not a request for service; that happens after the 202.
To find out what happened, send the same request again after a minute:
| Response | Meaning |
|---|---|
409 DUPLICATE_LEAD |
The lead exists. data has its leadId and clientId. |
202 with status ALREADY_QUEUED |
Still being processed. Check again in a few minutes. |
422 EMAIL_LEAD_NOT_CREATED |
No lead was made, usually because it was judged spam. error says why. |
For 24 hours, every request for this email address gets one of these answers and sends nothing new, even if the message or emailAgentId changed. If it is still ALREADY_QUEUED after 30 minutes, or a real lead was refused, contact support with the requestId.
You can also find the lead in GET /v2/pub/leads-created (newest first): the item whose email matches and whose qualificationSource is EMAIL_QUALIFICATION.
Duplicates and retries
Each email address can have one lead inquiry every 30 days, from any source; addresses are compared ignoring case. History imported from a connected phone system and deleted contacts do not count. A repeat returns 409 DUPLICATE_LEAD with the existing leadId and clientId: LeadTruffle is already following up, so don't email them again on your own.
Retrying is safe within 24 hours: a request that timed out can be sent again, and no second email goes out. After 24 hours, check GET /v2/pub/leads-created before resending, because a request then counts as new.
Handle errors
Errors have the same shape as SMS leads: { "success": false, "code", "error" }, with code at the top level. Branch on code; error explains what happened and what to do.
| What to do | code |
|---|---|
| Fix the request, then retry | INVALID_INPUT (400) |
Choose an agent with canCreateLeads: true |
EMAIL_AGENT_NOT_FOUND (400), EMAIL_AGENT_UNAVAILABLE (403), EMAIL_AGENT_REQUIRED (400; choose from eligibleAgentIds, or stop if it is empty) |
| Stop: LeadTruffle is already following up. Don't email them on your own | DUPLICATE_LEAD (409; data.clientId) |
| Stop; a person must fix the account or key | CUSTOM_EMAIL_DOMAIN_REQUIRED (403), API_KEY_RESTRICTED (403), UNAUTHORIZED (401), ACCOUNT_INACTIVE (401; the key is fine, the account is inactive) |
| Stop until the limit resets | MONTHLY_LEAD_LIMIT_EXCEEDED (403) |
| Stop; the address opted out | EMAIL_OPTED_OUT (403) |
| Stop; a request for this address in the last 24 hours was processed and made no lead (usually judged spam) | EMAIL_LEAD_NOT_CREATED (422; error gives the reason and a request ID for support) |
| Wait up to 10 minutes, then retry | RATE_LIMIT_EXCEEDED (429; no retryAfterSeconds; the count resets every 10 minutes) |
Send the same request again within 24 hours. After that, first check whether the lead was created (GET /v2/pub/leads-created), because a later retry could send a second email |
INTERNAL_ERROR (500) |
The texting limits and 10DLC requirement of SMS leads do not apply to email leads.