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.
Requests and responses#
- Base URL
https://app.lemuai.com/api/v1, HTTPS only. - Authenticate with the
X-API-Keyheader (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.5rupees, not paise) with an ISO 4217currency(INR).
Paging through results#
List endpoints use one of three styles. Each endpoint's page lists its own parameters.
| Style | Parameters | Next page | Used by |
|---|---|---|---|
| Page number | page (from 1), limit | page + 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 |
| Offset | limit, offset | offset + limit until offset reaches total | List Events (limit up to 500) |
| Cursor (newest first) | limit, before / before_id | Pass next_before / next_before_id from the last answer; stop when it's null | Contact Activity, Contact Messages (limit up to 200) |
Example, all contacts in pages of 500:
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 += 1Sizes and limits#
| What | Limit |
|---|---|
| Bulk Upsert Contacts | 5,000 contacts per request |
| Create or Update Records in Bulk | 1,000 records per request |
| One custom record | 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.
Retries#
- Retry on network errors,
429, and5xx, 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,404or422without changing the request: they won't succeed as sent. Thedetailfield says why (Errors).
Sending the same thing twice#
| Request | Safe to repeat? |
|---|---|
| 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) |
| Send a transactional email | No. 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?
Docs