LemuAIDocs

Events · 5 min read

Send an Event

Send an event from your own system to record what a person did and start journeys for them

Open in ChatGPTOpen in ClaudeMarkdown

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.

POST/api/v1/events

Headers#

NameRequiredDescription
X-API-KeyYesAn API key from your organization. See Authentication.
Content-TypeYesapplication/json

Request body#

FieldTypeRequiredDescription
event_typestringYesThe 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.
phonestringNoThe person's phone number in international format, for example +919876543210, up to 50 characters.
emailstringNoThe person's email address, up to 254 characters.
external_idstringNoYour own id for the person, for example a CRM or customer id, up to 255 characters.
anonymous_idstringNoThe 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_namestringNoA 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.
dataobjectNoAny 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.

Event names#

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.

Orders and revenue#

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:

FieldTypeDescription
valuenumberThe order total in major units, for example 1499.5
currencystringAn ISO 4217 code, for example INR
order_idstringYour 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.

cURL
curl -X POST https://app.lemuai.com/api/v1/events \
  -H "X-API-Key: lemu_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "event_type": "Purchase",
    "phone": "+919876543210",
    "data": {
      "value": 1499.5,
      "currency": "INR",
      "order_id": "1042",
      "content_ids": ["SKU1"]
    }
  }'

How the contact is found#

LemuAI looks up every identifier you send (phone, email, external_id and anonymous_id) and works out which person they belong to:

  1. 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.
  2. 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.
  3. 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.

Example request:

cURL
curl -X POST https://app.lemuai.com/api/v1/events \
  -H "X-API-Key: lemu_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "event_type": "cart_abandoned",
    "phone": "+919876543210",
    "email": "priya@example.com",
    "external_id": "cust-58214",
    "list_name": "Abandoned carts",
    "data": {
      "first_name": "Priya",
      "cart_amount": 2499,
      "product_name": "Running shoes"
    }
  }'

Response#

201: the event was stored and matching journeys were queued.

JSON
{
  "event_id": 90412,
  "contact_id": 5531,
  "triggered_workflows": 0
}
FieldTypeDescription
event_idintegerThe id of the stored event. It appears in the Event Log.
contact_idinteger or nullThe 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_workflowsintegerAlways 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.

Using event data in a journey#

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;
  • only run for contacts in a chosen list.

See Journey nodes and triggers for the full trigger settings.

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.

Errors#

StatusWhen
401The API key is missing or not valid.
422event_type is missing or too long, or another field is too long or has the wrong type.

See Errors for the error format.