# Track Event Batch

`POST https://api.inboxjot.com/v1/events/batch`

Records up to 100 events in one request. The body is an array of Track Event bodies. Inboxjot checks every event first, and records none of them when one fails. Needs a Full key. A key limited to one domain answers 403. Send an optional `Idempotency-Key` header to retry safely. See Idempotency.

A batch counts as one request toward the rate limit of 10 requests per second per key.

## Body

An array of 1 to 100 event objects. Each event takes the fields below, the same as Track Event. When one event fails, the error message starts with its number, such as Event 2.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string \| null | No | Your ID for this event, 1 to 64 letters, numbers, `-` or `_`, such as a UUID. Inboxjot records an ID once for 24 hours, so a retry with the same ID is safe. IDs from a tracking key are checked per user, apart from your server's. |
| `event` | string | Yes | The event name, such as `signed_up`, 1 to 100 characters. Start with a letter or number, then use letters, numbers, `.`, `_`, `:` or `-`. |
| `email` | string \| null | No | The contact address. A new address creates a subscribed contact. Disposable addresses are refused. Send `email`, `user_id` or both. |
| `user_id` | string \| null | No | Your ID for the contact, 1 to 255 characters. With an email, it is saved on the contact. Without one, it must match a contact that has it. |
| `occurred_at` | string \| null | No | When the event happened, as ISO 8601 with an offset, such as `2026-11-14T09:30:00Z`. Leave it out for now. It must be within the last 400 days. An event older than 72 hours is recorded but starts no automation. A tracking key's events always use the time Inboxjot received them. |
| `properties` | object | No | The event properties, such as `{ "plan": "pro" }`, up to 16 KB as JSON. Automations started by the event can use them in their emails. |

## Response

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | object[] | No | One entry per event, in the order you sent them. |
| `data[].contact_id` | string | No | The contact the event belongs to. |

## Request

cURL:

```bash
curl -X POST https://api.inboxjot.com/v1/events/batch \
  -H "Authorization: Bearer $INBOXJOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '[
    {
      "event": "order.completed",
      "user_id": "usr_8842",
      "properties": {
        "order_id": "4821"
      }
    },
    {
      "event": "signed_up",
      "email": "marcus.lee@example.com",
      "occurred_at": "2026-11-14T09:30:00Z"
    }
  ]'
```

Node.js:

```javascript
import { Inboxjot } from 'inboxjot';

const inboxjot = new Inboxjot();

const { data } = await inboxjot.events.batch([
  { event: 'order.completed', user_id: 'usr_8842', properties: { order_id: '4821' } },
  {
    event: 'signed_up',
    email: 'marcus.lee@example.com',
    occurred_at: '2026-11-14T09:30:00Z',
  },
]);
```

Rust:

```rust
use inboxjot::{Event, Inboxjot};

let client = Inboxjot::from_env()?;

let result = client
    .events()
    .batch(&[
        Event {
            event: "order.completed".into(),
            user_id: Some("usr_8842".into()),
            ..Default::default()
        },
        Event {
            event: "signed_up".into(),
            email: Some("marcus.lee@example.com".into()),
            occurred_at: Some("2026-11-14T09:30:00Z".into()),
            ..Default::default()
        },
    ])
    .await?;
```

Go:

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

result, err := client.Events.Batch(ctx, []inboxjot.SendEventParams{
	{Event: "order.completed", UserID: "usr_8842", Properties: map[string]any{"order_id": "4821"}},
	{
		Event:      "signed_up",
		Email:      "marcus.lee@example.com",
		OccurredAt: time.Date(2026, 11, 14, 9, 30, 0, 0, time.UTC),
	},
})
```

Python:

```python
from inboxjot import Inboxjot

inboxjot = Inboxjot()

result = inboxjot.events.batch(
    [
        {"event": "order.completed", "user_id": "usr_8842", "properties": {"order_id": "4821"}},
        {
            "event": "signed_up",
            "email": "marcus.lee@example.com",
            "occurred_at": "2026-11-14T09:30:00Z",
        },
    ]
)
```

## Responses

| Status | Description |
| --- | --- |
| 202 | Accepted. Inboxjot records the events in the background. A batch is all or nothing: one invalid event refuses the whole batch. |
| 400 | The list is empty or has more than 100 events (60 with a tracking key), a field is missing or invalid, or the Idempotency-Key header is not valid. |
| 401 | The API key is missing, revoked or expired. |
| 403 | The key is a Sending key or is limited to one domain, or the request comes from outside its IP allowlist. |
| 404 | An event has a `user_id` that no contact has, and no email to create one. The message names the event, such as `Event 2: …`. |
| 409 | An event has an email and a `user_id` that belong to different contacts, or a request with the same Idempotency-Key is still running. |
| 413 | The body is larger than 2 MB. |
| 415 | The Content-Type header is not application/json. |
| 422 | The Idempotency-Key was already used with a different request. |
| 429 | Too many requests for this key. Wait for the seconds in the Retry-After header. |
| 500 | Something failed on our side. Retry later. |

202:

```json
{
  "data": [
    {
      "contact_id": "con_06d2mfk8r9wq3zh5ka2pe"
    },
    {
      "contact_id": "con_06d2mfk8rb4xk2vt9nq7d"
    }
  ]
}
```

400:

```json
{
  "name": "validation_error",
  "status": 400,
  "message": "The request body is not valid JSON",
  "errors": [
    {
      "message": "The request body is not valid JSON",
      "location": "body"
    }
  ],
  "request_id": "5f0c6a2e-8d1b-4c7a-9e3f-2b6d4a1c8e90"
}
```

401:

```json
{
  "name": "unauthorized",
  "status": 401,
  "message": "Unauthorized",
  "errors": [],
  "request_id": "5f0c6a2e-8d1b-4c7a-9e3f-2b6d4a1c8e90"
}
```

403:

```json
{
  "name": "forbidden",
  "status": 403,
  "message": "This key cannot be used from 203.0.113.7",
  "errors": [],
  "request_id": "5f0c6a2e-8d1b-4c7a-9e3f-2b6d4a1c8e90"
}
```

404:

```json
{
  "name": "not_found",
  "status": 404,
  "message": "Event 2: No contact has this user_id. Send an email with it to create the contact.",
  "errors": [],
  "request_id": "5f0c6a2e-8d1b-4c7a-9e3f-2b6d4a1c8e90"
}
```

409:

```json
{
  "name": "concurrent_idempotent_requests",
  "status": 409,
  "message": "A request with this idempotency key is still in progress. Try again later.",
  "errors": [],
  "request_id": "5f0c6a2e-8d1b-4c7a-9e3f-2b6d4a1c8e90"
}
```

413:

```json
{
  "name": "payload_too_large",
  "status": 413,
  "message": "The request body is too large",
  "errors": [],
  "request_id": "5f0c6a2e-8d1b-4c7a-9e3f-2b6d4a1c8e90"
}
```

415:

```json
{
  "name": "unsupported_media_type",
  "status": 415,
  "message": "The Content-Type must be application/json",
  "errors": [],
  "request_id": "5f0c6a2e-8d1b-4c7a-9e3f-2b6d4a1c8e90"
}
```

422:

```json
{
  "name": "invalid_idempotent_request",
  "status": 422,
  "message": "This idempotency key was already used with a different request",
  "errors": [],
  "request_id": "5f0c6a2e-8d1b-4c7a-9e3f-2b6d4a1c8e90"
}
```

429:

```json
{
  "name": "rate_limit_exceeded",
  "status": 429,
  "message": "Too many attempts. Try again later.",
  "errors": [],
  "request_id": "5f0c6a2e-8d1b-4c7a-9e3f-2b6d4a1c8e90"
}
```

500:

```json
{
  "name": "unknown_error",
  "status": 500,
  "message": "Something went wrong. Please try again later.",
  "errors": [],
  "request_id": "5f0c6a2e-8d1b-4c7a-9e3f-2b6d4a1c8e90"
}
```
