> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lekalao.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Events

> Tell Lekalao what a person did: what automations start on, and segments are built with.

An [event](/contacts/events) is something a person did, reported by your shop or your application. It is kept on their profile, may start an automation, feeds segments — and, named `order` with a `value`, counts as revenue.

## Record an event

```bash theme={null}
curl -X POST https://api.lekalao.com/v1/events \
  -H "Authorization: Bearer $LEKALAO_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "email": "ada@example.com",
    "name": "cart.abandoned",
    "reference": "cart-88213",
    "properties": {
      "url": "https://shop.example.com/cart/88213",
      "total": "27,500 FCFA",
      "items": [
        { "name": "Darjeeling first flush", "price": "15,000 FCFA", "quantity": 1 },
        { "name": "Teapot", "price": "12,500 FCFA", "quantity": 1 }
      ]
    }
  }'
```

| Field               |                                                                                                                                          |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `email`             | Who did it. Required. They do not have to be a subscriber yet: the event waits for them on their profile.                                |
| `name`              | Required, yours to choose: letters, numbers, spaces and `_ . : -`, 100 characters at most.                                               |
| `properties`        | Whatever describes it. The e-mails of the automation it starts read them directly: `{{ event.total }}`, `{% for item in event.items %}`. |
| `value`, `currency` | An integer in the smallest unit (`1250` is 12.50 €) and three letters. Each requires the other.                                          |
| `reference`         | Your own identifier. The same reference twice is recorded once: the second call answers `200` with `"status": "duplicate"`.              |
| `occurred_at`       | Now, when absent. At most one day ahead.                                                                                                 |

The answer is `201` with `{"data": {"index": 0, "status": "recorded", "id": "…"}}`.

## A batch

Up to **1,000** events under `events`. Each row gets its own answer, in the order it came — one bad row does not cost the others:

```json theme={null}
{
  "data": [
    { "index": 0, "status": "recorded", "id": "01a0…" },
    { "index": 1, "status": "invalid", "errors": { "email": ["The email field must be a valid email address."] } }
  ],
  "failed": 1
}
```

The call answers `200`, or `422` when **every** row is invalid.

## An order is revenue

An event named `order` that carries a `value` is credited to the last e-mail the person opened or clicked inside the attribution window, exactly as [`POST /v1/conversions`](/developers/conversions) does. Send one or the other for a sale, not both.

## What one person did

```bash theme={null}
curl "https://api.lekalao.com/v1/events?email=ada@example.com&name=order" \
  -H "Authorization: Bearer $LEKALAO_TOKEN" -H "Accept: application/json"
```

Most recent first, 50 by default, 200 at most (`per_page`). An address the team does not know answers an empty list.

## Contact fields

Fields give a type to what you send under `attributes` on a [subscriber](/developers/subscribers). `GET /v1/fields` lists them; `POST /v1/fields` creates one (`key`, `label`, `type`: `text`, `number`, `date` or `boolean`); `PATCH` changes its label or its type; `DELETE` removes it. A key you never declared creates a `text` field by itself. See [Contact fields](/contacts/fields).
