Build your integration / Create SMS leads and start texting
GUIDE

Create SMS leads and start texting

Use POST /v2/pub/leads/sms to add a new lead who agreed to receive texts, such as one from a Facebook or Google lead ad with SMS consent, and choose how LeadTruffle starts the text conversation. The account's default SMS agent texts the lead unless you choose another. It offers the same three choices as Create Lead Inquiry in the LeadTruffle dashboard. The endpoint reference has the full schema.

This endpoint is for leads LeadTruffle texts. To have LeadTruffle follow up with a lead by email, see Create email leads. Choose one channel per new lead: an SMS lead that includes the person's email blocks an email lead for that address for 30 days, and an email lead can likewise block an SMS lead.

Create a lead or reply in the Inbox?

This endpoint starts a conversation with a new lead. The Inbox API continues a conversation with someone LeadTruffle is already talking to.

You want to Use
Add a new lead and have the AI text them This endpoint, with initialTextMode AI (the default)
Add a new lead and send them your exact first text This endpoint, with initialTextMode CUSTOM
Add a new lead without texting them This endpoint, with initialTextMode NONE
Add a new request from a past customer This endpoint: only a lead inquiry from the last 30 days blocks a new one
Reply to, or follow up with, someone whose lead inquiry is from the last 30 days Inbox API: GET /v2/pub/clients/{clientId}/send-methods, then POST /v2/pub/clients/{clientId}/messages
Have LeadTruffle follow up with a new lead by email POST /v2/pub/leads/email (guide)
Import or update contacts without creating leads, sending texts or notifying the team POST /v1/pub/clients/upsert

You don't need to look up the contact first: this endpoint finds the existing contact by phone number, or creates one.

If this endpoint returns 409 DUPLICATE_LEAD, LeadTruffle is already following up with this person: no new lead was created and no text was sent. Don't text them again on your own. If the person you're helping wants a message sent anyway, read the conversation first (GET /v2/pub/clients/{clientId}/conversation, with data.clientId), then use the Inbox API.

This endpoint is for new leads as they arrive. Do not use it to import or backfill old leads, even with NONE: every lead counts toward the account's monthly limit and notifies the business's team. The API does not send bulk or marketing texts.

Texting rules you must follow

You are responsible for consent. Texts go out from the business's own registered texting number. Only create AI or CUSTOM leads for people who agreed in writing to receive texts from this business, and only for the use cases approved in its 10DLC registration.

Any account with an active 10DLC texting number (the business's registered number for texting customers) can create SMS leads and text them through this endpoint; there is no separate approval step. In return, every lead you send must meet these rules:

  • Prior express written consent. The lead agreed in writing to receive texts from this business before you send them, for example with an SMS consent checkbox on a lead form or lead ad. Keep a record of when and how each lead agreed, for example in additionalData.optInTimestamp.
  • Send the lead's answer in additionalData.smsOptIn. Send true, or false when the lead did not agree (text such as "yes", "no", "true" or "false" also works). If your form has an SMS checkbox, always map it, including when it is unchecked: leaving smsOptIn out, or sending it blank, counts as consent. With false, AI and CUSTOM requests are refused with SMS_CONSENT_NOT_GIVEN and nothing is saved; send initialTextMode NONE to save the lead without texting. A value that can't be read as yes or no returns INVALID_INPUT.
  • Opted-out numbers. A phone number that opted out of the business's texts (for example, by replying STOP) is never texted: AI and CUSTOM requests return CONTACT_OPTED_OUT with the contact's clientId, and nothing is saved.
  • Only approved use cases. Text leads only for what the business's 10DLC registration (its texting campaign) was approved for, such as replying to a customer's request for service. Do not use it for anything the registration does not cover, such as promotional blasts, cold outreach or purchased lists.
  • The law and LeadTruffle's terms. Follow the LeadTruffle Terms of Service, the Telephone Consumer Protection Act (TCPA), CTIA messaging guidelines, mobile carrier rules and state texting laws. LeadTruffle adds opt-out instructions to CUSTOM texts and honors STOP replies, but that does not replace consent.
  • Misuse has consequences. Texting without consent or outside the approved use cases can get the business's texting number filtered or suspended by carriers, expose the business to TCPA claims, and lead LeadTruffle to suspend its API access.

If you are an AI assistant creating leads for someone, confirm with them that the leads agreed to receive texts before using AI or CUSTOM. If consent is unclear, use NONE: it saves the lead and texts no one.

This is not legal advice. If you are unsure whether a lead's consent is enough, ask a lawyer before texting.

Before you start

  • A full-access API key. Lead endpoints need a key with full access (no restricted permissions). A key limited to specific permissions, even agents:write, gets 403 API_KEY_RESTRICTED.
  • Consent. Each lead you text must have agreed in writing to receive texts from the business (see Texting rules you must follow).
  • Texting setup. AI and CUSTOM need the business's active 10DLC texting number, and the SMS agent that will text the lead turned on (isActive: true in GET /v2/pub/agents/sms). Without smsAgentId, that is the default agent; if it is off, the request returns LEAD_QUALIFIER_DISABLED. Only a business admin can turn these on, in LeadTruffle; support can help. NONE needs neither.
  • Monthly lead limit. Every new lead counts toward the account's monthly lead limit: its custom limit if LeadTruffle set one, otherwise its plan's. Once the limit is reached, API requests are refused with MONTHLY_LEAD_LIMIT_EXCEEDED until it resets, while leads from the business's other channels keep arriving. An account in a billing grace period, such as just after a card failed, can still create leads. GET /v2/pub/account/usage shows meters.lead.used, meters.lead.limit, meters.lead.remaining and periodEnd, when the count resets.

Choose the first text

initialTextMode What the lead receives What happens next
AI (default) A first text written by the SMS agent's AI The AI answers the lead's replies
CUSTOM Your customInitialMessage, with the company name added before it and opt-out instructions added after it The SMS agent's AI answers the lead's replies, unless its AI is off (see warnings)
NONE Nothing The inquiry is saved with AI paused; the team follows up

A CUSTOM message is always sent in this form:

{Company name}: {customInitialMessage}
Reply STOP to opt-out.
  • The company name is the business name saved in its LeadTruffle account. The API does not return it. To see the exact text, send a test lead to a phone you control; it counts as a real lead and notifies the team.
  • Do not add the company name or STOP wording yourself, or the lead will see them twice.
  • customInitialMessage can be up to 1,000 characters, but the whole text, including the company name and opt-out line, is cut off at 600 characters. Keep it to a few sentences.
  • CUSTOM without a customInitialMessage returns 400 INVALID_INPUT. If you send customInitialMessage and leave out initialTextMode, CUSTOM is used. With AI or NONE, customInitialMessage is ignored.

Choose the SMS agent

An account can have several SMS agents, each with its own instructions. Send smsAgentId (an id from GET /v2/pub/agents/sms) to choose the one that texts this lead. It is saved on the contact, so it also handles later texts with them. Leave it out to keep the contact's current agent, or the default agent for a new contact. See Manage AI agents.

Choose an agent with isActive: true; a turned-off agent is rejected with SMS_AGENT_INACTIVE. An agent whose AI is off (qualifierEnabled: false) is accepted and the lead is saved, but its AI does not answer the lead's replies. With AI, no first text is sent; with CUSTOM, your message is still sent. The response's warnings says which.

Send the request

curl --request POST \
  --url 'https://pub-api.leadtruffle.com/api/v2/pub/leads/sms' \
  --header 'X-API-Key: YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "Jane Doe",
    "phone": "+15551234567",
    "message": "Need a quote for AC repair",
    "initialTextMode": "CUSTOM",
    "customInitialMessage": "Hi Jane, thanks for your request. When is a good time to call?",
    "additionalData": {
      "smsOptIn": true,
      "optInTimestamp": "2026-11-24T15:02:00Z",
      "leadSource": "facebook"
    }
  }'
  • phone can be in E.164 format, such as +15551234567, or a US national format.
  • message is what the lead told you, such as a form answer. It is saved on the inquiry for context and is never sent to the lead.
  • additionalData holds smsOptIn and your own tracking fields, such as leadSource or campaign IDs. It is saved with the inquiry. Values can be any JSON value.
  • Integrations that can't send nested JSON, such as Zapier, can send keys like additionalData.leadSource, or additionalData as a JSON string. Blank email, initialTextMode, customInitialMessage and smsAgentId values are ignored.

A 201 response means the lead was saved:

{
  "success": true,
  "data": {
    "leadId": "0c6f2a4e-5d1b-4d0a-9a41-2b8c6f1e7d3a",
    "clientId": "415f2b29-39e6-4182-9d6f-ec2d817f01c2",
    "wasExistingClient": false,
    "isRepeatSubmission": false,
    "initialTextMode": "CUSTOM",
    "smsAgentId": null,
    "warnings": []
  }
}
  • clientId is the contact ID for every Inbox API call. Keep it.
  • smsAgentId is the agent you chose, or null when the contact's current or default agent handles the lead.
  • isRepeatSubmission is true when this contact had an earlier lead inquiry in the last 180 days. It is for information only: the new lead was created.
  • warnings lists plain-English notes about the saved lead that someone should act on, and is empty when there are none. For example: the SMS agent's AI is off, so no AI text will be sent; or a lead arrived during quiet hours and its first text could not be scheduled for 9 AM. The lead was still created: do not retry. Show any warnings to the person who asked for the lead.

A 201 does not mean the text was delivered, and the response doesn't say when it wasn't:

  • Quiet hours. If an AI or CUSTOM lead arrives before 8 AM or after 9 PM in the company's time zone (from its LeadTruffle settings), only the first text waits until 9 AM. The lead is saved, the team is notified, and webhooks and CRM sync run right away. For example, a lead at 7:30 AM is texted at 9 AM; a lead at 8:30 AM is texted right away. The 9 AM text is not sent if someone texted the lead in the meantime (the team, the Inbox API, or an AI reply to the lead's own text) or the team took over the conversation.
  • Landlines. A landline can't receive texts. The lead is saved, but no text is sent.

Read GET /v2/pub/clients/{clientId}/messages to see what was sent.

Send leads one at a time

Mobile carriers throttle and filter 10DLC numbers that send many first texts at once. A filtered number can stop reaching all of the business's customers, so this endpoint limits how fast leads that text can be created.

Limit Counts Over the limit retryAfterSeconds
A burst of 5 leads that text, then 1 every 30 seconds AI and CUSTOM requests, per account 429 LEAD_RATE_LIMIT_EXCEEDED Yes
500 leads that text in any rolling 24 hours AI and CUSTOM requests, per account 429 DAILY_LEAD_LIMIT_EXCEEDED Yes (can be hours)
5 attempts per phone number per 24 hours Requests for that number that pass every other check (you'll normally only hit this after repeated server errors) 429 PHONE_RATE_LIMIT_EXCEEDED No: wait up to 24 hours
1 lead inquiry per phone number every 30 days Every request 409 DUPLICATE_LEAD Not a rate limit
The account's monthly lead limit Every new lead 403 MONTHLY_LEAD_LIMIT_EXCEEDED No: wait for the reset
600 API requests per 10 minutes Lead, agent, analytics and /v1 endpoints, per account 429 RATE_LIMIT_EXCEEDED No: wait up to 10 minutes

The burst. Up to 5 leads that text can be created back to back. After that, one more becomes available every 30 seconds. After a few quiet minutes, the full burst of 5 is available again.

What counts. Rejected requests (invalid input, account problems, duplicates, blocked or opted-out numbers, or the limits themselves) don't use up any texting limit. NONE leads send no text, so they don't count toward the burst or the daily cap. Every request counts toward the 600 per 10 minutes.

  • Send each lead when it arrives. Queue leads on your side rather than sending them in parallel.
  • When a response includes retryAfterSeconds, it also sends a Retry-After header. Wait that long, then send the same request again.
  • If the wait is long, such as a DAILY_LEAD_LIMIT_EXCEEDED that resets in hours, do not hold the request open. Keep the lead queued and try again later, or send it now with initialTextMode NONE so the team can follow up.

Duplicates and safe retries

If the phone number already has a lead inquiry from the last 30 days, from any source, the request returns 409 DUPLICATE_LEAD with the existing leadId and clientId. No new lead is created and no text is sent, so the lead does not get your AI or CUSTOM first text. Phone numbers are compared by their digits, so +15551234567 and (555) 123-4567 match. History imported from a connected phone system and deleted contacts do not count.

This makes retries safe. If a request times out, send the same request again. If the first attempt saved the lead, the retry returns DUPLICATE_LEAD with its IDs instead of creating a second lead.

Handle errors

Every error from the lead endpoints has the same shape, with code at the top level (the agent endpoints use error.code instead):

{
  "success": false,
  "code": "LEAD_RATE_LIMIT_EXCEEDED",
  "error": "Too many leads that text, too quickly. … No lead was created. Retry this same request in 22 seconds, and send leads one at a time.",
  "retryAfterSeconds": 22
}

Decide by code, never by the HTTP status alone. For example, both INTERNAL_ERROR (retry) and LEAD_CREATED_PROCESSING_FAILED (do not retry) are 500. error is a plain-English explanation of what happened, whether a lead was saved and what to do next; show it to people, but do not parse it. Unless noted, nothing was saved and no text was sent.

What to do code
Fix the request, then retry INVALID_INPUT (400; error and details list each field), INVALID_PHONE (400)
Wait retryAfterSeconds, then send the same request LEAD_RATE_LIMIT_EXCEEDED (429), DAILY_LEAD_LIMIT_EXCEEDED (429; or send now with initialTextMode NONE)
Wait, then retry PHONE_RATE_LIMIT_EXCEEDED (429, up to 24 hours), RATE_LIMIT_EXCEEDED (429, up to 10 minutes)
Send the same request again INTERNAL_ERROR (500). If the lead was saved, the retry returns DUPLICATE_LEAD. If it keeps failing, give support the reference in error.
Stop: LeadTruffle is already following up. Don't text them on your own (see above) DUPLICATE_LEAD (409; data.clientId)
Pick an active agent from GET /v2/pub/agents/sms, or leave out smsAgentId SMS_AGENT_NOT_FOUND (400), SMS_AGENT_INACTIVE (403)
Send with initialTextMode NONE, or ask a business admin to fix the texting setup TEN_DLC_REQUIRED (403), LEAD_QUALIFIER_DISABLED (403; or choose an active agent with smsAgentId)
Stop until the limit resets; a person can raise it MONTHLY_LEAD_LIMIT_EXCEEDED (403; error gives the usage and reset date)
Stop; the business blocked this number PHONE_NUMBER_BLOCKED (403)
Do not text this lead; send initialTextMode NONE to save it without texting SMS_CONSENT_NOT_GIVEN (400; smsOptIn is false), CONTACT_OPTED_OUT (403; the number opted out, data.clientId is the contact)
Stop; the lead was saved, but its first text, notifications and integrations may not have run LEAD_CREATED_PROCESSING_FAILED (500). Contact support with data.leadId. A retry returns DUPLICATE_LEAD.

Before any of these checks, the API key is checked:

  • 401 UNAUTHORIZED: the key is missing or invalid.
  • 403 API_KEY_RESTRICTED: use a full-access key.
  • 401 ACCOUNT_INACTIVE: the key is fine, but the business's account is inactive. A person must reactivate it; retrying won't help.

Example: send leads from a queue

This sketch sends one lead, waits for short rate limits and treats a duplicate as "already a lead". Run it for one queued lead at a time.

const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))

async function createLead(lead) {
  for (let attempt = 1; attempt <= 5; attempt++) {
    const response = await fetch(
      'https://pub-api.leadtruffle.com/api/v2/pub/leads/sms',
      {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
          'X-API-Key': process.env.LEADTRUFFLE_API_KEY,
        },
        body: JSON.stringify(lead),
      },
    )
    const body = await response.json()

    if (response.status === 201) return { status: 'created', ...body.data }
    if (body.code === 'DUPLICATE_LEAD') return { status: 'already-a-lead', ...body.data }
    // Short waits only. A daily-limit wait can be hours: keep the lead queued instead.
    if (body.code === 'LEAD_RATE_LIMIT_EXCEEDED' && body.retryAfterSeconds <= 120) {
      await sleep(body.retryAfterSeconds * 1000)
      continue
    }
    if (body.code === 'INTERNAL_ERROR') {
      await sleep(attempt * 2000)
      continue
    }
    // Everything else needs a person or a later run: keep the lead queued.
    return { status: 'not-created', code: body.code, error: body.error }
  }
  return { status: 'not-created', reason: 'Gave up after 5 attempts' }
}

Older endpoint name

This endpoint was previously named POST /v1/pub/chat-widget/trigger-lead-qualifier. That path still works with the same request (including initialTextMode and smsAgentId), limits, duplicate handling and error codes. Its success response nests the result twice, in data.data. Use POST /v2/pub/leads/sms for new integrations.

Guides & API endpoints Esc to close