LemuAIDocs

Getting Started · 2 min read · For developers

Conventions

How the LemuAI API pages through results, which limits apply, how to retry safely, and how to avoid counting the same order twice.

Open in ChatGPTOpen in ClaudeMarkdown

Requests and responses#

  • Base URL https://app.lemuai.com/api/v1, HTTPS only.
  • Authenticate with the X-API-Key header (Authentication).
  • Send JSON with Content-Type: application/json; answers are JSON.
  • Times are ISO 8601. Times LemuAI returns are in UTC.
  • Phone numbers are international format with country code: +919876543210.
  • Money is in major units (1499.5 rupees, not paise) with an ISO 4217 currency (INR).

Paging through results#

List endpoints use one of three styles. Each endpoint's page lists its own parameters.

StyleParametersNext pageUsed by
Page numberpage (from 1), limitpage + 1 until page reaches total_pages (or a page comes back short)List Contacts (limit up to 500), List Contact Lists (up to 100), List Contacts in a List (up to 1,000), List Calls
Offsetlimit, offsetoffset + limit until offset reaches totalList Events (limit up to 500)
Cursor (newest first)limit, before / before_idPass next_before / next_before_id from the last answer; stop when it's nullContact Activity, Contact Messages (limit up to 200)

Example, all contacts in pages of 500:

Python
import os, requests
 
page, contacts = 1, []
while True:
    r = requests.get(
        "https://app.lemuai.com/api/v1/contacts",
        headers={"X-API-Key": os.environ["LEMU_API_KEY"]},
        params={"page": page, "limit": 500},
        timeout=30,
    )
    r.raise_for_status()
    body = r.json()
    contacts += body["contacts"]
    if page >= body["total_pages"]:
        break
    page += 1

Sizes and limits#

WhatLimit
Bulk Upsert Contacts5,000 contacts per request
Create or Update Records in Bulk1,000 records per request
One custom record16 KB of data, key up to 255 characters, text values up to 2,000 characters
Event name1 to 100 characters
Segment rules30 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.

Retries#

  • Retry on network errors, 429, and 5xx, with a growing wait (1 s, 2 s, 4 s… up to about a minute) and a little randomness.
  • Don't retry 400, 401, 403, 404 or 422 without changing the request: they won't succeed as sent. The detail field says why (Errors).

Sending the same thing twice#

RequestSafe to repeat?
Upsert a contact, bulk upsert, create or update a recordYes. 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 callNo. 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)
Send a transactional emailNo. Each request sends an email

OpenAPI#

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.

Was this page helpful?