API guide
AI agents and ringless voicemail
Create AI voice agents that answer and place calls and act in your systems, read AI call history, and send ringless voicemails and voicemail drops.
AI voice agents#
An AI agent is a voice bot that talks to callers in natural language. It can answer a company number, run outbound calls (one at a time or as a dialer campaign), look things up in its knowledge, collect information, update the CRM, send a text or email, transfer to a human, and call your own API while it talks. Scopes: ai:read and ai:write.
Create an agent#
curl -X POST "$LEXO_URL/api/v1/ai-agents" \
-H "Authorization: Bearer $LEXO_API_KEY" -H "Content-Type: application/json" \
-d '{"name": "Front desk", "language": "en", "greeting": "Thanks for calling Northwind Dental, how can I help?", "instructions": "Answer questions about opening hours and book cleanings. Be brief and friendly.", "maxDurationSec": 600, "tools": {"hangup": {"enabled": true}, "transfer": {"enabled": true, "targets": [{"name": "Reception", "description": "A human receptionist", "type": "queue", "value": "6f1e2d3c-4b5a-4968-8776-5a4b3c2d1e0f", "mode": "warm"}]}}}'Main fields: greeting (first sentence), instructions (how the agent behaves), businessDescription, voice (an id from GET /ai-agents/voices), language, maxDurationSec, silenceTimeoutSec, outbound answering machine detection (amdEnabled, amdAction), the outbound caller ID callerIdNumberId, and tools:
| Tool | What the agent can do |
|---|---|
hangup | end the call politely |
transfer | hand the caller to named targets (extension, queue, number or ai_agent; cold or warm) |
sendMessage | send an SMS, WhatsApp or email from a template with {{variables}} |
crmUpdate | update listed fields of the caller's CRM record |
scheduleCallback | book a callback task for a user |
collect | collect typed fields (string, number, boolean, date, email, phone), optionally saved to CRM fields |
httpActions | call your API (up to 10 actions; see below) |
knowledge | answer from the agent's knowledge sources |
Add knowledge with POST /ai-agents/{id}/knowledge ({"type": "url", "source": "https://www.example.com"} to crawl a site, or type text / faq). Every save of an agent is a version: GET /ai-agents/{id}/versions lists them and POST /ai-agents/{id}/versions/{version}/publish rolls back to one.
Answer inbound calls#
Route a number to the agent: PATCH /numbers/{id} with {"routeType": "ai_agent", "routeId": "AGENT_ID"} (see Phone system), or use an ai_agent step in an IVR call flow. Use a schedule to let the agent answer only after hours.
Place an outbound AI call#
curl -X POST "$LEXO_URL/api/v1/ai-agents/AGENT_ID/calls" \
-H "Authorization: Bearer $LEXO_API_KEY" -H "Content-Type: application/json" \
-d '{"to": "+12125550123", "variables": {"name": "Grace", "appointment": "Tuesday 3 pm"}}'variables are available to the agent (and to message templates) as {{name}}. recordId links the call to a CRM record. The prepaid balance, fraud checks, caller ID rules and least-cost routing apply. For many numbers, create a dialer campaign with mode: "ai" instead.
AI call history#
GET /ai-agents/calls(filter byagentId,direction,outcome) andGET /ai-agents/calls/{id}: transcript, summary, tool log, collected fields, recording and price.- The
ai.call.endedwebhook delivers the same data when the call ends. GET /reports/call-qa(scopereports:read): AI quality scorecards of reviewed calls.
Call your API during a call (HTTP actions)#
An HTTP action is a function the agent may call while talking, for example book_appointment or check_order_status. You give it a name, a description the model reads, your url, the method, and a JSON Schema of its arguments:
{
"tools": {
"httpActions": [
{
"name": "book_appointment",
"description": "Book a cleaning. Use after the caller confirmed a date and time.",
"url": "https://api.example.com/lexo/book",
"method": "POST",
"parameters": {
"type": "object",
"properties": {
"date": { "type": "string", "description": "YYYY-MM-DD" },
"time": { "type": "string", "description": "HH:MM, 24-hour" },
"patientName": { "type": "string" }
},
"required": ["date", "time", "patientName"]
}
}
]
}
}LexoConnect POSTs to your URL (8-second timeout):
{
"type": "ai.action",
"action": "book_appointment",
"timestamp": "2026-11-13T15:04:05Z",
"tenantId": "…",
"data": {
"arguments": { "date": "2026-11-18", "time": "15:00", "patientName": "Grace Hopper" },
"aiCallId": "…", "agentId": "…", "callUuid": "…",
"from": "+12125550123", "to": "+14155550100", "direction": "inbound",
"variables": {}
}
}Answer with 2xx and a short text or JSON (up to 4 000 characters) that the agent reads back to the caller, for example {"booked": true, "confirmation": "Tuesday 18 November at 3 pm"}. A non-2xx answer tells the agent the action failed. Requests carry the Standard Webhooks headers, signed with the agent's own secret. The secret is not yet available through the API, so also protect the endpoint with a long random token in the URL. A complete example is in Recipes.
Ringless voicemail and voicemail drops#
Leave a recorded message in a customer's voicemail box. Scopes: rvm:read and rvm:write.
1. Create a message: upload a recording, or have the AI voice read a text.
# Upload a WAV or MP3 recording
curl -X POST "$LEXO_URL/api/v1/voicemail-messages" \
-H "Authorization: Bearer $LEXO_API_KEY" -F "name=Spring offer" -F "file=@offer.mp3"
# Or generate it from text with the AI voice
curl -X POST "$LEXO_URL/api/v1/voicemail-messages" \
-H "Authorization: Bearer $LEXO_API_KEY" -H "Content-Type: application/json" \
-d '{"name": "Cleaning reminder", "text": "Hi, this is Northwind Dental. Your cleaning is due; call us back at 415 555 0100."}'2. Send one voicemail:
curl -X POST "$LEXO_URL/api/v1/rvm/drops" \
-H "Authorization: Bearer $LEXO_API_KEY" -H "Content-Type: application/json" \
-d '{"phone": "+14155550142", "messageId": "7c1d2e3f-4a5b-4c6d-8e9f-0a1b2c3d4e5f", "method": "native", "humanAction": "hangup", "consentAttested": true}'method | How it is delivered |
|---|---|
native | ringless, through the company's own carriers (carrier voicemail deposit, or a double dial where the second call lands in voicemail) |
call | a normal call with answering machine detection; the message plays after the beep |
vendor | through a ringless voicemail vendor account (accountId) |
humanAction says what happens if a person answers: hangup, message (play humanMessageId) or transfer (to queueId). consentAttested: true confirms the recipient gave prior express consent; it is required. Do-not-call and blocked numbers are refused, and so are times outside 08:00–21:00 in the recipient's time zone.
The result arrives with the rvm.delivered or rvm.failed webhook and on GET /rvm/drops/{id}; GET /rvm/drops lists drops with counts per status. To send to a list, create a dialer campaign with mode: "voicemail".