API guide
Messaging
Send and receive SMS, WhatsApp, email and chat messages, work with conversations, attach files and use templates.
Channels and conversations#
LexoConnect's inbox is omnichannel: SMS and MMS, WhatsApp, email, the website chat widget, Facebook Messenger, Instagram, Telegram, Viber and LINE all land in conversations. A conversation is the thread with one customer address on one channel account (for example one SMS number or one support mailbox).
GET /omni/channels(scopemessages:read): the channel accounts the company can send from, with theirid,kindand address.GET /omni/conversations: conversations, filtered bystatus(open,pending,closed),channelor a searchq; paged withcursor.GET /omni/conversations/{id}/messages: the messages of one conversation.
Channel accounts are connected by the company's admins in the app (or by the platform operator for shared accounts); the API sends and reads through them.
Send a message#
POST /messages (scope messages:write) is the simplest way to send: give to and either a channel (the company's first enabled account of that kind is used) or a specific channelAccountId. LexoConnect reuses the open conversation with that address, or starts one.
curl -X POST "$LEXO_URL/api/v1/messages" \
-H "Authorization: Bearer $LEXO_API_KEY" -H "Content-Type: application/json" \
-d '{"channel": "sms", "to": "+12125550123", "body": "Your appointment is confirmed for 3 pm."}'Fields:
channel:sms,whatsapp,email,messenger,instagram,telegram,viberorline;channelAccountId: send from this exact account instead;subject: email only;recordId: link the conversation to a CRM record (otherwise LexoConnect links it by phone or email when it can);template: a WhatsApp template{"name": "...", "language": "en", "params": ["..."]}, required outside WhatsApp's 24-hour customer service window (GET /omni/channels/{id}/templateslists the approved templates);attachments: files uploaded first withPOST /omni/attachments(see below).
Delivery progress (sent, delivered, read, failed) arrives with the message.status webhook. Recipients who opted out on a channel (for example replied STOP to an SMS) are refused with 409 opted_out; Opt-out keywords (STOP, UNSUBSCRIBE, …), opt-in keywords (START, …) and HELP are answered automatically; the company can change the words and replies in the app.
Reply in a conversation#
curl -X POST "$LEXO_URL/api/v1/omni/conversations/CONVERSATION_ID/messages" \
-H "Authorization: Bearer $LEXO_API_KEY" -H "Content-Type: application/json" \
-d '{"body": "Thanks, we will call you tomorrow."}'POST /omni/conversations starts a new conversation from a given channelAccountId (same fields as POST /messages).
Assign, close, snooze and link#
PATCH /omni/conversations/{id} changes:
status:open,pendingorclosed;assigneeId: the user who owns the conversation (nullto unassign);snoozedUntil: hide the conversation until a time (RFC 3339); it comes back earlier if the customer replies;recordId: link it to a CRM record.
await lexo("PATCH", `/omni/conversations/${conversationId}`, { assigneeId: ana.id, status: "open" });Attachments#
Upload a file (at most 10 MB) as multipart/form-data, then send it:
curl -X POST "$LEXO_URL/api/v1/omni/attachments" \
-H "Authorization: Bearer $LEXO_API_KEY" -F "file=@invoice.pdf"The answer {url, name, mime, size} is what goes into attachments. MMS, WhatsApp and email accept attachments; other channels may not.
Receive messages#
Inbound messages are not polled: subscribe a webhook endpoint to message.received (and message.status for delivery updates). The event carries the conversation, the message, the channel and the sender. See Webhooks and the auto-reply recipe.
Your own channel (custom API channel)#
To connect a messaging network LexoConnect does not support, the company admin can add a Custom API channel in the app with the URL of your service. LexoConnect then:
- POSTs every outbound message to your URL as JSON
{conversationId, to, text, attachments}with the headersX-NovaComm-Timestamp(unix seconds) andX-NovaComm-Signature: sha256=<hex HMAC-SHA256(secret, timestamp + "." + body)>; - accepts inbound messages from your service on the webhook URL shown on the channel, signed the same way:
{"from": "...", "name": "...", "text": "...", "externalId": "..."}for a new message, or{"type": "status", "externalId": "...", "status": "delivered"}for a delivery update. The timestamp must be within a few minutes of LexoConnect's clock.
The header names keep the product's former name so that existing integrations keep working.