# Track Events

An event tells Inboxjot that a contact did something in your app. Events start automations and resume runs that wait for them. The events API needs a key with Full access.

## Send an Event

```bash cURL
curl -X POST https://api.inboxjot.com/v1/events \
  -H "Authorization: Bearer $INBOXJOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "order.completed",
    "email": "riti@example.com",
    "data": { "order_id": "1042", "total": "$42.00" }
  }'
```

```javascript Node.js
import { Inboxjot } from 'inboxjot';

const inboxjot = new Inboxjot();

await inboxjot.events.send({
  name: 'order.completed',
  email: 'riti@example.com',
  data: { order_id: '1042', total: '$42.00' },
});
```

```rust Rust
use inboxjot::{Event, Inboxjot};
use serde_json::json;

let client = Inboxjot::from_env()?;

client
    .events()
    .send(&Event {
        name: "order.completed".into(),
        email: "riti@example.com".into(),
        data: json!({ "order_id": "1042", "total": "$42.00" })
            .as_object()
            .cloned()
            .unwrap_or_default(),
    })
    .await?;
```

```go Go
client := inboxjot.NewClient("")

result, err := client.Events.Send(ctx, inboxjot.SendEventParams{
	Name:  "order.completed",
	Email: "riti@example.com",
	Data:  map[string]any{"order_id": "1042", "total": "$42.00"},
})
```

```python Python
from inboxjot import Inboxjot

inboxjot = Inboxjot()

inboxjot.events.send(
    {
        "name": "order.completed",
        "email": "riti@example.com",
        "data": {"order_id": "1042", "total": "$42.00"},
    }
)
```

| Field | Description                                                                                                |
| ----- | ---------------------------------------------------------------------------------------------------------- |
| name  | Required. Up to 100 letters, numbers, dots, colons, dashes or underscores. Starts with a letter or number. |
| email | Required. The contact who did it.                                                                          |
| data  | Optional. A JSON object of up to 16 KB.                                                                    |

The API answers `202 Accepted` with the `contact_id`. Inboxjot sets the time of the event.

## What Happens Next

- If no contact has the email, Inboxjot creates one as subscribed.
- Automations with an Event received trigger for this name start a run.
- Runs of the contact that wait for this event continue.

> The automation editor lists the event names your app sent in the last 30 days.

## Use Event Data

Emails in an automation started by an event can use its data. Each top-level field becomes a variable such as `{{event.order_id}}`. Data from an event that resumes a Wait for Event step is not added.
