The REST API, the LemuTickets API, webhooks, SDKs, events and the MCP server.
Checked against LemuAI app version 1.0.53. The latest version is always at https://docs.lemuai.com. Plain-text copies for AI assistants: https://docs.lemuai.com/llms-developers.txt
API Trigger
API Trigger helps you trigger your Voice Agent using external systems, like N8n or Zapier
initial_context is a valid JSON object, which contains any contextual information that you would want your voice agent to access. You can refer to these values in your prompts using Handle Bars, which are values enclosed in {{ and }}.
Example: If you have below JSON as your initial_context
you can refer to the user name in your prompts as {{user.name}}. The keys of initial_context are added to the call's context directly, so you don't prefix them with initial_context.
Webhook
Webhook node allow you to sync the result of Voice Agent runs to your external systems, like CRM or to other workflow orchestrator like Zapier or n8n.
https://docs.lemuai.com/voice-agent/webhook
You can have multiple Webhook Nodes for a single Voice Agent, if you want to sync the result of the call at multiple places.
The payload can contain a valid JSON, and you can reference variables while constructing that payload. You can reference below variables while constructing the payload.
HTTP API tools allow you to attach extrernal REST API calls directly to workflow nodes, enabling your voice agents to call any internal or external system during live conversations based on LLM judgment and your prompts. This works similar to function calling on any agentic platform and is fully customizable.
All the tools that you have created will be available for selection in the node
Tools are only callable when attached to that node
The LLM will choose which one to call
Inside the node, guide the LLM using simple English instructions.
Example:
"If the user shows interest in speaking to sales or wants a callback, immediately call the capture_lead_interest tool and set interest to true."
This instruction is often the deciding factor for correct tool usage.
This instruction is often the deciding factor for correct tool usage.
Let AI assistants like Claude and Cursor use your Lemu AI voice agents through the Model Context Protocol
https://docs.lemuai.com/mcp/overview
Lemu AI runs a remote Model Context Protocol (MCP) server. Once you connect an AI assistant to it, the assistant can look up your voice agents, request phone calls with them, and read how those calls went, all from a normal chat.
Server address:
Text
https://mcp.lemuai.com/mcp
It uses the standard streamable HTTP transport, so any MCP client that supports remote servers with OAuth can connect.
An assistant never gets more access than a person in your organization gives it:
An admin approves every connection. When an assistant connects, you're sent to a Lemu AI consent screen. Only someone with admin rights in the organization can approve it.
You choose the permissions. Each connection gets only the permissions ticked on the consent screen, such as reading agents or requesting calls.
You choose the agents. For calls, you pick exactly which agents the assistant may use. Agents you create later are not added automatically.
Daily limits. Each connection has a cap on calls per day (at most 200), plus limits on concurrent and pending calls.
A person confirms every call. Calls an assistant requests wait for confirmation by someone in your organization before anything is dialed.
Your calling policy always applies. Who may be called, local calling hours, the do-not-call list and the AI disclosure are enforced by Lemu AI, whatever the assistant sends.
Everything is logged. Every request is recorded in an audit log.
Anything a person says on a call is returned to the assistant as data, never as an instruction.
Add the Lemu AI MCP server to Claude, Claude Code or Cursor and approve the connection
https://docs.lemuai.com/mcp/connect
Connecting takes two parts: you add the Lemu AI server to your assistant, then you approve the connection on a Lemu AI consent screen. There is no API key to copy. The assistant signs in with OAuth, the same way you'd connect it to any other service.
These steps follow each client's standard setup for remote MCP servers. The Lemu AI side (discovery, client registration and the consent screen) works with any client that supports MCP over OAuth. Menu names in third-party apps can change, so check your client's own docs if a step looks different.
Claude
In Claude, open Settings → Connectors.
Click Add custom connector.
Enter a name (for example Lemu AI) and the server address https://mcp.lemuai.com/mcp, then add it.
Click Connect. Claude opens the Lemu AI consent screen (see below).
On Claude Team and Enterprise plans, only an organization owner can add custom connectors. Ask your owner to add it, then each member connects it.
Claude Code
Run:
Shell
claude mcp add --transport http lemuai https://mcp.lemuai.com/mcp
Then start Claude Code, run /mcp, choose lemuai and authenticate. Your browser opens the Lemu AI consent screen.
Cursor
Add the server to your mcp.json (Cursor Settings → MCP → Add new MCP server, or ~/.cursor/mcp.json):
Your assistant sends you to app.lemuai.com/mcp/authorize. Sign in if asked, then review what the assistant is asking for.
Check who is asking
The screen shows the name the assistant gave itself and the address you'll be sent back to after approving. The name is chosen by the app, so only approve if you started this connection and recognise that address.
Choose the organization
If you're an admin in more than one organization, pick the one the assistant should work in.
Choose what it may do
Tick the permissions to grant, for example "See which voice agents you allow it to use" or "Request phone calls". See Permissions & limits for what each one allows.
Choose agents and a daily cap
If you allow calls, pick which agents it may use and the most calls per day (up to 200). Agents you create later are not included automatically.
Approve
Click Approve. You're sent back to the assistant and it can use Lemu AI right away.
Ask the assistant something like "Which Lemu AI agents can you use?" to check the connection.
The assistant renews its access automatically: access tokens last 1 hour and refresh on their own. A connection stays valid for up to 90 days, after which you approve it again.
Calls the assistant requests wait for a person in your organization to confirm them. See Call confirmation.
Remove Lemu AI from the assistant's connector or MCP settings. Assistants that support it revoke their access when you do.
Viewing and revoking connections from the Lemu AI dashboard isn't available yet. To cut off a connection immediately, contact support.
MCP Tools
Every tool the Lemu AI MCP server offers, the permission it needs and the arguments it takes
https://docs.lemuai.com/mcp/tools
Your assistant discovers these tools automatically when it connects, so you don't call them yourself. This page explains what each one does so you know what to ask for and what to approve.
A tool only works if the connection was granted its permission on the consent screen. See Permissions & limits.
Tool
Permission
What it does
list_agents
agents:read
Lists the agents this connection may use
get_agent
agents:read
Describes one agent and the details a call needs
start_call
calls:start
Requests an outbound call with an agent
get_call
calls:read
Status and outcome of one call
list_calls
calls:read
Recent calls made through this connection
cancel_call
calls:cancel
Cancels a call that hasn't been dialed
create_agent_draft
agents:write
Drafts a new agent from a brief
update_agent_draft
agents:write
Changes a draft it made
test_agent
agents:write
Reviews a draft before it can go live
archive_agent
agents:write
Retires an agent it made
search_docs
none
Searches the LemuAI docs (how-tos, settings, error messages)
search_docs and read_doc read the public docs at docs.lemuai.com, so every connection has them, whatever its permissions. An assistant uses them to explain how to do something in LemuAI or what an error means while it works in your workspace.
Lists the voice agents this connection may use: the agents you ticked on the consent screen. Takes no arguments. Each agent comes back with its agent_id, name and the context variables a call can fill in.
Requests an outbound phone call with an agent. It returns straight away with a call_id. The call then waits for a person in your organization to confirm it (see Call confirmation) before it's dialed. Read the outcome with get_call.
Argument
Type
Required
Description
agent_id
integer
Yes
The id from list_agents
phone_number
string
Yes
Who to call, in international format, like +919876543210
counterparty_class
string
Yes
Who this person is to your organization: employee, customer, distributor, supervisor, prospect or other. Your calling policy decides which are allowed
idempotency_key
string
Yes
A unique key for this call, 8 to 120 letters, digits or _ . : -. Retrying with the same key returns the original call and never dials twice
context
object
No
Values for the agent's context variables (see get_agent), up to 30
callee_timezone
string
No
IANA timezone like America/Chicago. Only needed for countries that span several timezones
correlation
object
No
Your own ids (for example a ticket number), kept in the audit log next to the call
Result webhooks (callback_url) are not available for assistant connections. Assistants read results with get_call.
The call is checked against the connection's limits and your organization's calling policy before it's accepted. If something is wrong, the tool returns an error code such as OUTSIDE_CALLING_HOURS. See Error codes.
Cancels a call that hasn't been dialed yet, for example one still waiting for confirmation. A call that is already ringing or live can't be cancelled this way.
With the agents:write permission, an assistant can write a new voice agent from a short brief. Lemu AI writes the agent's script from the brief and adds fixed safeguards the brief can't remove. A connection can create at most 5 agents a day.
Agents made over MCP are drafts. They can't place calls until they're published, and publishing isn't available to assistant connections. To publish a draft an assistant made, contact support.
Changes a draft this connection made. Send the draft_version you last read. If the draft has changed since, the update is refused with STALE_DRAFT so nothing is overwritten.
Reviews the draft as it will run: safeguards present, nothing forbidden, only declared context used. A draft needs a passed review of its exact version before it can be published.
Retires an agent this connection made. Calls already in progress finish normally.
Argument
Type
Required
Description
agent_id
integer
Yes
The agent to archive
Permissions & Limits
What each MCP permission allows, how calls are confirmed, the calling policy and the error codes assistants can get
https://docs.lemuai.com/mcp/permissions
Every assistant connection is limited to what an admin approved on the consent screen, and Lemu AI enforces those limits on every request, whatever the assistant sends.
These are the permissions (OAuth scopes) an assistant can ask for. The consent screen lists the ones it asked for, and you can untick any of them before approving. An assistant that doesn't ask for specific permissions gets agents:read and calls:read.
Scope
On the consent screen
Allows
agents:read
See which voice agents you allow it to use
list_agents, get_agent
calls:read
Read the status and outcome of calls it places
get_call, list_calls
calls:transcripts:read
Read call transcripts (may contain personal data)
A transcript link in get_call
calls:start
Request phone calls (a person in your organization confirms each one)
start_call
calls:cancel
Cancel calls that have not been dialed yet
cancel_call
agents:write
Create and edit draft voice agents (it cannot publish them)
Every call an assistant requests is created with the status pending_confirmation. Nothing is dialed until a person in your organization confirms it. If they decline, the call becomes rejected. When a call is confirmed, the calling policy and limits are checked again, since time may have passed since the request.
Confirming or declining assistant calls from the Lemu AI dashboard isn't available yet. Until it is, calls requested by an assistant stay in pending_confirmation. Contact support if you need to confirm calls now. The assistant can cancel its own pending calls with cancel_call.
Your organization's calling policy applies to every call an assistant requests:
Who may be called. Each call says who the person is: employee, customer, distributor, supervisor, prospect or other. Only classes the policy allows can be called. By default, a prospect can be called at most twice in total (one call and one follow-up).
Calling hours. Calls are only placed inside the allowed hours in the callee's local time. Lemu AI works out the timezone from the phone number. For countries that span several timezones (like the US), the assistant must pass callee_timezone.
Do not call. People who asked not to be called, are on your do-not-call list, or opted out of calls (or of everything) on their contact in Lemu AI are never called.
AI disclosure. The agent must tell the person they're talking to an AI. Its opening greeting needs to include the {{ai_disclosure}} variable, which Lemu AI replaces with your organization's wording.
Until your organization sets its own policy, a default applies: only employees and supervisors can be called, between 09:00 and 20:00 local time, every day, with the AI disclosure on.
Changing the calling policy or the do-not-call list from the dashboard isn't available yet. Contact support to change them.
Every request an assistant makes is recorded: which connection, which tool, the outcome, the call it touched and how long it took. Arguments are stored as a fingerprint, not in full, and phone numbers are masked. If you need a copy of the log for a connection, contact support.
Standard and conversion events
The event names Lemu recognises, the fields an order needs (value, currency and order_id), and how revenue and ROI are calculated
Lemu uses Meta Pixel's standard events exactly as Meta defines them: the same names and the same parameters. If your site or app already sends events to Meta, you can send the same calls to Lemu unchanged. The same names work everywhere: the website snippet, the app SDKs, the Send an Event API and Shopify.
Only conversion events have required fields. By default that is Purchase, because journey and campaign revenue and ROI are calculated from it. Every other event is free-form.
A page loaded. The website snippet sends it for you
ViewContent
A product or other key page was viewed
content_ids, content_category, content_name, content_type, contents, currency, value
Search
A search
search_string, content_category, content_ids, contents, currency, value
AddToCart
An item was added to the cart
content_ids, content_name, content_type, contents, currency, value
AddToWishlist
An item was added to a wishlist
content_ids, content_name, content_category, contents, currency, value
InitiateCheckout
Checkout started
content_ids, content_category, contents, currency, num_items, value
AddPaymentInfo
Payment details were entered
content_ids, content_category, contents, currency, value
Purchase
An order was placed
value and currency (required by Meta), content_ids, content_name, content_type, contents, num_items, plus order_id for Lemu
Lead
A lead was submitted
content_category, content_name, currency, value
CompleteRegistration
A sign-up was completed
content_name, currency, status, value
Subscribe
A paid subscription started
currency, predicted_ltv, value
StartTrial
A free trial started
currency, predicted_ltv, value
Schedule
An appointment was booked
SubmitApplication
An application was submitted
Contact
Someone contacted your business
CustomizeProduct
A product was customised
Donate
A donation
FindLocation
Someone searched for a store location
What the parameters mean:
Parameter
Type
Meaning
value
number
An amount in major units: 1499.5 is ₹1,499.50
currency
string
An ISO 4217 code such as INR
content_ids
list of strings
Product ids or SKUs
contents
list of objects
Items, each with id and quantity, and optionally item_price, title, brand and category
content_type
string
product or product_group
content_name, content_category
string
A name and a category
num_items
integer
The number of items
search_string
string
What was searched for
predicted_ltv
number
The expected lifetime value of a subscriber
status
string
The status of a registration
You can add your own parameters next to these, for example payment_method: "cod" or coupon. For Meta's full definitions, see Meta's standard events reference.
Matching a Meta name ignores case and separators. purchase, PURCHASE and Purchase are all stored as Purchase, and add_to_cart, Add To Cart and AddToCart are all stored as AddToCart.
A name that doesn't match one of Meta's events is a custom event. Custom events are allowed everywhere and are never renamed, rejected or reshaped. Personal data is still removed from their properties.
// Already on your site for Meta:fbq("track", "Purchase", { value: 1499.5, currency: "INR", content_ids: ["SKU1"], content_type: "product" });// The same call for Lemu, plus order_id:lemu("track", "Purchase", { value: 1499.5, currency: "INR", content_ids: ["SKU1"], content_type: "product", order_id: "1042" });
For purchases you can also use lemu("purchase", { value, currency, order_id }), which sends the event straight away.
Lemu counts one conversion per order. The same order is often reported more than once: by your website, by your app, by Shopify (from both the storefront and the store's order webhook), by your server, or by a reload of the thank-you page. With order_id, all of these count as one order, so revenue isn't counted twice. Without it, every Purchase event counts as its own order.
Meta's Conversions API has the same field, so your order id fits both. Use the same order id your store and backend use.
A conversion event is an event that counts as an order for revenue and ROI. The list is set under Settings → Sending Limits → Conversion events. The default is Purchase. You can add others, such as Lead, Subscribe, Schedule, or one of your own custom events. See Sending Limits.
A conversion event is never rejected for a missing or wrong field. A missing field never drops an order. Instead Lemu does the following, and counts it:
Problem
What Lemu does
value is text, such as "1,499.00"
Converts it to a number
value is missing, but an older field such as total_price or total has the amount
Uses that field
value is missing, isn't a number, or is negative
Counts the order with no revenue
currency is missing or isn't an ISO code
Uses your workspace currency
order_id is missing, but an older field such as order_number has it
Uses that field
order_id is missing
Counts the order, but the same order sent twice counts twice
You can see these counts in two places:
Settings → Sending Limits, under Conversion events: how many conversion events arrived in the last 30 days, and how many had each problem.
The Recent events debugger on each tracking source: each conversion event, marked Conversion, with what was missing or fixed.
Events that aren't conversion events go through none of these checks.
An order is credited to the last journey or campaign message the contact got, if that message came within the channel's attribution window. See Sending Limits.
Revenue is the total value of the credited orders, per currency.
Message spend is what the messages cost in money: WhatsApp charges from your WhatsApp wallet. Email (paid in credits) and calls (paid in plan minutes) are not priced, so they don't add to spend.
ROI is revenue divided by message spend. 3.5x means 3.5 back for each 1 spent. When there was no message spend in the period, ROI shows –.
A few details:
Orders that arrived without a value count as orders but add nothing to revenue. Reports say how many there were, so a low ROI caused by missing data isn't mistaken for a poor journey.
ROI uses revenue in the same currency as the spend. Revenue in other currencies is shown but left out of the ratio.
ROI is shown on each journey's report, on marketing campaigns and on the Copilot home in the AI Copilot.
Before standard events, Lemu's website pixel and Shopify connection used their own names. These old names still match their Meta event everywhere you name an event: journey triggers, exit events, Wait for reaction, segments, the Event Log filter and Conversion events. A journey on Purchase also starts for an event sent as order_placed, and the other way round.
Old name
Matches
order_placed, checkout_completed
Purchase
cart_added, checkout_started
InitiateCheckout
added_to_cart
AddToCart
viewed_product
ViewContent
page_viewed
PageView
searched
Search
checkout_payment_submitted
AddPaymentInfo
cart_added matches InitiateCheckout, not AddToCart, because it was always sent when a shopper started checkout.
Saved journeys, segments and the Conversion events setting that used these old names were renamed to the Meta names for you. Events you sent before keep the name they were stored with, and still match. Your own custom event names were not changed.
A purchase sent from a browser or an app can be lost: the app is closed right after payment, or an ad blocker stops the script. For the most reliable revenue and ROI, also send Purchase from your backend with the Send an Event API:
Keep sending it from your site or app as well. With the same order_id, both count as one order. Shopify stores already send orders from the store's order webhook (see Shopify).
SDKs
Send events, purchases and known users to Lemu from your website, JavaScript and React apps, and your Android, iOS, Flutter and React Native apps
https://docs.lemuai.com/sdks/overview
Setup required: the SDK packages (@lemuai/analytics, @lemuai/react, @lemuai/react-native, com.lemuai:analytics, LemuAnalytics and lemu_analytics) are rolling out. If a package isn't available yet, contact LemuAI support for access. The website snippet needs no package.
The Lemu SDKs send what people do on your website and in your apps to Lemu: page and screen views, Meta's standard events such as AddToCart and Purchase, and identify for people you know. Lemu uses these events for contact activity and segments, to start journeys, and to calculate the revenue and ROI of your journeys and campaigns.
In Lemu, open Settings → Tracking Sources. Under Add a tracking source, choose Website for a website or a JavaScript, React or Next.js app. Choose App for an Android, iOS, Flutter or React Native app.
Name it
Give it a Name, for example "Main store" or "Android and iOS app". You can list the Allowed sites or Allowed apps now or later. Then click Create.
Copy the write key
On the new source, under Set up, copy the write key. It starts with lpk_.
Under Set up, the source also shows install and setup code for each platform with your key filled in: Any website and React / Next.js on a website source, and Android, iOS, Flutter and React Native on an app source.
The write key is public by design and safe to ship in your site or app: it can only send events, never read anything. One app source can serve the same app on every platform, for example your Android and iOS builds. Create a separate source for each environment, such as staging, so test events stay apart.
Send every order with purchase, with three fields:
value: the order total, in major units (1499.5 is ₹1,499.50).
currency: an ISO 4217 code such as INR.
the order id (order_id in JavaScript, orderId on Android, iOS and Flutter): the same id your store and backend use.
Lemu counts one conversion per order id, however many times the order is reported: by your app, your website, Shopify or your server. Without it, every report counts as a separate sale. See Conversion events for what Lemu does when a field is missing, and send purchases from your server too for the most reliable numbers.
Call identify when someone signs up or logs in, with your own user id and their contact details (email, phone in international format such as +919876543210, first_name, last_name). The user id is sent with every later event until reset.
An identify with an email or a phone finds the matching contact, or creates one.
An identify with only your user id links to an existing contact with that id. It never creates one.
Before identify, a visitor or install is anonymous and isn't a contact. Once they identify, their earlier anonymous activity shows up on the contact.
Contact details belong in identify only. Lemu removes keys such as email, phone and address from event properties.
To let tracked actions from identified people start journeys, switch on Let identified visitors' tracked actions trigger journeys on the source. See Trigger journeys.
If you need consent before tracking, for example under GDPR or the DPDP Act, start the SDK with requireConsent and call setConsent(true) once the person agrees.
Until consent, nothing is sent and nothing is stored on the device, not even the anonymous id. Up to 50 events wait in memory and are sent once consent is given.
setConsent(false) discards the waiting and queued events. A granted consent is remembered (in the browser, across visits; in an app, across launches) until setConsent(false).
optOut() stops all tracking and clears the queue, and is remembered. optIn() turns tracking back on.
Every second or every 10 events, and when the page is hidden
Every 30 seconds or every 20 events, when the app goes to the background, and right after a purchase
If sending fails
Retried with increasing waits, up to 5 minutes apart, while the page is open
Kept on the device, also across restarts, and retried with increasing waits, up to 5 minutes apart, for up to 20 hours
Queue
Up to 1,000 events, in memory
Up to 1,000 events, for up to 7 days. When it's full, the oldest event that isn't a purchase is dropped first
Each request carries up to 50 events. The same event received twice within 24 hours is recorded once, so retries never double count. See Limits and duplicates.
The SDKs never throw into your code. A bad argument, such as an empty event name, is ignored and logged in debug mode.
The SDKs collect a random anonymous id for each browser or app install, the events and properties your code sends, the user id and traits you pass to identify, and basic app and device details such as the app version, OS version, device model, locale and time zone. They collect no advertising ids (IDFA, GAID) and no hardware ids.
Start the SDK with debug on. It logs every call, request and response.
Send an event
Open your site or app and do something you track, or call flush() to send straight away.
Look in Lemu
In Settings → Tracking Sources, the source shows when the last event arrived. Under Recent events, click Show recent events to see the last 50 events from the past hour as Lemu stored them, then Refresh for new ones. See Recent events.
Add Lemu to any website with the snippet, or to a JavaScript app with the @lemuai/analytics package: page views, events, purchases, known users and consent
https://docs.lemuai.com/sdks/javascript
The same script powers the website snippet and the @lemuai/analytics npm package. It has no dependencies, is about 5.5 KB gzipped, and is safe to import during server-side rendering.
Use the snippet on any website, including Shopify themes, WordPress and site builders.
Use the package in a JavaScript or TypeScript app built with a bundler.
For React and Next.js, use @lemuai/react, which is built on this package.
You need the write key of a Website source. See Get a write key.
Copy the snippet from your source (Settings → Tracking Sources, the Any website tab under Set up) and paste it into the <head> of every page. It loads the script, starts it with your key and records a page view:
HTML
<script> !function(w,d){w.lemu=w.lemu||function(){(w.lemu.q=w.lemu.q||[]).push(arguments)}; var s=d.createElement("script");s.async=1;s.src="https://app.lemuai.com/api/v1/pixel/sdk.js"; d.head.appendChild(s)}(window,document); lemu("init", "YOUR_WRITE_KEY"); lemu("page");</script>
With the snippet, call every method by name, for example lemu("track", "AddToCart", { value: 999, currency: "INR" }). Calls made before the script has loaded are kept and run once it arrives.
Use Meta's standard event names for standard actions, such as ViewContent, AddToCart and InitiateCheckout. With the package, use the LemuEvent constants. Any other name works as a custom event.
purchase sends a Purchase event at once, without waiting for the next batch, so it isn't lost if the visitor closes the tab.
value, currency and order_id are required. Lemu counts one conversion per order_id, so the same order reported by this page, a reload of the page, Shopify or your server counts once. Lemu never rejects an event for a missing field, but it flags the conversion. See Conversion events.
Call identify when the visitor signs up, logs in or fills a form, with your own user id and their contact details:
JavaScript
lemu.identify("crm-123", { email: "asha@example.com", phone: "+919876543210", first_name: "Asha",});// without your own idlemu.identify({ email: "asha@example.com" });// on logoutlemu.reset();
With the snippet, the same calls are lemu("identify", "crm-123", { ... }) and lemu("reset").
The user id is kept and sent with every later event until reset, which also gives the visitor a new anonymous id. See Identify visitors for how Lemu matches contacts.
With the snippet, pass options as the third argument: lemu("init", "YOUR_WRITE_KEY", { trackPageChanges: true }).
UTM parameters (utm_source, utm_medium, utm_campaign, utm_term, utm_content) and gclid / fbclid on the landing page are kept with the visitor's events. Personal data in page URLs, such as ?email=, is removed.
If you need consent before tracking, for example after your cookie banner, start with requireConsent:
JavaScript
lemu.init("YOUR_WRITE_KEY", { requireConsent: true });// later, from your consent bannerlemu.setConsent(true); // snippet: lemu("consent", true)
Until consent, nothing is sent and nothing is written to cookies or local storage, not even the visitor id. Up to 50 events wait in memory and are sent once consent is given.
setConsent(false) discards them. A granted consent is remembered in local storage (_lemu_consent), so returning visitors aren't asked again. setConsent(false) forgets it.
optOut() stops all tracking and clears the queue. It is remembered in a cookie and in local storage. optIn() undoes it.
Every call, request and response is logged to the browser console with a [lemu] prefix. Bad arguments, such as an empty event name or properties that can't be turned into JSON, are logged and ignored. The script never throws into your code.
If the console shows a refused request, check that your site is listed under Allowed sites on the source.
Events are batched and sent every second or every 10 events, and with sendBeacon when the page is hidden, so events from the last page aren't lost. Requests are sent as plain text, so the browser makes no extra CORS request first. Failed requests are retried with increasing waits.
The visitor id lives in the _lemu_aid first-party cookie and in local storage, so returning visitors keep the same id.
React and Next.js
Add Lemu to a React or Next.js app with @lemuai/react: a provider, the useLemu hook and page tracking for React Router and the Next.js routers
https://docs.lemuai.com/sdks/react
@lemuai/react adds Lemu to React and Next.js apps: a provider, a hook to send events from any component, and page tracking for React Router and both Next.js routers. It's built on @lemuai/analytics and is safe with server-side rendering: nothing touches window during render, and calls made on the server do nothing.
You need the write key of a Website source. See Get a write key. The source's React / Next.js tab under Set up shows the code below with your key filled in.
purchase sends a Purchase event at once. Always pass your real order id: Lemu counts one conversion per order_id, however many sources report the order (this page, a webhook, a reload of the thank-you page). See Conversion events.
const lemu = useLemu();// after sign-up or loginlemu.identify(user.id, { email: user.email, phone: user.phone, first_name: user.firstName });// on logoutlemu.reset();
The user id is kept and sent with every later event until reset. Send phone numbers in international format, for example +919876543210. Contact details belong in identify only.
To wait for consent, pass requireConsent to the provider and call setConsent(true) from your consent banner:
TSX
<LemuProvider writeKey="YOUR_WRITE_KEY" options={{ requireConsent: true }}> <App /></LemuProvider>// in your consent bannerconst lemu = useLemu();lemu.setConsent(true);
Nothing is sent or stored until then. lemu.optOut() and lemu.optIn() turn tracking off and on, remembered in the browser. See Consent and opt-out for the details.
Add Lemu to a React Native or Expo app with @lemuai/react-native: events, purchases, known users, screens, app installs and opens, and deep links
https://docs.lemuai.com/sdks/react-native
@lemuai/react-native sends events, purchases, known users and screens from your React Native or Expo app, and records installs, app opens and the deep links that bring people in. It's pure JavaScript with no native module of its own, so it works in Expo Go and in bare React Native apps.
You need the write key of an App source. See Get a write key.
npm install @lemuai/react-native @react-native-async-storage/async-storage# optional, for the app version, bundle id and device model:npm install react-native-device-info
Call init once, as early as possible, for example in index.js or your root component:
TSX
import { lemu } from "@lemuai/react-native";lemu.init("lpk_...");
Calls made before storage has loaded are kept and sent in order.
Without react-native-device-info, for example in Expo Go, pass the app version, build and id yourself:
TSX
import * as Application from "expo-application";import { lemu } from "@lemuai/react-native";lemu.init("lpk_...", { appVersion: Application.nativeApplicationVersion ?? undefined, appBuild: Application.nativeBuildVersion ?? undefined, appNamespace: "com.brand.app",});
If the source lists Allowed apps, Lemu refuses events that don't carry an allowed app id. The SDK reads the id from react-native-device-info. Without that package, set appNamespace to your bundle id or package name, or leave Allowed apps empty.
purchase sends a Purchase event and sends the queue right away. Always pass the order id your backend uses: the same order is often reported by the app, your backend and your payment provider, and Lemu counts one conversion per order_id. See Conversion events.
Screens aren't tracked automatically. Send one yourself:
TSX
lemu.screen("Checkout", { step: 2 });
Or record every route change in React Navigation:
TSX
import { NavigationContainer, useNavigationContainerRef } from "@react-navigation/native";import { useLemuNavigationTracking } from "@lemuai/react-native";export function App() { const navigationRef = useNavigationContainerRef(); useLemuNavigationTracking(navigationRef); return <NavigationContainer ref={navigationRef}>{/* screens */}</NavigationContainer>;}
Outside a component, trackNavigationState(navigationRef) does the same and returns a function that stops it. Only the route name is sent, not route params, because params can hold personal data. Screens are stored as screen_viewed.
from_background, and url when a link opened the app
app_backgrounded
The app goes to the background. Queued events are sent then too
deep_link_opened
A link opens the app or arrives while it runs
url, referrer
UTM parameters (utm_source, utm_medium, utm_campaign, utm_term, utm_content) and gclid / fbclid in a deep link are kept with that event and every later event in the session, so Lemu can credit what happens next, such as a purchase, to the campaign.
Turn these off with trackLifecycle: false and trackDeepLinks: false.
Events are kept in AsyncStorage (or the storage you pass) and survive restarts. They are sent every 30 seconds, every 20 events, when the app goes to the background, and right after a purchase. Failed requests are retried with increasing waits, up to 5 minutes apart. At most 1,000 events are kept; when the queue is full, the oldest event that isn't a purchase is dropped. Events older than 7 days are dropped.
Requests carry a User-Agent such as lemu-react-native/1.0.0 (iOS 17.4; iPhone15,2). No advertising ids or hardware ids are collected. For app store forms, the SDK collects the same data as the native SDKs, so the answers under Google Play data safety and App Privacy answers in App Store Connect apply.
Android
Add Lemu to an Android app in Kotlin or Java: events, purchases, known users, screens, installs, deep links and the Play install referrer
https://docs.lemuai.com/sdks/android
The Android SDK sends events, purchases, known users and screens from your app, and records installs, app opens and the links and Play Store campaigns that bring people in.
Kotlin, and works from Java. Android 5.0 (API 21) or later.
One small AndroidX dependency (androidx.lifecycle:lifecycle-process). No OkHttp, Retrofit or Gson, so nothing clashes with your app's versions.
Events are kept on disk, batched, and retried when the network is back.
No advertising id and no hardware ids.
You need the write key of an App source. See Get a write key.
The SDK is on Maven Central. In your app module's build.gradle.kts:
kotlin
dependencies { implementation("com.lemuai:analytics:1.0.0") // Optional: attribute installs to the Play Store campaign that brought the user. implementation("com.android.installreferrer:installreferrer:2.2")}
Make sure mavenCentral() is in your repositories. It is by default in new projects.
If your app runs code in more than one process, call setup in the main process only.
If the source lists Allowed apps, add your app's package name (its applicationId). Builds with an applicationIdSuffix, such as com.brand.app.debug, send that id, so add it too or use a separate source for testing.
Lemu.track(LemuEvent.ADD_TO_CART, mapOf( "value" to 999, "currency" to "INR", "content_ids" to listOf("SKU1"), "content_type" to "product",))Lemu.track("coupon_applied", mapOf("code" to "DIWALI10"))
Any event name works. For Meta's standard events, use the LemuEvent constants (VIEW_CONTENT, ADD_TO_CART, INITIATE_CHECKOUT, PURCHASE and the rest) so the names match exactly. See the event reference.
Keep contact details such as email, phone and address out of event properties. Lemu removes them. Send them with identify instead.
purchase sends a Purchase event straight away instead of waiting for the next batch. value, currency and orderId are what Lemu calculates journey and campaign revenue and ROI from.
Always pass orderId. The same order is often reported by the app, your website, Shopify or your server. Lemu counts one conversion per order id, so use the same id your backend and store use. Without it, every report counts as a separate sale. The app can be closed right after payment, so for the most reliable numbers send purchases from your server too. With the same order id, both count once.
With debug on, track("Purchase", ...) without value, currency or order_id logs a warning. The event is still sent.
Screens are stored as screen_viewed and aren't tracked automatically. To send one each time an activity starts, set trackActivityScreens = true, or register the tracker yourself to choose the names:
Links that start an activity (ACTION_VIEW with a URL) are recorded as deep_link_opened with the url and referrer. UTM parameters (utm_source, utm_medium, utm_campaign, utm_term, utm_content) and gclid / fbclid in the link become the campaign for this and later events in the session, so a purchase made after tapping a campaign link is credited to that campaign.
Links delivered to an activity that is already running arrive in onNewIntent, which the SDK can't see. Record those yourself:
kotlin
override fun onNewIntent(intent: Intent) { super.onNewIntent(intent) setIntent(intent) Lemu.trackDeepLink(intent)}
With com.android.installreferrer:installreferrer in your app (see Install), the SDK reads the Play install referrer on the first launch. The campaign the user arrived with, for example from a Google Ads or Meta app campaign link to the Play Store, is added to app_installed and the rest of that first session. app_installed waits up to 10 seconds for the referrer. Without the library this is skipped. Set collectInstallReferrer = false to turn it off.
If you need consent before tracking, for example under GDPR or the DPDP Act:
kotlin
Lemu.setup(this, "lpk_...", LemuOptions(requireConsent = true))// later, from your consent screenLemu.setConsent(true) // sends what was held and starts trackingLemu.setConsent(false) // discards held and queued events
Until consent, nothing is sent and nothing is written to the device, not even the anonymous id. Up to 50 events wait in memory and are sent once consent is given. A granted consent is remembered across launches; call setConsent(false) if the user withdraws it.
To let users switch tracking off entirely:
kotlin
Lemu.optOut() // stops everything, clears queued events, remembered across launchesLemu.optIn() // turns it back on
Every call, request body and server response is logged to Logcat with the tag Lemu. Use it during development only, because event properties and traits appear in the log. A refused request (an unknown write key, or an app that isn't in Allowed apps) is logged too.
Events are sent in batches of up to 50: every 30 seconds, when 20 are queued, when the app goes to the background, and right after a purchase. Lemu.flush() sends now.
Events are stored in the app's no-backup files directory, so they survive restarts and aren't copied to other devices by Auto Backup. At most 1,000 are kept; when full, the oldest are dropped first, purchases last. Events older than 7 days are dropped.
Failed requests are retried with increasing waits, up to 5 minutes apart, for up to 20 hours. Refused batches are dropped and logged in debug mode.
The SDK never throws into your app. A bad argument is logged in debug mode and ignored.
The SDK ships its own ProGuard and R8 rules, so you don't need to add any.
Your answers depend on how you use the SDK. With the SDK alone, this is what it collects and sends to Lemu:
Play data type
Collected
When
Purpose
Device or other IDs
Yes
Always: a random anonymous id created by the SDK for this install (not an advertising id or a hardware id)
Analytics
App activity: App interactions
Yes
Always: lifecycle events, screens and the events you track
Analytics
App activity: Other actions
If you track them
Searches, sign-ups and other custom events
Analytics
Financial info: Purchase history
If you send purchases
Order value, currency, order id, items
Analytics
Personal info: User IDs
If you call identify with a user id
Your own user id
Analytics, App functionality
Personal info: Name, Email address, Phone number
If you pass them to identify
The traits you send
Analytics, and Advertising or marketing if you message users from Lemu
Also sent with every event, and not a Play data type: app name, version, build and package name; device manufacturer, model and type; Android version; screen size and density; locale and time zone; the link that opened the app and its campaign parameters.
Not collected: advertising id (GAID), Android ID, IMEI, serial number, MAC address, location, contacts, photos, files and crash logs.
Is data encrypted in transit? Yes, it is sent over HTTPS.
Is data shared? Lemu processes it as your service provider. Under Play's definitions, that isn't sharing. If you forward conversions to an ad platform, that is.
Is collection optional? Yes, if you use requireConsent or offer optOut().
Add Lemu to an iOS or tvOS app in Swift or Objective-C: events, purchases, known users, screens, app opens, deep links and App Store privacy answers
https://docs.lemuai.com/sdks/ios
The iOS SDK (LemuAnalytics) sends events, purchases, known users and screens from your iOS or tvOS app, and records app opens and the deep links that bring people in.
iOS 13 or later, tvOS 13 or later. Swift and Objective-C.
No third-party dependencies.
No advertising identifier (IDFA), no IDFV, and no AdSupport or App Tracking Transparency.
Events are kept on disk and sent in batches, so nothing is lost offline.
You need the write key of an App source. See Get a write key.
Every Lemu method can be called from any thread, and none of them throws. A bad argument, such as an empty event name or a value JSON can't hold, is skipped and logged when debug is on.
If the source lists Allowed apps, add your app's bundle identifier, for example com.brand.app. Events from any other bundle id are refused.
Any event name works. For Meta's standard events, use the LemuEvent constants (viewContent, addToCart, initiateCheckout, purchase and the rest) so the names match exactly. If you already send these events to Meta, the same properties work here. See the event reference.
Keep contact details out of event properties. Lemu removes keys such as email, phone, address and password; send contact details with identify instead.
purchase sends a Purchase event straight away instead of waiting for the next batch. content_ids and num_items are filled in from contents when you don't pass them.
Always pass orderId. Lemu counts one conversion per order. The same order is often reported more than once: by the app, your website, a Shopify webhook, or the app again after a retry. With the order id these count as one order, so journey and campaign revenue isn't counted twice. value and currency are needed to show revenue at all. See Conversion events.
userId is your own id for the customer. It's stored and sent with every later event until reset(). Send phone numbers in international format. On logout:
swift
Lemu.reset() // new anonymous id, user id cleared
Lemu.anonymousId returns the id Lemu uses for this install, for example to pass to your backend so server-side events join up with the app's.
Turn on automatic screen tracking (it's off by default):
swift
Lemu.enableAutomaticScreenTracking()
Each of your view controllers sends a screen when it appears, named after its class without the ViewController suffix (CheckoutViewController becomes Checkout). Navigation, tab bar, split and page controllers, Apple's own controllers, SwiftUI hosting controllers and child controllers embedded in your own are skipped. To rename a screen, or skip one:
swift
extension CheckoutViewController: LemuScreenNameProviding { var lemuScreenName: String? { "Checkout" } // return nil to send nothing}
Pass every URL that opens the app to trackDeepLink. It sends deep_link_opened with the url, and keeps utm_source, utm_medium, utm_campaign, utm_term, utm_content, gclid and fbclid with this and every later event in the session, so a purchase made after tapping a campaign link is credited to that campaign.
For a cold launch from a link with scenes, also pass the URLs in scene(_:willConnectTo:options:) (connectionOptions.urlContexts and connectionOptions.userActivities). The next app_opened carries the link as url.
Sent for you unless you set trackLifecycle: false:
Event
When
Properties
app_installed
First launch with the SDK
version, build
app_updated
First launch after the version or build changed
version, build, previous_version, previous_build
app_opened
Every time the app comes to the foreground
from_background, and url when a link opened the app
app_backgrounded
The app goes to the background
If your app had users before you added the SDK, each of them sends app_installed once after updating, because the SDK has no record of an earlier version.
If you must ask before collecting data, start with requireConsent:
swift
Lemu.setup(writeKey: "lpk_...", options: LemuOptions(requireConsent: true))// later, from your consent promptLemu.setConsent(true) // sends events held since launch, and remembers the answerLemu.setConsent(false) // discards held and queued events
Until consent, nothing is sent and nothing is written to the device, not even the anonymous id. Up to 50 events are held in memory and sent if consent is given. A granted consent is remembered across launches; call setConsent(false) to withdraw it.
To let people turn tracking off in your settings screen:
swift
Lemu.optOut() // stops everything, clears the queue, remembered across launchesLemu.optIn() // turns it back onLemu.isOptedOut
Every call, request body and response is logged with os_log under the subsystem com.lemuai.analytics. Watch it in the Xcode console, or in Console.app filtered by that subsystem. Turn debug off in release builds.
Events are kept in Application Support/Lemu, excluded from iCloud and device backups, and survive restarts.
They are sent every 30 seconds, when 20 are queued, when the app goes to the background, and right after a purchase. Lemu.flush() sends now.
Each request carries up to 50 events. Failed requests are retried with increasing waits, up to 5 minutes apart, for up to 20 hours. Events older than 7 days are dropped.
The queue holds at most 1,000 events. When it's full, the oldest event that isn't a purchase is dropped first.
The SDK ships its own privacy manifest (PrivacyInfo.xcprivacy, in the package and in the CocoaPods resource bundle LemuAnalyticsPrivacy). Xcode adds it to your app's privacy report. It declares:
NSPrivacyTracking: false, with no tracking domains.
Required reason API: UserDefaults, reason CA92.1. The SDK keeps its anonymous id, user id, opt-out, consent and the last app version in its own UserDefaults suite.
Collected data, all linked to the user and none used for tracking:
Data type
Why it's collected
Purposes
User ID
The anonymous install id, and your userId from identify
Your app's privacy label covers all the data your app collects, including through Lemu. For the data that goes to Lemu:
Data used to track you: No. Lemu doesn't use advertising identifiers, doesn't share data with data brokers, and doesn't link your app's data with other companies' data for advertising. See the note below if you forward data to ad networks.
Data linked to you, for each type you actually send:
Contact Info > Email Address, Phone Number, Name: if you call identify with them.
Identifiers > User ID: yes. The SDK always sends an anonymous id, plus your own user id.
Purchases > Purchase History: if you call purchase() or send commerce events.
Usage Data > Product Interaction: yes (app opens, screens, events).
Usage Data > Other Usage Data: if you send custom events.
Purposes:Analytics, plus Developer's Advertising or Marketing if you message these customers through Lemu journeys or campaigns. Add App Functionality if your app relies on Lemu data to work.
Not collected by the SDK: location, device ids (IDFA or IDFV), diagnostics, contacts, health, financial info, browsing history, and search history unless you send search terms as events (then also declare Search History).
Forwarding to ad networks. If you send Lemu events to an advertising platform, for example through a Meta Conversions API connection, Apple counts that as tracking. Then answer "Data used to track you: Yes" for the shared types, ask permission with App Tracking Transparency first, and only call identify with an email or phone after the user allows it.
Android and iOS need no extra setup. On macOS, apps are sandboxed and need permission to make network requests. Add this to macos/Runner/DebugProfile.entitlements and macos/Runner/Release.entitlements:
The write key is public, so it's safe to ship in the app. Calls made before setup are ignored. No method ever throws: a bad argument is ignored and, with debug: true, logged.
If the source lists Allowed apps, Lemu refuses events from any other app id. On Android the id is your applicationId, and on iOS and macOS your bundle identifier. Web and desktop builds send a different id: if you ship them, turn on debug mode, find namespace under app in a logged request, and add it to the list too.
await Lemu.instance.setup( 'lpk_...', options: const LemuOptions( debug: false, // log every call, request and response requireConsent: false, // see "Consent and opt-out" flushAt: 20, // send once this many events are queued (web: 10) flushInterval: Duration(seconds: 30), // and at least this often (web: 1 second) maxQueueSize: 1000, // events kept on the device while offline (at most 1,000) trackLifecycle: true, // app_installed, app_updated, app_opened, app_backgrounded trackDeepLinks: true, // deep_link_opened from trackDeepLink() ),);
LemuOptions also takes apiHost. Change it only if your source's setup steps show another host.
Any event name works. For Meta's standard events, use the LemuEvent constants (viewContent, addToCart, initiateCheckout, purchase and the rest), spelled exactly as Meta expects. See the event reference.
Don't put email addresses, phone numbers or other contact details in event properties. Lemu removes them; they belong in identify().
purchase() sends a Purchase event right away instead of waiting for the next batch. content_ids and num_items are filled in from contents when you don't pass them.
Always pass the order id from your backend. The same order is often reported by more than one source: the app, your website, your server, Shopify. Lemu counts one conversion per order id, so revenue isn't counted twice and journeys don't fire twice. Without it, every report counts. See Conversion events.
Lemu.instance.identify( userId: 'cust_8812', // your own id for this user traits: { 'email': 'asha@example.com', 'phone': '+919812345678', // international format 'first_name': 'Asha', 'last_name': 'Rao', },);
The userId is kept and sent with every later event, also after the app restarts. On logout:
dart
Lemu.instance.reset(); // new anonymous id, no user id
Lemu.instance.anonymousId is the id Lemu uses for this install before the user is known.
go_router names each page after the GoRoutename, or its path pattern (/product/:id) when it has none. Routes inside a ShellRoute need the observer on that ShellRoute too.
Dialogs, bottom sheets and unnamed routes are skipped. To choose names yourself:
Pass each link that opens the app to trackDeepLink. It sends deep_link_opened and keeps the link's utm_source, utm_medium, utm_campaign, utm_term, utm_content, gclid and fbclid with every later event in the session, so later events, including the purchase, are credited to the campaign.
app_links
The app_links stream also delivers the link that launched the app:
dart
final appLinks = AppLinks();appLinks.uriLinkStream.listen((uri) => Lemu.instance.trackDeepLink(uri));
go_router
Track links in the top-level redirect. It also runs for in-app navigation, so only track URLs that carry campaign parameters, once each:
dart
Uri? lastTrackedLink;final router = GoRouter( redirect: (context, state) { final uri = state.uri; final hasCampaign = uri.queryParameters.keys .any((k) => k.startsWith('utm_') || k == 'gclid' || k == 'fbclid'); if (hasCampaign && uri != lastTrackedLink) { lastTrackedLink = uri; Lemu.instance.trackDeepLink(uri); } return null; }, routes: [...],);
trackDeepLink(uri, referrer: 'com.instagram.android') records where the link came from, when you know it.
Unless you set trackLifecycle: false, the SDK sends:
Event
When
Properties
app_installed
First launch
version, build
app_updated
First launch after the version or build changed
version, build, previous_version, previous_build
app_opened
Launch and every return to the foreground
from_background
app_backgrounded
The app goes to the background
Queued events are sent when the app goes to the background, with or without lifecycle events. If you add the SDK to an app people already have, each of them sends app_installed once, on their first launch with the SDK.
If you must ask before tracking, for example under GDPR or the DPDP Act, set requireConsent: true. Nothing is sent and nothing is written to the device, not even the anonymous id, until the user agrees. Up to 50 events are held in memory meanwhile.
dart
await Lemu.instance.setup('lpk_...', options: const LemuOptions(requireConsent: true));// later, from your consent screenLemu.instance.setConsent(true); // sends the held events; remembered across launchesLemu.instance.setConsent(false); // discards held and queued events
To stop all tracking for a user who opts out in your settings screen:
dart
Lemu.instance.optOut(); // clears the queue, remembered across launchesLemu.instance.optIn(); // resumes
On the web, the SDK reuses the visitor id of the Lemu website snippet (the _lemu_aid cookie and local storage key) when the Flutter app runs on the same site. A visitor who browses your website and then your Flutter web app is one visitor, and a visitor who opted out on the website stays opted out. Events are sent every second or every 10 events.
Every call, request body and response status is printed with a [Lemu] prefix through debugPrint. Lemu.instance.flush() sends the queue immediately, which helps while testing. To see what Lemu stored, open the source in Settings → Tracking Sources and use Recent events.
Events are kept on the device (in shared_preferences) and survive restarts. At most 1,000 are kept; when full, the oldest event that isn't a Purchase is dropped. Events older than 7 days are dropped before sending.
Each request carries up to 50 events. Apps send every 30 seconds or 20 events, when going to the background, and right after a purchase. The web sends every second or 10 events.
Network errors, timeouts and server errors are retried with increasing waits, up to 5 minutes apart. A batch that keeps failing is dropped 20 hours after it was queued. Refused batches are dropped and the reason is logged in debug mode.
Every request has the User-Agent lemu-flutter/<version> (<os> <os version>; <model>), except on the web, where the browser sets its own.
A random anonymous id created on first launch and stored in the app's preferences. It isn't derived from the device and is replaced on reset() or reinstall.
The events and properties your code sends, plus the userId and traits you pass to identify().
App name, version, build and package name; device manufacturer, model and type; OS name and version; screen size and pixel density; locale; time zone; campaign parameters from deep links.
It doesn't collect advertising ids (IDFA, GAID), hardware or vendor ids (Android ID, identifierForVendor), location, contacts, or anything else you don't send.
Your store answers depend on what your app sends and how your Lemu workspace uses it. The Flutter SDK collects the same data as the native SDKs, so the answers under Google Play data safety and App Privacy answers in App Store Connect apply. The Flutter SDK reads no advertising identifier and doesn't need the App Tracking Transparency prompt to work. If your workspace forwards conversions to ad platforms, for example through the Meta Conversions API, both stores count that as tracking or sharing: declare it, and follow Apple's App Tracking Transparency rules for it.
Event reference
Every event name the Lemu SDKs send, its constant on each platform, the standard parameters, and how Lemu stores events, properties and context
https://docs.lemuai.com/sdks/events
This page lists the event names every Lemu SDK knows, the constant for each one on each platform, and what Lemu keeps from each event. For the fields an order needs and how revenue and ROI are calculated, see Standard and conversion events.
These are Meta's standard events, with Meta's names and parameters. Every SDK has a constant for each one.
Event
JavaScript, React, React Native
Android
iOS, Flutter
Parameters
PageView
LemuEvent.PageView
LemuEvent.PAGE_VIEW
LemuEvent.pageView
none. On websites, page() sends it
ViewContent
LemuEvent.ViewContent
LemuEvent.VIEW_CONTENT
LemuEvent.viewContent
content_ids, content_category, content_name, content_type, contents, currency, value
Search
LemuEvent.Search
LemuEvent.SEARCH
LemuEvent.search
search_string, content_category, content_ids, contents, currency, value
AddToCart
LemuEvent.AddToCart
LemuEvent.ADD_TO_CART
LemuEvent.addToCart
content_ids, content_name, content_type, contents, currency, value
AddToWishlist
LemuEvent.AddToWishlist
LemuEvent.ADD_TO_WISHLIST
LemuEvent.addToWishlist
content_ids, content_name, content_category, contents, currency, value
InitiateCheckout
LemuEvent.InitiateCheckout
LemuEvent.INITIATE_CHECKOUT
LemuEvent.initiateCheckout
content_ids, content_category, contents, currency, num_items, value
AddPaymentInfo
LemuEvent.AddPaymentInfo
LemuEvent.ADD_PAYMENT_INFO
LemuEvent.addPaymentInfo
content_ids, content_category, contents, currency, value
Purchase
LemuEvent.Purchase
LemuEvent.PURCHASE
LemuEvent.purchase
value, currency and order_id (required), content_ids, content_name, content_type, contents, num_items. Use purchase()
Lead
LemuEvent.Lead
LemuEvent.LEAD
LemuEvent.lead
content_category, content_name, currency, value
CompleteRegistration
LemuEvent.CompleteRegistration
LemuEvent.COMPLETE_REGISTRATION
LemuEvent.completeRegistration
content_name, currency, status, value
Subscribe
LemuEvent.Subscribe
LemuEvent.SUBSCRIBE
LemuEvent.subscribe
currency, predicted_ltv, value
StartTrial
LemuEvent.StartTrial
LemuEvent.START_TRIAL
LemuEvent.startTrial
currency, predicted_ltv, value
Schedule
LemuEvent.Schedule
LemuEvent.SCHEDULE
LemuEvent.schedule
SubmitApplication
LemuEvent.SubmitApplication
LemuEvent.SUBMIT_APPLICATION
LemuEvent.submitApplication
Contact
LemuEvent.Contact
LemuEvent.CONTACT
LemuEvent.contact
CustomizeProduct
LemuEvent.CustomizeProduct
LemuEvent.CUSTOMIZE_PRODUCT
LemuEvent.customizeProduct
Donate
LemuEvent.Donate
LemuEvent.DONATE
LemuEvent.donate
FindLocation
LemuEvent.FindLocation
LemuEvent.FIND_LOCATION
LemuEvent.findLocation
With the website snippet, use the event name itself, for example lemu("track", "AddToCart", { ... }). Lemu matches a standard name whatever its case or separators, so add_to_cart is stored as AddToCart. See Matching names.
An amount in major units: 1499.5 is ₹1,499.50. On AddToCart, the value of what was added. On InitiateCheckout, the checkout total. On Purchase, the order total
currency
string
An ISO 4217 code such as INR
order_id
string
Your id for the order. Lemu counts one conversion per order id, however many sources report it. Meta's Conversions API has the same field
content_ids
list of strings
Product ids or SKUs
contents
list of objects
Items, each with id and quantity, and optionally item_price, title, brand and category
content_type
string
product or product_group
content_name
string
A name
content_category
string
A category
num_items
integer
The number of items
search_string
string
What was searched for
predicted_ltv
number
The expected lifetime value of a subscriber
status
string
The status of a registration
You can add your own properties next to these, for example payment_method or coupon.
The app SDKs take the order id and items as typed arguments to purchase: orderId and LemuContent(id, quantity, itemPrice, title) on Android, iOS and Flutter. They are sent as order_id and contents with item_price.
A conversion event counts as an order for revenue and ROI. By default that's Purchase; you can add others under Settings → Sending Limits → Conversion events. Every conversion event needs value, currency and order_id.
Lemu never rejects a conversion event for a missing field. It fixes what it can, counts the rest, and shows the problem on the event in Recent events. See When a field is missing.
The app SDKs (Android, iOS, Flutter and React Native) send these for you. They have no Meta equivalent and are never conversions.
Event
JavaScript (React Native)
Android
iOS, Flutter
When
Properties
app_installed
LemuEvent.AppInstalled
LemuEvent.APP_INSTALLED
LemuEvent.appInstalled
The first launch with the SDK
version, build
app_updated
LemuEvent.AppUpdated
LemuEvent.APP_UPDATED
LemuEvent.appUpdated
The first launch after the version or build changed
version, build, previous_version, previous_build
app_opened
LemuEvent.AppOpened
LemuEvent.APP_OPENED
LemuEvent.appOpened
Every launch and every return to the foreground
from_background, and url when a link opened the app (not on Flutter)
app_backgrounded
LemuEvent.AppBackgrounded
LemuEvent.APP_BACKGROUNDED
LemuEvent.appBackgrounded
The app goes to the background
deep_link_opened
LemuEvent.DeepLinkOpened
LemuEvent.DEEP_LINK_OPENED
LemuEvent.deepLinkOpened
A link opens the app
url, referrer
screen_viewed
LemuEvent.ScreenViewed
LemuEvent.SCREEN_VIEWED
LemuEvent.screenViewed
A screen is shown, when you track screens
name, plus your properties
screen_viewed is never sent automatically. Call screen(name), or turn on your platform's screen tracking.
Turn the first four off with trackLifecycleEvents = false on Android, or trackLifecycle: false on iOS, Flutter and React Native. Turn deep links off with trackDeepLinks.
If you add the SDK to an app people already have, each of them sends app_installed once, on their first launch with the SDK.
On Android, the install referrer's campaign is added to app_installed. See Install referrer.
Any name that isn't a standard event is a custom event, for example coupon_applied or wishlist_shared. Custom events are never rejected, and they work in journeys, segments and the Event Log like any other event.
Lemu stores a custom name from an SDK in lowercase with underscores, so "Coupon Applied" is stored as coupon_applied. Use that spelling in journeys and segments, or send it that way to begin with.
Contact details belong in identify traits only. Lemu removes these keys from event, page and screen properties, at any depth, whatever their case: email, e_mail, phone, phone_number, mobile, mobile_number, whatsapp, password, otp, card, card_number, cvv, pan, aadhaar and address. The same keys are removed from the query string of page URLs and referrers.
The SDKs add context to every event. Your code never sets it. Lemu keeps:
Context
What it holds
platform
web, ios, android, flutter or react_native
library
The SDK's name and version
app
The app's name, version, build and namespace (bundle id or package name)
device
manufacturer, model, and type (phone, tablet, desktop, tv or other)
os
The OS name and version
screen
Width, height and pixel density
locale, timezone
For example en-IN and Asia/Kolkata
campaign
source, medium, campaign, term and content from UTM parameters, plus gclid and fbclid, from the landing page, the deep link that opened the app, or the Android install referrer
user_agent
The browser's user agent, or the SDK's, such as lemu-android/1.0.0 (Android 14; Pixel 8)
referrer
The page's referrer, on websites
You can see an event's context in Recent events. No advertising ids and no hardware ids are sent or kept.
Overview
Trigger calls, send events, sync contacts and records, send transactional email and WhatsApp templates with the Lemu AI REST API
https://docs.lemuai.com/api-reference/overview
The Lemu AI REST API covers a small, stable set of tasks:
Events, contacts and records find the right person by phone number, external_id (your own customer ID) or email, so a contact without a phone number can still be matched. See how the contact is found.
Everything else (building agents and journeys, running campaigns, recordings and transcripts) is done in the Lemu AI dashboard.
The recommended way to receive the outcome of a call (what was said, what the agent captured, how it ended) is to add a Webhook node to your agent. Lemu AI then posts the result to your system when the call finishes, so you don't need to poll.
Connecting an AI assistant such as Claude or Cursor? Use the MCP server instead of this REST API. It lets an assistant list your agents and place calls on your behalf, with permissions you approve.
Quickstart
Make your first LemuAI API calls in five minutes: create a key, add a contact, send an order event and start a call.
https://docs.lemuai.com/api-reference/quickstart
Everything goes to https://app.lemuai.com/api/v1 with your key in the X-API-Key header and JSON bodies. The examples below read the key from the LEMU_API_KEY environment variable.
In the app, open Settings → API Keys and create a key. It starts with lemu_. Store it as a secret on your server; never put it in a website or mobile app (use Tracking Sources write keys there instead).
The contact is matched by phone, so sending the same phone again updates them instead of adding a duplicate. list_name is required (the list is created if new). See Upsert a Contact for every field.
The answer includes the run id. Get the result with List Calls, or have the agent push it to you with a Webhook. See Trigger an Outbound Call for the exact URL and fields.
Create keys in the Lemu AI dashboard under Settings → API Keys (see API Keys). The full key is shown only once, when you create it. Store it straight away in a secrets manager or an environment variable. Keys start with lemu_.
You can also archive a key from the same page. An archived key stops working immediately.
The Authorization: Bearer lemu_your_api_key header is also accepted, except on Trigger an outbound call, which only reads X-API-Key. Use X-API-Key everywhere to keep things simple.
An API key acts for your organization, not for a team member, so team roles don't limit it: a key can use every endpoint in this reference. One exception: the contacts endpoints show full phone numbers only if the team member who created the key may view personal data.
An API key can act on your whole organization. Keep it on your server. Never put it in a browser, a mobile app, or a public repository.
16 KB of data, key up to 255 characters, text values up to 2,000 characters
Event name
1 to 100 characters
Segment rules
30 per segment; is in lists up to 500 values
The REST API has no fixed per-key request rate today, but be a good citizen: use the bulk endpoints for imports instead of one request per row, and keep to a few requests per second per key. Website and app events sent with a tracking-source write key are rate limited per source and per device, and answer 429 Too many requests when exceeded.
Upsert a contact, bulk upsert, create or update a record
Yes. They match on phone / key and update; repeating changes nothing
Send an event (Purchase and other conversion events)
Orders count once per order_id. Always send order_id, so a retried order isn't counted twice. Each event still starts journeys that listen for it, so avoid resending non-order events
Trigger an outbound call
No. Each request places a call. Retry only when you're sure the first request failed (a network error before any answer, or a 4xx/5xx)
The public endpoints are described in an OpenAPI 3 file: /openapi.json. Import it into Postman or Insomnia, generate a client, or give it to your coding assistant.
Webhooks
Get call results pushed to your system after each call, and start journeys from your system with a signed webhook.
https://docs.lemuai.com/api-reference/webhooks
There are two directions:
Direction
What
Set up in
LemuAI → you
After each call, a voice agent sends the result (variables it captured, duration, recording, transcript) to your URL
A Webhook step in the voice agent
You → LemuAI
Your system starts a journey for someone by posting to the journey's webhook URL
A journey with the Webhook trigger
To send events (orders, sign-ups) that start any journey listening for them, use Send an Event instead; it needs your API key and links the event to a contact.
Add a Webhook step to the voice agent (Voice Agents → Agents, open the agent). Set the HTTP Method, Endpoint URL, optional Auth and Custom Headers, and a Payload Template (JSON) using these variables:
Variable
Value
{{workflow_run_id}}
The call's run id
{{workflow_id}}, {{workflow_name}}
The agent
{{initial_context.<name>}}
Values the call started with (from the API, a journey or a campaign)
Create a journey with the Webhook trigger. Its panel shows the URL to post to:
Text
POST https://app.lemuai.com/api/v1/workflow-execution/webhooks/{trigger_id}
The JSON body becomes the run's starting context, so later steps can use {{context.<field>}}. Include the person's phone so steps that call or message have someone to reach. No API key is needed: the URL is the secret. For extra safety, set a secret on the trigger and sign each request.
The run started. The body includes the trigger and run details
401
"Invalid webhook signature": missing or wrong X-Webhook-Signature
404
"Trigger {id} not found": the trigger was deleted, or the id is wrong
400
"Trigger {id} is not active", "Trigger {id} is not a webhook trigger", a request that doesn't match the trigger's settings (method, content type, required headers), or a journey that isn't live
Starts an outbound call to one phone number using a voice agent. This is the endpoint to call from your CRM, n8n, Zapier, or your own backend.
The uuid in the path identifies an API Trigger node in your agent, not the agent itself. Add an API Trigger node to the agent in the editor, save it, and copy the endpoint URL shown in the node's settings. The trigger must be active and still present in the agent's workflow.
Your organization's telephony provider must be set up before calls can connect. See Telephony.
Sends an event that happened in your own system, such as an abandoned cart, a placed order or a submitted form. LemuAI stores it, links it to the right contact, and starts every active journey whose API Events trigger listens for the same event_type.
Use this to start a journey, for example a WhatsApp message or a follow-up call an hour after a cart is abandoned. To call one number straight away with a voice agent, use Trigger an outbound call instead.
The name of the event, 1 to 100 characters, for example Purchase, InitiateCheckout or your own cart_abandoned. Journeys whose API Events trigger uses the same event_type start for this contact. See Event names.
phone
string
No
The person's phone number in international format, for example +919876543210, up to 50 characters.
email
string
No
The person's email address, up to 254 characters.
external_id
string
No
Your own id for the person, for example a CRM or customer id, up to 255 characters.
anonymous_id
string
No
The visitor id set by the LemuAI website snippet or an app SDK (see Tracking Sources), up to 512 characters. Send it to tie website or app activity to the person once they sign up or check out.
list_name
string
No
A contact list name, up to 255 characters. The contact is added to this list, and the list is created if it doesn't exist yet.
data
object
No
Any details about the event, such as order id, amount or product. Journeys started by this event can use these values (see below). For a Purchase, include value, currency and order_id (see Orders and revenue).
Send at least one of phone, email, external_id or anonymous_id to link the event to a person. An event with none of them is stored but not linked to a contact.
If data contains first_name and last_name (or name, full_name, contact_name or customer_name), the name is saved on the contact.
Use Meta's standard event names where one fits, such as Purchase, AddToCart, InitiateCheckout or Lead. They are matched whatever the case or separators: purchase, PURCHASE and Purchase are all stored as Purchase, and add_to_cart as AddToCart. Any other name is a custom event and is stored as you sent it.
Older names such as order_placed and cart_added still match Purchase and InitiateCheckout in journeys and segments. See Standard and conversion events for the full list.
A Purchase (or any other event listed under Conversion events in Sending Limits) counts as an order for journey and campaign revenue and ROI. Include these fields in data:
Field
Type
Description
value
number
The order total in major units, for example 1499.5
currency
string
An ISO 4217 code, for example INR
order_id
string
Your id for the order. The same order reported more than once, by this API, your website, your app or Shopify, counts once
The event is never rejected for a missing field. An order without a value counts with no revenue, a missing currency is replaced by your workspace currency, and an order without an order_id counts every time it is sent.
LemuAI looks up every identifier you send (phone, email, external_id and anonymous_id) and works out which person they belong to:
One match. If the identifiers point to one existing contact, the event is linked to it, and any new identifiers you sent are added to that contact.
Several matches. If they point to two or more contacts that are clearly the same person (for example the phone matches one contact and the email matches another, and nothing conflicts), those contacts are merged into one and the event is linked to it. Contacts are not merged when that would join two different people, for example two contacts that each have a different email. In that case the event is linked to the main matching contact and nothing is merged.
No match. A new contact is created, but only when you sent a phone or an email. An external_id or anonymous_id on its own links to an existing contact or to none; it never creates one.
A website visitor id that was linked to another person before moves to the person in this event.
The id of the stored event. It appears in the Event Log.
contact_id
integer or null
The contact the event was linked to. null when no identifier was sent, when only an external_id or anonymous_id was sent and no contact has it, or when your plan's contact limit stopped a new contact being created.
triggered_workflows
integer
Always 0. Journeys are started in the background just after the response, so the count isn't known yet. Check the Event Log or the journey's runs to see what ran.
A journey started by this event gets phone, event_type and event_id, plus every field from data (or only the fields picked in the trigger's context mapping). With the request above, a call step in the journey can use {{first_name}}, {{cart_amount}} and {{product_name}} in the agent's prompt.
On the journey's API Events trigger you can also:
wait before running, for example 60 minutes after cart_abandoned;
cancel the run if another event arrives for the same contact first, for example Purchase;
A new contact created from an event is tagged event and counts toward your plan's contact limit. If you've reached the limit, the event is still stored, but no contact is created and contact_id is null.
List your organization's events from every source, newest first
https://docs.lemuai.com/api-reference/events/list
Returns your organization's events, newest first. This is the same data as the Event Log page. It includes events you sent with Send an event and events from other sources, such as Shopify, your tracking sources, segments and custom records.
Only return events of this type, for example Purchase. A Meta standard event name also returns events stored under its older names, so Purchase includes order_placed and checkout_completed. See Standard and conversion events.
source
string
No
Only return events from this source. See Event sources below.
include_message_updates
boolean
No
Also return message status updates, such as message_sent or message_delivered. Default false. Only works when the event store is on (see store below).
search
string
No
Match against the phone number, the contact's name or the event type.
start_date
string
No
Earliest event to include, as YYYY-MM-DD or a full ISO date and time.
end_date
string
No
Latest event to include, as YYYY-MM-DD (the whole day is included) or a full ISO date and time.
The event's number in LemuAI. This is the event_id returned by Send an event. It is 0 for events that are only kept in the event store, such as page views by website visitors.
events[].event_id
string
A unique id (UUID) for the event. Every event has one, so use it when you need a stable id.
The website visitor id, for activity by a visitor who isn't linked to a contact yet.
events[].event_data
object
The details sent with the event.
events[].created_at
string
When the event happened, in ISO 8601 (UTC).
total
integer
How many events match your filters in total, for paging with limit and offset.
store
string
Where the events were read from: clickhouse (the event store, which holds every source including anonymous website visits) or postgres (the main database, used when the event store isn't on).
API keys see full phone numbers here. In the dashboard, team members without permission to view personal data see them partly hidden.
Returns the calls for one voice agent, newest first, a page at a time. Each call is called a run. Use it to check whether a call you triggered has finished and what the agent captured.
If you need each result as soon as a call ends, add a Webhook node to the agent instead of polling this endpoint.
How the call was connected: the telephony provider (for example twilio, plivo, exotel), or webrtc / textchat for browser tests.
created_at
string
When the call started (ISO 8601, UTC).
is_completed
boolean
true once the call has ended.
call_type
string
outbound or inbound.
definition_id
integer or null
The version of the agent that ran this call.
initial_context
object or null
The data the call started with, including phone_number and anything you sent in initial_context.
gathered_context
object or null
What the agent captured during the call, plus mapped_call_disposition (the disposition code the call ended with). Empty until the call has finished.
cost_info
object or null
call_duration_seconds and billed_minutes for the call. null until the call has ended.
recording_url, transcript_url
string or null
Internal references to the stored recording and transcript. Open recordings and transcripts from the call in the dashboard; they are not downloadable through the API.
Phone numbers and other personal details in initial_context and gathered_context may be partly hidden, depending on whether the person who created the API key is allowed to view personal data in your organization.
List Campaigns
List the calling campaigns in your organization and their progress
created, syncing, running, paused, completed, or failed.
source_type
string
Where the numbers come from: contact-list, google-sheet, or csv.
source_id
string
The contact list id, Google Sheet URL, or uploaded file reference.
total_rows
integer or null
Contacts in the campaign, once the source has been read.
processed_rows
integer
Contacts already called.
failed_rows
integer
Contacts whose call could not be placed.
created_at
string
When the campaign was created (ISO 8601, UTC).
started_at
string or null
When it was first started.
completed_at
string or null
When it finished.
retry_config
object
Whether and how unanswered calls are retried: enabled, max_retries, retry_delay_seconds, and which outcomes trigger a retry (retry_on_busy, retry_on_no_answer, retry_on_voicemail).
schedule_config
object or null
The calling windows: timezone and slots (day_of_week from 0 Monday to 6 Sunday, start_time and end_time as HH:MM). null if the campaign calls at any time.
circuit_breaker
object or null
Automatic pause when too many calls fail: failure_threshold (share of failures, 0 to 1) within window_seconds, once at least min_calls_in_window calls were made.
Overview
Keep your Lemu AI contacts and contact lists in sync with your CRM
A contact is a person you call or message. Contacts are grouped into contact lists, which campaigns and journeys use as their audience. One contact can be in several lists.
The contacts API is for keeping Lemu AI in step with your own system (a CRM, a spreadsheet, a signup form):
Phone numbers are personal data. If the person who created the API key isn't allowed to view personal data in your organization, responses show the number partly hidden (for example •••• 3210) and set phone_masked to true. Organization owners and admins, and team members with permission to view personal data, see full numbers.
Adds one contact to a contact list, creating whatever doesn't exist yet:
The contact is matched by phone in your organization. The match ignores formatting, so +91 98765 43210 and +919876543210 are the same number. If a match is found, the fields you send are updated; if not, a new contact is created.
The list is matched by list_name. If no list has that name, it is created.
Use this endpoint when a record is created or changes in your CRM.
Loads or refreshes a contact list in one request. For each contact:
Lemu AI looks for an existing contact with the same phone, then with the same external_id. A row that has neither a phone nor an external_id is matched by email instead (ignoring upper and lower case), so sending the same email-only rows again updates them rather than creating duplicates.
If one is found, it is updated with the fields you send. If not, a new contact is created.
The contact is added to the list named list_name, which is created if it doesn't exist.
Each contact is handled on its own, so one bad row doesn't stop the rest. Rows that fail are reported in errors.
This endpoint matches rows by phone, external_id and email only. It does not merge contacts. To link activity from several identifiers (for example a website visitor id) to one person, use Send an event.
Bulk matching compares phone numbers exactly as stored. Send every number in the same international format (for example +919876543210) so existing contacts are found instead of duplicated.
The list to put the contacts in (1 to 255 characters). Created if it doesn't exist.
contacts
array
Yes
Between 1 and 5,000 contacts. Each one accepts the fields below.
Each contact:
Field
Type
Description
phone
string
Phone number in international format.
external_id
string
Your own id for the person.
email
string
Email address.
first_name, last_name
string
Name. A single name (or full_name) is also accepted and split into first and last name.
company
string
Company name.
title
string
Job title.
tags
array of strings
Replaces the contact's tags.
custom_fields
object
Extra values, merged into the contact's custom fields.
any other key
any
Stored in custom_fields, so you can send a row from a spreadsheet or CRM as it is. A mobile key is used as phone and an id key as external_id when those aren't set.
One entry per failed row: index (its position in your contacts array, starting at 0) and error (why). A phone number, external_id or email (for email-only rows) repeated within the same request is skipped after its first appearance.
list_created
boolean
true if the list was created by this request.
list_id
integer
The id of the list. Use it with List the contacts in one list, or to pick the list as a journey or campaign audience.
contacts
array
The contacts that were created or updated. See contact fields.
Text to look for in first, last or full name, email, company, external ID and phone. A phone-like value also matches the last 4 digits, and the full number with or without the country code (9876543210, +919876543210).
tags
string
No
Comma-separated tags. Returns contacts with any of them.
has_email
boolean
No
true for contacts with an email, false for contacts without one.
has_phone
boolean
No
true for contacts with a phone number, false for contacts without one.
Each contact has a consent status for every channel. LemuAI checks it before a journey or campaign sends a message or places a call, so recording opt-ins and opt-outs from your own system (a signup form, a preference center, a support ticket) keeps your messages within what each person agreed to.
The person opted out of this channel. On WhatsApp this stops marketing: replies in a chat they start, utility templates and authentication codes still go.
null (unknown)
Nothing has been recorded for this channel yet.
What happens when the status is unknown depends on the channel:
Channel
Unknown means
voice
Allowed
whatsapp
Allowed
email
Not allowed for marketing email
sms
Not allowed
The contact's opted_out flag is a separate "do not contact" switch. When it is true, no channel is allowed, whatever the per-channel status says. Recording a channel status with this API doesn't change opted_out.
Each response includes can_contact for every channel, which applies all of these rules for you.
For marketing email, your workspace's email settings can also allow sending when consent is unknown. Transactional email (order and account updates sent with Send a transactional email) doesn't need consent, but is never sent to an address on your suppression list, for example after a hard bounce, a spam complaint or an unsubscribe.
Returns a contact's activity timeline, newest first: events you sent, Shopify orders, website visits, message status changes, segment changes and custom record changes. It is the same timeline as the Activity tab on the contact's page.
The timeline covers the whole person:
events stored against contacts that were later merged into this one;
website visits made before the person was identified, through the visitor ids linked to the contact.
Setup required. Activity is read from the event store. If the event store isn't turned on for your workspace, the response has enabled: false and no events. Use List events in that case.
false when the event store isn't turned on. events is then empty.
events
array
The events on this page, newest first.
events[].event_id
string
The event's unique id (UUID).
events[].event_type
string
The event name, for example Purchase, PageView or message_delivered. Events stored before Lemu switched to Meta's standard event names keep their older name, such as order_placed or page_viewed.
events[].occurred_at
string
When it happened, in ISO 8601 (UTC).
events[].source
string
Where it came from: api, shopify, pixel, messaging, segments, records or backfill. See Event sources.
events[].contact_id
integer or null
The contact the event was stored against: this contact or one merged into it. null for website activity from before the person was identified.
events[].anonymous_id
string or null
The website or app visitor id, for events from a tracking source.
events[].properties
object
The details of the event.
next_before
string or null
Pass this as before to get the next page. null on the last page.
Returns every message sent to or received from a contact, newest first, on every channel: WhatsApp, email, SMS and voice calls. Each entry shows where the message is in its life (sent, delivered, read, failed) and what sent it.
The service that carried the message, for example the WhatsApp, email or telephony provider.
messages[].provider_status
string or null
The provider's own last status word, before LemuAI mapped it to status.
messages[].template_name
string or null
The WhatsApp or email template used, if any.
messages[].text
string or null
The message's text, up to 1,000 characters: what was written, or a template's filled-in text. null for calls and messages with no text.
messages[].source_type
string or null
What sent it: automation (a journey), campaign, voice_agent (an agent during a call), transactional (the transactional email API), inbox (a team member replying in the Inbox), manual (a call placed by hand or through the API), inbound_call, customer (a message the contact sent you) or test.
messages[].source_id
integer or null
The id of what sent it, such as the journey run, the campaign or the call.
messages[].workflow_run_id
integer or null
The call this message is (voice), or the call it was sent during (for example a WhatsApp message sent by an agent tool).
messages[].error
string or null
Why the message failed, when status is failed.
messages[].meta
object
Extra details about the message, for example a call's duration in seconds.
Custom records hold data about your contacts that doesn't fit on the contact itself, such as orders, subscriptions, bookings or policies. You define each record type and its fields in the dashboard under Records. See Custom Records for how to set one up and how journeys, segments and messages use records.
The records API keeps those records in step with your own system:
The record type's API name, for example subscription. It is made from the record type's name when you create it, in lower case with underscores.
Record key
The value that identifies a record within its type, for example a subscription id. Sending the same key again updates that record instead of creating a new one.
Owner
The contact a record belongs to. Every record of a normal record type has one owner. A catalog (such as products) has no owner.
data
The record's fields, as an object of field name and value. Only fields defined on the record type are accepted.
a field sent as null or an empty string is cleared.
Each change records an object_created or object_updated event on the owner's timeline (source records), so journeys and segments can react to it. Personal fields aren't copied into the event.
An ISO 8601 date and time, for example "2026-11-30T18:00:00Z".
Choice
One of the field's options. Upper and lower case are ignored.
Link
An http or https link, up to 2,000 characters.
A record can be at most 16 KB once saved. Fields marked as required must have a value.
Fields marked as personal are partly hidden (•••) in the dashboard for team members without permission to view personal data. API keys always see the full values.
Your plan sets how many record types and records your organization can store. A request that would create more records than your plan allows returns 402.
Create or Update a Record
Create or update one custom record by its key, and set the contact it belongs to
Creates a record, or updates it if a record with the same key already exists. Fields you send replace the stored values, fields you don't send are kept, and null clears a field. See how updates work.
Records of a normal record type belong to one contact. A catalog has no owner, so these fields are ignored for it.
If you send contact_id, that contact is the owner.
Otherwise, if you send phone, email, external_id or shopify_customer_id, Lemu AI finds the contact the same way as Send an event. A new contact (tagged record) is only created from a phone or email.
If you send no owner fields and the record already exists, it keeps its owner.
A new record with no owner fields is rejected.
Sending a different owner for an existing record moves the record to that contact.
There's no record type with this api_name, the record type is archived, the record has no owner, no contact matches the owner, a new owner contact couldn't be created because your plan's contact limit is reached, a field is unknown or has a value of the wrong type, a required field is missing, the key in data doesn't match the path, or the record is larger than 16 KB. detail lists every problem.
401
The API key is missing or not valid.
402
Creating the record would take your organization over its plan's record limit.
422
The body isn't valid JSON, or an owner field is too long.
Creates or updates up to 1,000 records of one record type. Each record works the same way as Create or update a record, and each one succeeds or fails on its own, so one bad row doesn't stop the rest.
Send an order, shipping or account email to one person from a saved email template
https://docs.lemuai.com/api-reference/email/send
Sends one transactional email, such as an order confirmation, a shipping update or a password reset, from an email template you built in the dashboard. Values you send in data fill the template's merge tags.
Use this only for messages the person needs. Marketing email (offers, newsletters, reminders to buy) goes through email campaigns and journeys, which check consent and add an unsubscribe link.
Setup required. Before you can send, your account needs:
LemuAI's email service turned on. Contact hello@lemuai.com to enable it.
A verified sending domain and at least one sender. See Email Setup.
A saved template. Transactional templates are best marked as transactional in the editor.
Transactional email doesn't need the person's email consent, and it is sent even when your marketing email is paused. It is still never sent to an address on your suppression list (for example after a hard bounce, a spam complaint or an unsubscribe). Those requests return 422 with skipped set to suppressed.
The template has never been saved, you have no sender (add one in Email Setup), or to isn't a valid email address.
401
The API key is missing or not valid.
404
No template with this template_id in your organization.
422
Nothing was sent. detail.skipped says why: domain_not_verified (the sender's domain isn't verified), suppressed (the address is on your suppression list), render_failed (a merge tag couldn't be filled, see detail.message) or no_address. Also returned when a field is missing or has the wrong type.
502
The sending service refused the email. It is logged as failed.
Sends one approved WhatsApp template to one phone number from your own system, for example an order update, a payment reminder or a login code. You say which template to send, the number to send it to, and the values for the template's variables. It works like the "send template message" API of WATI, Interakt or AiSensy.
Any approved template can be sent: marketing, utility and authentication. To send to a list of people at once, use a broadcast or a journey in the dashboard instead.
Setup required. Before you can send, your workspace needs:
WhatsApp connected under WhatsApp → Setup, with at least one number under WhatsApp → Numbers.
An approved template under WhatsApp → Templates.
Money in your WhatsApp balance. Recharge under Usage & Plan → Usage & balances.
An API key from Settings → API Keys. See Authentication.
Name the template with template_id, or with template_name and language.
Field
Type
Required
Description
to
string
Yes
The number to send to, with its country code: +919876543210 or 919876543210. Spaces and dashes are fine. A 10-digit number without a country code is refused.
template_id
integer
One of template_id or template_name
LemuAI's id for the template, a number such as 44. Open WhatsApp → Templates and click the template: its side panel shows Template ID with a copy button. It is not the Meta template ID shown next to it.
template_name
string
One of template_id or template_name
The template's name exactly as shown under WhatsApp → Templates, for example order_shipped.
language
string
With template_name, when the template has more than one language
The template's language code, for example en, en_US or hi. en also finds en_US when that is the template's only English version. Ignored with template_id, which already points at one language.
variables
object
When the template has variables
The values for the template's variables, as text or numbers. See Variables. Up to 100 entries.
header_text
string
When the template's text header has a variable
The value for the header's variable, up to 60 characters. Templates with named variables can give it in variables instead.
header_media_url
string
When the template's header is an image, video or document
A public https:// link to the file. WhatsApp downloads it when it sends the message.
header_filename
string
No
The file name WhatsApp shows for a document header, for example Invoice-10422.pdf. Default: the file name the link ends in, when it ends in one (…/Invoice-10422.pdf).
button_url_value
string
When a link button's address ends with a variable
The part that goes in place of the variable. For a button to https://shop.example.com/track/{{1}}, send SO-10422. For a button made with Count clicks on this button, send the whole page address to open; see Link Click Tracking.
coupon_code
string
When the template has a copy-code button
The code the button copies, up to 15 characters.
product_retailer_ids
array of strings
For a multi-product template
The content IDs (SKUs) of the products to show, from your WhatsApp catalog. Up to 30.
thumbnail_product_retailer_id
string
No
For a catalog template: the content ID (SKU) of the product whose photo shows on the message.
from
string
No
Which of your WhatsApp numbers sends the message, as shown under WhatsApp → Numbers (for example +91 98111 12222). Default: your default number.
reference
string
No
Your own id for this message, up to 100 characters, for example your order id. It comes back in the response and in Get a WhatsApp Message.
A field that isn't in this table is refused with 422, so a typo in a field name doesn't go unnoticed.
variables holds one value for each variable in the template's header and body. The keys depend on how the template was written:
The template's variables look like
Send
{{1}}, {{2}} (positional)
{"1": "Priya", "2": "SO-10422"}
{{first_name}}, {{order_id}} (named)
{"first_name": "Priya", "order_id": "SO-10422"}
An authentication template (login or verification code)
The code: {"1": "482913"}, up to 15 characters. It fills the message and the template's copy-code or autofill button.
Every variable needs a value. If one is missing, nothing is sent and the error lists the keys to send.
"1" and "{{1}}" both work as keys. Numbers are sent as text: 2499 becomes 2499.
WhatsApp doesn't allow a new line, a tab or more than four spaces in a row inside a value. Such a value is refused before sending.
A text header with a variable takes its value from header_text. In a template with positional variables, the header's {{1}} is separate from the body's {{1}}.
Keys the template doesn't use are ignored.
Example request: the template order_shipped has the header "Order {{1}}", the body "Hi {{1}}, your order {{2}} is on its way." and a Track button that opens https://shop.example.com/track/{{1}}.
Cost: each message is paid from your WhatsApp balance at WhatsApp's rate for the template's category and the recipient's country. A message WhatsApp refuses is refunded.
Inbox and contact: the message shows in the contact's conversation in the Inbox, labelled API, and in the contact's messages. When the person replies, the reply lands in the same conversation and opens WhatsApp's 24-hour window, like any other reply.
Delivery:sent means WhatsApp accepted it. Whether it was delivered or read, or why it failed, shows a few seconds later in Get a WhatsApp Message, in the Inbox and in Contact Messages.
Opt-out: a contact who opted out of all messages is never sent anything, and a marketing template isn't sent to a contact who stopped WhatsApp marketing (STOP, Stop promotions or Stop marketing in WhatsApp). Utility and authentication templates still go. The request returns 422 with opted_out.
Sending limits: the per-channel limits under Settings → Sending Limits apply to journeys and campaigns, not to this API. Your system decides how often a person gets a message.
Marketing templates: WhatsApp limits how many marketing messages one person gets from all businesses. When it holds one back, the message's status becomes failed with WhatsApp's reason.
Nothing is charged or sent when the request has a problem. The body is:
JSON
{ "detail": { "error": "missing_values", "message": "Missing a value for {{2}}. Send variables: {\"2\": \"...\"}.", "missing": ["2"], "variables": ["1", "2"] }}
error is a fixed word your code can check. message is a sentence that says what to change. missing_values also lists the missing keys and every key the template takes in variables.
Status
detail.error
When
400
whatsapp_not_ready
WhatsApp isn't connected, setup isn't finished, payment setup with Meta is still pending, Meta restricted the account, or marketing messages are paused on the sending number. detail.message says which.
400
template_not_approved
The template is pending, rejected, paused or disabled. detail.template_status holds its status.
401
The API key is missing or not valid.
402
balance_too_low
The WhatsApp balance is too low. Recharge under Usage & Plan → Usage & balances.
404
template_not_found
No template with this template_id in your workspace, no template with this name on the sending number's WhatsApp account, or no version in this language (detail.languages lists the template's languages).
422
template_required
Neither template_id nor template_name was sent.
422
language_required
template_name matches the template in more than one language. Send language.
422
missing_values
A variable, the header value, header_media_url, button_url_value, coupon_code or product_retailer_ids is missing.
422
invalid_values
A value has a new line, a tab or more than four spaces in a row, is too long, or isn't text or a number, or a click-counting button got something other than a full https:// address.
422
invalid_number
to isn't a phone number, or has no country code.
422
unknown_from_number
from isn't one of your numbers under WhatsApp → Numbers.
422
opted_out
The contact opted out of all messages, or stopped WhatsApp marketing and this is a marketing template.
422
A field is missing, has the wrong type, or isn't a field of this endpoint. detail is then a list of the fields to fix.
502
send_failed
WhatsApp refused the message when it was sent. detail.message holds WhatsApp's reason. It shows as failed in the Inbox and is refunded. A number without WhatsApp is usually accepted first and then turns failed in Get a WhatsApp Message.
Returns one WhatsApp message with its status: sent, delivered, read or failed, with the time of each step and WhatsApp's reason when it failed. Use it after Send a WhatsApp Template to check that the message reached the person.
It works for any WhatsApp message of your workspace, including ones sent by journeys, broadcasts or the Inbox, and replies people sent you.
The message_id that Send a WhatsApp Template returned (a number, for example 90311), or WhatsApp's id for the message (provider_message_id, starting with wamid.).
The person opened it. Only shows when the person has read receipts turned on in WhatsApp; otherwise it stays delivered.
clicked
The person opened a link in it that counts clicks.
failed
WhatsApp couldn't deliver it. error says why, for example the number has no WhatsApp account or WhatsApp held back a marketing message. A failed template message is refunded.
received
A message the person sent you.
Statuses only move forward: a message that was read doesn't go back to delivered. WhatsApp usually reports delivery within seconds, but a phone that is off reports it when it comes back online. If you check in a loop, wait at least 30 seconds between checks.
Create and work LemuTickets tickets from your ERP or other systems with the LemuTickets REST API
https://docs.lemuai.com/tickets-api/overview
LemuTickets is the service desk in the Lemu family: complaints, requests, tasks and incidents become tickets with an owner, a status, a deadline and a full history. The app at tickets.lemuai.com is built on this same API, so anything your team does in the app, your own systems can do too.
This reference covers what an ERP or back-office system usually needs:
Task
Endpoint
Raise a ticket when something goes wrong in your system
The version (v1) is part of the path. Changes within v1 only add things: new endpoints, new optional fields and new response fields. Write your code so it ignores response fields it does not know.
Send an API key in the Authorization header. Create keys in LemuTickets under Settings → API keys and webhooks. See Authentication for scopes and OAuth apps.
Your own server talks to LemuTickets, for example your ERP syncing tickets. This is the usual choice.
OAuth app
You build an app that acts for a person who approves it (authorization code), or a server integration that should not use a long-lived key (client credentials).
Both are sent as a bearer token in the Authorization header.
API keys, client secrets and access tokens act on your organization's data. Keep them on your server. Never put them in a browser, a mobile app or a public repository. To show tickets in a browser, use an embed token instead.
In LemuTickets, open Settings → API keys and webhooks and stay on the API keys tab.
Click Create key.
Fill in the form:
Name: where the key is used, for example ERP sync.
Mode: Live keys start with ltk_live_, Test keys with ltk_test_. The mode only labels the key; both work on the same organization and data.
Scopes: pick a preset (Read only, Agent or Full access) or Custom to choose scopes one by one. See scopes below.
Projects: limit the key to some projects. Empty means every project.
Requests per minute: the key's rate limit. The default is 600.
Allowed IP addresses: single addresses or CIDR ranges the key may be used from. Empty means any address.
Expires: never, or on a date you choose.
Copy the key. The full key is shown only once. Store it straight away in a secrets manager or an environment variable.
You need the api_keys.manage permission to see this page (organization owners and admins have it). You cannot give a key a scope you do not have yourself.
To stop a key working, revoke it on the same page. A revoked or expired key is rejected at once.
Each key acts as its own user, named API: followed by the key's name (for example API: ERP sync). Tickets the key creates show this user as the reporter, and comments it writes show it as the author.
A key does not see restricted tickets unless they are shared with that user, and it only sees the projects you chose when you created it.
Use this when your app acts for a LemuTickets user. The token can never do more than that user can do now, and only within the scopes they approved.
1. Send the user to the consent screen. Create a random code_verifier (43 to 128 characters) and its SHA-256 code_challenge (base64url, no padding), then open:
The URL is split over lines here to make it easier to read; send it as one line with the values URL-encoded. PKCE with S256 is required for every app. scope is a space-separated list; leave it out to ask for all of the app's scopes. After the user approves, they return to your redirect_uri with code and your state. The code expires after 5 minutes and works once.
3. Call the API with Authorization: Bearer lto_.... Access tokens last 1 hour.
4. Refresh before the access token expires. Refresh tokens last 30 days and change every time you use one: store the new one each time. Using an old refresh token again ends the whole grant, and the user has to approve the app again.
The response has an access_token that lasts 1 hour and no refresh token: ask for a new one when it expires. Leave out scope to get all of the app's scopes.
A client credentials token is not tied to a user, so endpoints that record a person need one in the request. For example, Log work needs user_id.
List endpoints that can return many items use cursors. Send limit to choose the page size, and pass the next_cursor from one response as cursor in the next request. Keep every other parameter the same.
cURL
curl -G https://api.tickets.lemuai.com/v1/tickets \ -H "Authorization: Bearer ltk_live_your_api_key" \ --data-urlencode "q=project = SUP ORDER BY created ASC" \ --data-urlencode "limit=100"
Pass it as cursor to get the next page. null on the last page.
total
Only on List and search tickets: the number of matching tickets when you send with_total=true, otherwise null.
Treat the cursor as an opaque string. It is a position in the result list, so if tickets change while you page through them, a ticket can show up twice or move to a page you already read. For a full sync, sort by a field that does not change (ORDER BY created ASC) and de-duplicate by id.
Shorter lists (comments on a ticket, transitions, projects, webhooks) return everything at once as {"data": [...]}, without a cursor.
Networks fail. If you send a request and get no answer, you cannot tell whether it worked. An idempotency key lets you send it again safely.
Add an Idempotency-Key header with a value that is unique to the action, for example your own record id:
cURL
curl -X POST https://api.tickets.lemuai.com/v1/tickets \ -H "Authorization: Bearer ltk_live_your_api_key" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: erp-complaint-58213" \ -d '{ "project": "SUP", "title": "Refund not received for order 58213" }'
The first request runs normally and its response is saved.
A later request with the same key and the same body gets the saved response back, with the header Idempotent-Replayed: true. Nothing is created twice.
The same key with a different body fails with 409 and the code idempotency_mismatch.
Keys are kept per organization and per endpoint path for 24 hours. Keys can be up to 200 characters; a longer key fails with 422 and the code idempotency_key_too_long.
Tickets have two more ways to avoid duplicates, which work without the header:
source_ref: if a ticket with the same source and source_ref already exists, creating it again returns the existing ticket with status 200 instead of 201.
external_id: must be unique. Creating a second ticket with the same external_id fails with 409 and the code duplicate_external_id.
Every ticket has a version number. It goes up every time the ticket changes, including when someone comments, logs work, transitions it, or an automation updates it. The current version is in the ticket's version field and in the ETag header of Get a ticket, Create a ticket and Update a ticket.
To make sure you do not overwrite someone else's change, send the version you last read in an If-Match header on Update a ticket and Transition a ticket:
If the ticket changed since then, nothing is saved and you get 412:
JSON
{ "error": { "type": "precondition_failed", "code": "version_mismatch", "message": "The ticket changed since you loaded it", "request_id": "4f1d9c2b7a6e4e0f8c3b1a2d5e6f7a8b", "data": { "current_version": 8 } }}
Get the ticket again, decide whether your change still makes sense, and retry with the new version. If-Match accepts the plain number (7) or the quoted forms ("7", W/"7"). Without If-Match, the change is applied to whatever is current.
Each API key has its own limit per minute, set when the key is created (600 by default). OAuth tokens that act for a user share that user's limit of 1,200 requests per minute. The window slides, so a short burst does not lock you out for a full minute.
Responses carry the current state:
Header
Description
RateLimit-Limit
Requests allowed per minute.
RateLimit-Remaining
Requests left in the current window.
Over the limit, requests fail with 429. The Retry-After header and the error's data.retry_after both say how many seconds to wait:
JSON
{ "error": { "type": "rate_limited", "code": "rate_limited", "message": "Too many requests. Try again in 12 seconds.", "request_id": "9a0b1c2d3e4f40a1b2c3d4e5f6a7b8c9", "data": { "retry_after": 12, "limit": 600, "window": 60 } }}
If you need a higher limit for a key, create a new key with a higher Requests per minute value.
Every response has an X-Request-Id header, and every error repeats it as request_id. You can send your own X-Request-Id and it is used instead, which makes it easy to match your logs with ours.
Errors
The error shape, HTTP status codes and common error codes returned by the LemuTickets API
Retry 429 after the number of seconds in Retry-After.
Retry 500 and other 5xx responses with exponential backoff. They are usually temporary. A 5xx can come back without the JSON body above, so check the status before parsing. Use an idempotency key on creates so a retry never makes a duplicate.
On 412, get the ticket again, check that your change still applies, and retry with the new version.
On 409duplicate_external_id, the ticket already exists: use the key in data instead of creating another.
Do not retry other 4xx responses without changing the request. Read code and field_errors to see what to fix.
Searching with TQL
Find tickets with the Ticket Query Language: fields, operators, dates, sorting and examples
https://docs.lemuai.com/tickets-api/tql
TQL (Ticket Query Language) is how you search tickets. It is the same language the LemuTickets app uses for filters, queues and saved views, so a filter you build in the app works in the API too.
A query is one or more conditions joined with AND and OR, followed by an optional ORDER BY:
Text
field operator value [AND|OR field operator value ...] [ORDER BY field [ASC|DESC], ...]
AND binds tighter than OR. Use parentheses to group: (priority = p1 OR sla.breached = true) AND project = SUP.
Two conditions side by side without a keyword are joined with AND.
NOT in front of a condition or group negates it: NOT labels in (spam).
Keywords (AND, OR, NOT, IN, IS, EMPTY, ORDER BY, ASC, DESC) are not case sensitive. Field names are not case sensitive.
Put values with spaces or special characters in double or single quotes: status = "Waiting on customer".
A quoted text or a word on its own is a full-text search of the title and description: "refund not received". A ticket key on its own, like SUP-1042, finds that ticket.
Label text. labels in (refund, urgent) matches tickets with any of them
title
The title
Text (use ~ to search inside it)
description
The description
Text
text
Full-text search of title and description
Text
created
When it was created
Date
updated
Last change
Date
resolved
When it was resolved
Date
closed
When it was closed
Date
due
The due date
Date
first_response
First public reply
Date
status_changed
Last status change
Date
sla.next_due
The next SLA deadline
Date
sla.breached
An SLA target was missed
true or false
escalation_level
How many times it was escalated
Number
reopened
How many times it was reopened
Number
csat
The customer's satisfaction score
Number
time_spent
Logged work, in minutes
Number
restricted
Visible only to some people
true or false
parent
The parent ticket
Ticket key
watcher
A user watching the ticket
User id
external_id
Your own id for the ticket
Text
cf.<key>
A custom field
Depends on the field. Numbers can use > and <
ai.<key>
A value the AI set during triage, such as ai.category
Text
status_category is usually better than status in integrations: each project names its statuses differently, but every status belongs to one of the four categories.
Add ORDER BY at the end with one or more fields, each ASC (default) or DESC. Empty values sort last. Without ORDER BY, the most recently updated tickets come first.
You can sort by created, updated, resolved, due, sla.next_due, key (or number), title, priority, status (or status_category), escalation_level, csat and status_changed.
A valid query returns "valid": true and the same fields list. When a query in List and search tickets is invalid, the request fails with 422 and a tql_* error code.
Webhooks
Get signed LemuTickets events at your endpoint: subscribing, the event list, payloads, verifying signatures and retries
https://docs.lemuai.com/tickets-api/webhooks
Webhooks tell your system when something happens in LemuTickets, such as a new ticket, a status change or a customer reply, so you don't have to poll. LemuTickets sends an HTTPS POST with a JSON body to your URL for every event you subscribe to.
Open Settings → API keys and webhooks and select the Webhooks tab.
Click Add webhook.
Enter the Endpoint URL, an optional Description, the Events to send (use area.* for every event of that kind, for example ticket.*), and optionally the Projects to send events for. Empty means all projects.
The URL must be public. Private, local and internal addresses are refused.
On the same tab you can see each webhook's Deliveries with the response your endpoint gave, Send again a delivery, Send test event, and Rotate secret. The old secret stops working as soon as you rotate it.
A ticket was flagged or unflagged as a major incident
comment.created
A reply or internal note was added
comment.delivery_updated
A reply's delivery status changed (for example, the email or WhatsApp message was delivered or failed)
sla.warning
An SLA target is close to breach
sla.breached
An SLA target was breached
csat.submitted
A requester rated a ticket
approval.requested
An approval was requested
approval.decided
An approval was approved or rejected
worklog.created
Time was logged on a ticket
requester.created
A requester was created
requester.updated
A requester was updated
account.updated
An account was created or updated
assignment.unassigned
A ticket stayed unassigned longer than the project allows
asset.created
An asset was created
asset.updated
An asset changed
problem.created
A problem record was created
problem.updated
A problem record changed
change.created
A change request was created
change.updated
A change request changed status or was voted on
visit.updated
A field visit was scheduled or changed
visit.reminder
A field visit is due tomorrow
ai.triaged
The AI classified a new ticket
autopilot.action_proposed
Autopilot proposed an action (inside its review window)
autopilot.action_done
Autopilot carried out an action
lemu.issue_suggested
Lemu AI found an issue in a conversation and it is waiting for review
webhook.disabled
A webhook subscription was turned off after repeated failures
GET /v1/events/catalog returns the same list as {"data": [{"type", "description"}]}.
Patterns use * as a wildcard: ticket.* matches every ticket event, * matches everything. Each pattern must match at least one event.
When a webhook is limited to some projects, it only gets events that belong to a ticket in those projects. Events that are not about a ticket (requesters, accounts, webhook.disabled) are only sent to webhooks without a project filter.
The event id. It stays the same on every retry and redelivery, so use it to ignore events you have already handled.
type
The event name from the list above.
created_at
When the event was queued.
org_id
Your organization's id.
data.actor
Who caused it: type is user, api_key, integration, requester, automation, ai or system, with id and name.
data.ticket
For ticket and comment events: the whole ticket as it is when the event is sent. See the ticket object. Shortened above.
data.changes
For ticket.updated: each changed field as [old, new], for example {"priority": ["p3", "p1"]}. Empty for other events.
data.comment
For comment.* events: the comment, in the same shape as List comments.
data.details
Event-specific details, for example the from and to status of a transition, or the minutes of a worklog.
Events that are not about a ticket put their fields directly in data, for example {"actor": {"type": "system"}, "requester_id": "8b4d6f2a-..."} for requester.created. Fetch the full object with the API if you need it.
comment.created is sent for internal notes too. Check data.comment.visibility (public or internal) before showing a comment to a customer.
Check every delivery before you trust it. The signature is an HMAC-SHA256, in hex, of the timestamp, a dot, and the raw request body, using your webhook's signing secret (whsec_...) as the key:
Text
v1 = hex(HMAC_SHA256(secret, "<t>.<raw body>"))
Read t and v1 from the X-LemuTickets-Signature header.
Compute the HMAC over the raw body bytes as received. Parsing and re-encoding the JSON changes the bytes and breaks the check.
Compare with v1 in constant time.
Reject the delivery if t is more than 5 minutes from your clock, to stop replays.
Node.js
JavaScript
import crypto from "node:crypto";import express from "express";const app = express();const SECRET = process.env.LEMU_TICKETS_WEBHOOK_SECRET; // whsec_...app.post("/lemutickets/webhook", express.raw({ type: "application/json" }), (req, res) => { const header = req.get("X-LemuTickets-Signature") || ""; const parts = Object.fromEntries(header.split(",").map((p) => p.split("=", 2))); const t = Number(parts.t); const expected = crypto .createHmac("sha256", SECRET) .update(`${parts.t}.`) .update(req.body) .digest("hex"); const ok = parts.v1 && parts.v1.length === expected.length && crypto.timingSafeEqual(Buffer.from(parts.v1), Buffer.from(expected)) && Math.abs(Date.now() / 1000 - t) <= 300; if (!ok) return res.status(400).send("bad signature"); const event = JSON.parse(req.body.toString("utf8")); // Handle the event, then answer quickly with a 2xx res.sendStatus(204);});
Python
Python
import hashlibimport hmacimport osimport timefrom flask import Flask, abort, requestapp = Flask(__name__)SECRET = os.environ["LEMU_TICKETS_WEBHOOK_SECRET"] # whsec_...@app.post("/lemutickets/webhook")def lemutickets_webhook(): header = request.headers.get("X-LemuTickets-Signature", "") parts = dict(p.split("=", 1) for p in header.split(",") if "=" in p) t, sig = parts.get("t", ""), parts.get("v1", "") body = request.get_data() # raw bytes expected = hmac.new(SECRET.encode(), f"{t}.".encode() + body, hashlib.sha256).hexdigest() if not t.isdigit() or not hmac.compare_digest(sig, expected): abort(400) if abs(time.time() - int(t)) > 300: abort(400) event = request.get_json() # Handle the event, then answer quickly with a 2xx return "", 204
Answer with any 2xx status within 10 seconds. Do slow work after you answer, for example in a queue.
Redirects are not followed, and any other status, a timeout or a connection error counts as a failure.
Failed deliveries are retried with growing gaps (30 seconds, 1 minute, 2 minutes, 4 minutes and so on, up to 1 hour between tries) for 24 hours. After that the delivery is marked failed. You can still send it again from Deliveries.
Deliveries go out within about 10 seconds of the event, several at a time, so they can arrive out of order. Use created_at and the ticket's version to tell which is newer.
After 50 failed attempts in a row, the webhook is turned off, its pending deliveries are marked failed, and a webhook.disabled event is sent to any other webhook subscribed to it. Fix your endpoint, then turn Send events back on in the webhook's settings. That resets the failure count.
Show a customer's tickets, a request form or one ticket inside your own app with embed tokens and the <lemu-tickets> element
https://docs.lemuai.com/tickets-api/embedding
The <lemu-tickets> element puts LemuTickets screens inside your ERP, customer portal or website, without you building them. It shows one customer (a requester) their own tickets, lets them raise a new one, and lets them reply. Your agents see and answer everything in LemuTickets as usual.
It works in two steps:
Your server asks the API for a short-lived embed token for the signed-in customer.
Your page loads the script and adds a <lemu-tickets> element with that token.
Never put an API key in a web page. An embed token is safe to put in the page: it only works for one requester, only on the embed screens, only from the sites you list, and only for a short time.
Load the script once per page, then add an element for each screen:
HTML
<script src="https://api.tickets.lemuai.com/v1/public/embed.js" async></script><!-- The customer's tickets (token with scope "list") --><lemu-tickets token="TOKEN_FROM_YOUR_SERVER" view="list"></lemu-tickets><!-- A "raise a request" form (token with scope "create") --><lemu-tickets token="TOKEN_FROM_YOUR_SERVER" view="create"></lemu-tickets><!-- One ticket with its replies (token with scope "ticket") --><lemu-tickets token="TOKEN_FROM_YOUR_SERVER" view="ticket" ticket="SUP-1042"></lemu-tickets>
Attribute
Description
token
The embed token from step 1. Required.
view
list (default), create or ticket. It should match the token's scope.
ticket
The ticket key, for view="ticket".
status
Optional, for view="list". open shows every ticket that is not done. Otherwise a comma-separated list of status categories, for example waiting or new,open.
The customer only ever sees their own tickets and public replies. Internal notes stay hidden. Tickets they raise have the source portal.
Tokens expire (after 60 minutes by default). Ask your server for a new token each time the page loads. If the page stays open a long time, fetch a new token before expires_at and set it on the element:
network_error ("Could not reach the support service.")
Often the page's origin is not in the token's allowed_origins, so the browser blocks the response. Origins must match exactly, including https and any port.
embed_token_expired
The token ran out. Get a new one from your server.
embed_scope
The token's scope does not allow this view, for example a create token used with view="list".
The Ticket Object
The fields of a LemuTickets ticket, as returned by every ticket endpoint and webhook
A ticket is one complaint, request, task, incident or question, with an owner, a status, a deadline and a full history. Every ticket belongs to a project (for example SUP) and gets a key from it (SUP-1042). Wherever an endpoint takes {ref}, you can pass the key or the ticket's id.
Creates a ticket in a project. The ticket starts in the workflow's first status unless you choose one, and gets the next number in the project (for example SUP-1042).
After it is created, the project's assignment rules, SLA policy and AI triage run as they do for tickets made in the app.
A unique value for this ticket, for example your own record id. Sending the same request again returns the first response instead of a second ticket. See idempotency keys.
Ticket type name (Complaint) or id. Defaults to the project's default type.
priority
string
No
p1, p2, p3 or p4. Default p3.
severity
string
No
Optional severity, for incidents.
status
string
No
Status name or id to start in. Defaults to the workflow's first status.
source
string
No
Where the ticket came from. Default api. One of voice, whatsapp, web_chat, email, slack, teams, api, portal, web_form, manual, lemu_copilot, automation, journey.
source_ref
string
No
The id of the item in the source system. If a ticket with the same source and source_ref exists, it is returned instead of creating a new one.
external_id
string
No
Your own id for the ticket. Must be unique: a second ticket with the same value fails with 409.
requester_id
string (UUID)
No
An existing requester.
requester
object
No
Find or create the requester inline (see below). Used when requester_id is not sent.
account_id
string (UUID)
No
The customer account. Defaults to the requester's account.
assignee_user_id
string (UUID)
No
Assign to this person. They must be an active member of your organization.
assignee_team_id
string (UUID)
No
Assign to this team. Defaults to the project's default team when no person is set.
labels
array of strings
No
Labels to add.
due_at
string (date-time)
No
A due date, separate from SLA deadlines.
custom_fields
object
No
Values for the project's custom fields, by key. Required custom fields must be sent.
parent_id
string (UUID)
No
Make this a sub-task of another ticket.
restricted
boolean
No
Only the assignee, the reporter, admins and people it is shared with can see it. Default false.
Send requester to link the ticket to a customer without looking them up first. LemuTickets finds an existing requester by lemu_contact_id, email, phone, WhatsApp id or external_id, in that order, and creates one if there is no match. Details on an existing requester are only filled in where they are empty, never overwritten.
Field
Type
Description
name
string
Full name.
email
string
Email address.
phone
string
Phone number. Numbers without a country code are read as Indian (+91).
whatsapp_id
string
WhatsApp number.
external_id
string
Your own id for the customer.
lemu_contact_id
integer
The contact's id in Lemu AI, if you use both products.
language
string
Preferred language, for example hi or en.
A new requester whose email domain matches an account is added to that account.
Example request:
cURL
curl -X POST https://api.tickets.lemuai.com/v1/tickets \ -H "Authorization: Bearer ltk_live_your_api_key" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: ERP-CMP-58213" \ -d '{ "project": "SUP", "type": "Complaint", "title": "Refund not received for order 58213", "description": "Customer paid on 12 November and the order was cancelled the same day.", "priority": "p2", "external_id": "ERP-CMP-58213", "labels": ["refund"], "custom_fields": { "order_id": "58213" }, "requester": { "name": "Priya Sharma", "email": "priya@example.com", "phone": "+919876543210", "external_id": "CUST-20931" } }'
See the ticket object for every field. Assignment, SLA and triage can still change the ticket right after it is created, so version and the assignee may move on quickly.
200 with the existing ticket, when a ticket with the same source and source_ref already exists.
No project with that key or id, or the key cannot access it
409
duplicate_external_id
A ticket with this external_id exists. data.key is its key
409
idempotency_mismatch
The Idempotency-Key was used before with a different body
422
project_archived
The project is archived
422
invalid_type, invalid_status
The type or status does not exist in this project
422
invalid_assignee, invalid_team, invalid_requester
The assignee, team or requester does not exist
422
invalid_source
source is not one of the allowed values
422
invalid_custom_fields
A custom field value is wrong or a required one is missing. See field_errors
422
invalid_fields
A field has the wrong type or length. See field_errors
List and Search Tickets
List LemuTickets tickets a page at a time, filtered with simple parameters or a TQL query
https://docs.lemuai.com/tickets-api/tickets/list
Returns the tickets you can see, a page at a time. Filter with the simple parameters, with a TQL query in q, or both. All filters are combined with AND.
GET/v1/tickets
Needs the tickets.read scope. Deleted tickets are never returned.
The example is shortened; the response has every ticket field. A change fires the ticket.updatedwebhook with the changed fields, and ticket.assigned when the assignee or team changed. The new assignee becomes a watcher.
Returns the transitions a ticket can make from its current status, as set in the project's workflow. Use it to build "Start work", "Resolve" or "Close" buttons in your own system, and to find the transition_id or to_status for Transition a ticket.
A comment to add with the move. Some transitions require one.
comment_visibility
string
No
internal (default) for a note to your team, or public to reply to the requester.
fields
object
No
Ticket fields to change at the same time, with the same names as Update a ticket, for example {"priority": "p3"}.
If the transition has required_fields, they must already have a value or be set in fields. For required custom fields, set them with Update a ticket first.
Example request:
cURL
curl -X POST https://api.tickets.lemuai.com/v1/tickets/SUP-1042/transitions \ -H "Authorization: Bearer ltk_live_your_api_key" \ -H "Content-Type: application/json" \ -H "If-Match: 5" \ -d '{ "to_status": "Resolved", "comment": "Your refund of Rs 4,250 was processed today. It reaches your account in 3 to 5 working days.", "comment_visibility": "public" }'
{ "id": "2f9c7e1a-5b3d-4c8e-9a6f-1d0e2b4c6a8f", "key": "SUP-1042", "title": "Refund not received for order 58213", "status": { "id": "7a2b3c4d-9e5f-4a6b-b7c8-d9e0f1a2b3c4", "name": "Resolved", "category": "done", "color": "green" }, "status_category": "done", "priority": "p1", "first_response_at": "2026-11-25T10:02:18.640000+00:00", "resolved_at": "2026-11-25T10:02:18.640000+00:00", "closed_at": null, "version": 8, "updated_at": "2026-11-25T10:02:18.640000+00:00"}
The example is shortened; the response has every ticket field.
Moving to a status in the done category sets resolved_at (or closed_at for a final status) and fires ticket.resolved or ticket.closed. Moving a done ticket back to another category reopens it: reopened_count goes up and ticket.reopened fires. Every move fires ticket.transitioned. See Webhooks.
Once approved, the transition is made with the comment and fields you sent. notes can also appear with other information, such as how the ticket was assigned. Always check status_category to see where the ticket ended up.
An approved WhatsApp template (name, language, variables) to send instead of free text. WhatsApp only allows free text within 24 hours of the customer's last message.
Public replies on WhatsApp go out through Lemu AI, so your organization needs the Lemu AI connection set up in LemuTickets. A ticket that came from a phone call has no channel to reply on: the reply is saved on the ticket but not sent.
type, id and name of the author (avatar_url for users).
channel
string
Where a public reply was sent: email, whatsapp, portal, slack, voice, or none for internal notes and replies with no channel.
delivery_status
string or null
For public replies sent on a channel: queued at first, then for example sent, delivered, read or failed. null when nothing is sent.
delivery_error
string or null
Why delivery failed.
mentions
array of strings
Mentioned user ids.
meta
object
Extra details, such as the WhatsApp template used.
attachments
array
Files on the comment: id, filename, content_type, size_bytes.
created_at
string
When it was added.
edited_at
string or null
When it was last edited.
Delivery happens after the response. Listen for the comment.delivery_updatedwebhook, or read the comment again with List comments, to see whether it arrived.
The first public reply on a ticket sets its first_response_at, which meets the first response SLA.
200 with all comments at once (this list is not paged).
JSON
{ "data": [ { "id": "f4a6c8e0-2b1d-4f3a-9c5e-7b9d1f3a5c7e", "ticket_id": "2f9c7e1a-5b3d-4c8e-9a6f-1d0e2b4c6a8f", "visibility": "public", "body": "Hi, I still have not received the refund for order 58213.", "body_text": "Hi, I still have not received the refund for order 58213.", "author_type": "requester", "author": { "type": "requester", "id": "8b4d6f2a-0c1e-4a3b-9d5f-7e6a8c0b2d4f", "name": "Priya Sharma" }, "channel": "email", "delivery_status": null, "delivery_error": null, "mentions": [], "meta": {}, "attachments": [ { "id": "a9c1e3b5-d7f2-4a4c-9e6b-8d0f2a4c6e8b", "filename": "bank-statement.pdf", "content_type": "application/pdf", "size_bytes": 182344 } ], "created_at": "2026-11-25T09:40:02.771000+00:00", "edited_at": null }, { "id": "1b3d5f7a-9c2e-4a4b-8d6f-0a2c4e6b8d1f", "ticket_id": "2f9c7e1a-5b3d-4c8e-9a6f-1d0e2b4c6a8f", "visibility": "public", "body": "Your refund of Rs 4,250 was processed today. It reaches your account in 3 to 5 working days.", "body_text": "Your refund of Rs 4,250 was processed today. It reaches your account in 3 to 5 working days.", "author_type": "user", "author": { "type": "user", "id": "0e2a4c6b-8d1f-4a3e-9b5c-7d9f1a3c5e7b", "name": "Arjun Mehta", "avatar_url": null }, "channel": "email", "delivery_status": "sent", "delivery_error": null, "mentions": [], "meta": {}, "attachments": [], "created_at": "2026-11-25T10:02:18.640000+00:00", "edited_at": null } ]}
Each item has the fields described in Add a comment. Download links for attachments come from GET /v1/attachments/{attachment_id} (see Upload an attachment).
Records time someone spent on a ticket. Logged time adds up in the ticket's time_spent_minutes and appears in reports, separately from how long the ticket was open.
Whether the time can be billed to the customer. Default false.
user_id
string (UUID)
No
The team member who did the work. Defaults to the caller: for an API key, the key's own user. Required with a client credentials token.
Example request:
cURL
curl -X POST https://api.tickets.lemuai.com/v1/tickets/SUP-1042/worklogs \ -H "Authorization: Bearer ltk_live_your_api_key" \ -H "Content-Type: application/json" \ -d '{ "minutes": 45, "started_at": "2026-11-25T08:30:00+05:30", "note": "Checked the payment gateway logs and raised the refund.", "billable": false, "user_id": "0e2a4c6b-8d1f-4a3e-9b5c-7d9f1a3c5e7b" }'
This endpoint does not use idempotency keys. If you retry after a timeout, check the ticket's time_spent_minutes first so the time is not logged twice.
Linking the same two tickets with the same kind again returns the existing link, so it is safe to retry. A new link fires the ticket.linkedwebhook on the source ticket.
A requester is the customer who raises tickets: a person with a name, email, phone, WhatsApp number and, optionally, an account (their company). This endpoint finds the requester that matches the details you send, or creates one.
POST/v1/requesters
Needs the requesters.write scope.
To keep requesters in step with records in your ERP, Upsert a requester by external ID is usually simpler: it matches on your own id and updates exactly the fields you send.
LemuTickets looks for an existing requester in this order and uses the first match:
lemu_contact_id
email (not case sensitive)
phone (formatting is ignored; numbers without a country code are read as +91)
whatsapp_id
external_id
If there is a match, empty details on it are filled in from your request. Details that are already set (by your team or an earlier request) are not overwritten. If there is no match, a new requester is created. A new requester whose email domain matches an account's domain is added to that account.
The contact's id in Lemu AI, if you use both products.
is_vip
boolean
No
Mark as VIP. Default false.
tags
array of strings
No
Tags.
custom_fields
object
No
Extra values. Merged into existing custom fields.
Send at least one of email, phone, whatsapp_id, external_id or lemu_contact_id, or every request creates a new requester.
is_vip and tags always replace the stored values, even on an existing requester. If you leave them out, the requester's VIP flag is set to false and its tags are cleared. Send the current values, or use Upsert a requester by external ID, which only changes the fields you send.
Creates or updates the requester with your own id for the customer, for example the customer number in your ERP. Use it whenever a customer record is created or changes in your system.
A requester with this external_id exists: the fields you send are updated. Fields you leave out keep their values.
None exists yet: LemuTickets looks for the same person by email, phone or WhatsApp number (see how the requester is found), or creates a new requester, and then applies the fields you send. Later requests with the same id update the same requester.
A requester created by this endpoint has your id in external_id. You can then use it to issue embed tokens (requester_external_id) and to search with GET /v1/requesters?q=CUST-20931.
Up to 50 of the requester's tickets, newest first: id, key, title, status_category, priority, created_at, csat_score. Use List and search tickets with requester_id for all of them.
csat_average
number or null
The average of the requester's ratings on these tickets, or null if they never rated one.
List and search the customer accounts (companies) in LemuTickets
https://docs.lemuai.com/tickets-api/accounts/list
An account is a customer company, such as a distributor, dealer or business customer. Requesters belong to an account, and tickets carry the requester's account. This endpoint returns accounts a page at a time, sorted by name, with how many open tickets each one has.
List the LemuTickets projects you can create tickets in
https://docs.lemuai.com/tickets-api/projects/list
A project is where tickets live, for example SUP for customer support or LOG for logistics. Each project has its own ticket types, workflow, fields and SLAs. This endpoint returns every project the key can access, sorted by name.
Get one LemuTickets project with its ticket types, workflow statuses and transitions
https://docs.lemuai.com/tickets-api/projects/get
Returns one project with its ticket types and workflows. Use it to learn the status names, categories and transitions to use in your integration, and the ticket type names you can send when creating tickets.
The response has the project fields (with permissions filled in), plus:
Field
Type
Description
permissions
array of strings
The scopes the caller has in this project.
types
array
The project's ticket types: id, name, description, icon, color, the workflow_id it uses, its sla_policy_id, is_subtask and archived.
workflows
array
The workflows the types use (shortened above).
Each workflow has:
Field
Description
initial_status_id
The status new tickets start in.
allow_any_transition
true if tickets can move to any status, ignoring transitions.
statuses
Each status: id, name, category (new, open, waiting, done), color, position, pauses_sla (the SLA clock stops in this status), is_resolution (reaching it counts as resolved), is_final (reaching it closes the ticket) and wip_limit.
transitions
Each transition: id, name, from_status_id (null means from any status), to_status_id, conditions (who may use it), validators (required_fields, require_comment), post_actions and approval.
Uploads a file of up to 25 MB, such as an invoice, a photo of a damaged product or a log file. You can attach it to a ticket straight away, or upload it first and then attach it to a comment with Add a comment (attachment_ids).
POST/v1/attachments
Attaching to a ticket needs the tickets.write scope in the ticket's project.
Creates a webhook subscription: LemuTickets sends a signed POST to your URL for every matching event. See Webhooks for the event list, the payload, verifying signatures and retries.
secret is only returned here. Store it straight away: you need it to verify signatures. If you lose it, issue a new one with Rotate secret in Settings → API keys and webhooks.
Field
Type
Description
id
string
The webhook's id.
url
string
The endpoint URL.
description
string
Your note.
events
array of strings
The event patterns, sorted and without duplicates.
project_ids
array of strings
The project filter. Empty means all.
enabled
boolean
Whether events are being sent.
failure_count
integer
Failed attempts in a row. Resets on a successful delivery.
disabled_reason
string or null
Why the webhook was turned off automatically, if it was.
last_success_at, last_failure_at
string or null
The last successful and failed delivery.
created_at, updated_at
string
Timestamps.
secret
string
The signing secret (whsec_...). Only in this response.
Returns every webhook subscription in your organization, oldest first. Check enabled, failure_count and disabled_reason to spot an endpoint that stopped accepting deliveries.
Deletes a webhook subscription. No more events are sent to its URL. This cannot be undone; to stop deliveries for a while instead, turn off Send events on the webhook in Settings → API keys and webhooks.