# Quickstart

> Make your first LemuAI API calls in five minutes: create a key, add a contact, send an order event and start a call.

URL: https://docs.lemuai.com/api-reference/quickstart
For: Developers
Checked against LemuAI app version 1.0.12
Related: [Authentication](https://docs.lemuai.com/api-reference/authentication), [Send an Event](https://docs.lemuai.com/api-reference/events/trigger), [Webhooks](https://docs.lemuai.com/api-reference/webhooks), [Conventions](https://docs.lemuai.com/api-reference/conventions)

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.

## 1. Create an API key

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](https://docs.lemuai.com/website-pixel/overview) write keys there instead).
```bash
export LEMU_API_KEY="lemu_..."
```

## 2. Add or update a contact

**cURL**

```bash
curl -X POST https://app.lemuai.com/api/v1/contacts/upsert \
  -H "X-API-Key: $LEMU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"phone": "+919876543210", "first_name": "Priya", "email": "priya@example.com", "list_name": "API quickstart"}'
```

**JavaScript**

```js
const res = await fetch("https://app.lemuai.com/api/v1/contacts/upsert", {
  method: "POST",
  headers: { "X-API-Key": process.env.LEMU_API_KEY, "Content-Type": "application/json" },
  body: JSON.stringify({ phone: "+919876543210", first_name: "Priya", email: "priya@example.com", list_name: "API quickstart" }),
});
console.log(res.status, await res.json());
```

**Python**

```python
import os, requests

r = requests.post(
    "https://app.lemuai.com/api/v1/contacts/upsert",
    headers={"X-API-Key": os.environ["LEMU_API_KEY"]},
    json={"phone": "+919876543210", "first_name": "Priya", "email": "priya@example.com", "list_name": "API quickstart"},
    timeout=30,
)
print(r.status_code, r.json())
```

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](https://docs.lemuai.com/api-reference/contacts/upsert) for every field.

## 3. Send an order event

Orders sent as `Purchase` events count toward revenue and can start journeys.

**cURL**

```bash
curl -X POST https://app.lemuai.com/api/v1/events \
  -H "X-API-Key: $LEMU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"event_type": "Purchase", "phone": "+919876543210", "data": {"order_id": "A-1001", "value": 1499, "currency": "INR"}}'
```

**JavaScript**

```js
await fetch("https://app.lemuai.com/api/v1/events", {
  method: "POST",
  headers: { "X-API-Key": process.env.LEMU_API_KEY, "Content-Type": "application/json" },
  body: JSON.stringify({
    event_type: "Purchase",
    phone: "+919876543210",
    data: { order_id: "A-1001", value: 1499, currency: "INR" },
  }),
});
```

**Python**

```python
requests.post(
    "https://app.lemuai.com/api/v1/events",
    headers={"X-API-Key": os.environ["LEMU_API_KEY"]},
    json={"event_type": "Purchase", "phone": "+919876543210",
          "data": {"order_id": "A-1001", "value": 1499, "currency": "INR"}},
    timeout=30,
).raise_for_status()
```

Check it arrived: **Insights → Event Log** in the app, or [List Events](https://docs.lemuai.com/api-reference/events/list). See [Send an Event](https://docs.lemuai.com/api-reference/events/trigger).

## 4. Start a call

In the app, open a voice agent and add an **API Trigger** step; it shows the agent's trigger URL (with a UUID). Then:
```bash
curl -X POST https://app.lemuai.com/api/v1/public/agent/YOUR_TRIGGER_UUID \
  -H "X-API-Key: $LEMU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"phone_number": "+919876543210", "initial_context": {"first_name": "Priya", "order_id": "A-1001"}}'
```

The answer includes the run id. Get the result with [List Calls](https://docs.lemuai.com/api-reference/agents/runs/list), or have the agent push it to you with a [Webhook](https://docs.lemuai.com/api-reference/webhooks). See [Trigger an Outbound Call](https://docs.lemuai.com/api-reference/calls/trigger) for the exact URL and fields.

## Next

- [Webhooks](https://docs.lemuai.com/api-reference/webhooks): get call results pushed to you, and start journeys from your system.
- [Conventions](https://docs.lemuai.com/api-reference/conventions): pagination, limits, retries and idempotency.
- [Errors](https://docs.lemuai.com/api-reference/errors) and [API troubleshooting](https://docs.lemuai.com/troubleshooting/account-and-billing#api-keys).
- [OpenAPI file](https://docs.lemuai.com/openapi.json): import into Postman or generate a client.
