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

# Batch

> Send 1 to 100 identify and track calls in one request.

Send up to 100 `identify` and `track` items in one request; the JavaScript SDK sends every call this way. A batch is taken whole or not at all: one refused item refuses the request, and nothing of it is stored.

> [!NOTE]
>
> An item that names a `userId` needs the `Maqetin-Identity-Token` header in `required` mode, the default, unless you send the batch with a secret key. See [Identity verification](https://docs.maqetin.com/data/identity-verification.md).

## Limits

| What | Limit |
| - | - |
| Items | 1 to 100 |
| Body | 512 KiB |
| One item as stored | 900,000 bytes. Over it, the whole request is a `413`, with `at` naming the item. |
| Rate | Each item counts against the key's rate: a batch of 100 counts 100 events. See [Rate limits](https://docs.maqetin.com/api-reference/introduction.md#rate-limits). |

## Headers

**Authorization** `string` *required*

`Bearer mq_live_…`, your public key, or `Bearer mq_sec_…`, a secret key with the `events:write` scope. A secret key without that scope is a `401`.

**Maqetin-Identity-Token** `string`

A token your server signed for the person the batch names. One token covers the request, so every item with a `userId` must name the token's `sub`. A batch sent with a secret key needs no token. See [Identity token](https://docs.maqetin.com/api-reference/introduction.md#identity-token).

## Body

Any top-level field that is not listed here is a `400`.

**batch** `object[]` *required*

1 to 100 items. Each has a `type` and follows the rules of that call.

**an identify item**

**type** `string` *required*

`identify`.

**userId** `string` *required*

Your own id for the person, 1 to 256 characters.

**traits** `object` *required*

The traits, as in [Identify](https://docs.maqetin.com/api-reference/identify.md).

**channel** `string` *required*

`web`, `ios`, `android`, `node`, `python`, `go` or `rest`.

Optional: `anonymousId`, `messageId`, `timestamp`, `sessionId`, `sdkVersion` and `context`, as in [Identify](https://docs.maqetin.com/api-reference/identify.md).

**a track item**

**type** `string` *required*

`track`.

**event** `string` *required*

The name of the event, at least 1 character.

**channel** `string` *required*

`web`, `ios`, `android`, `node`, `python`, `go` or `rest`.

**userId** `string`

1 to 256 characters. An item needs a `userId`, an `anonymousId` or both.

**anonymousId** `string`

1 to 256 characters.

Optional: `properties`, `messageId`, `timestamp`, `sessionId`, `sdkVersion` and `context`, as in [Track](https://docs.maqetin.com/api-reference/track.md).

**sentAt** `string`

When your client sent the request, as an ISO 8601 date-time. Send it once, on the batch: an item cannot carry its own `sentAt`. See [Event time](https://docs.maqetin.com/api-reference/introduction.md#event-time).

## Response

**accepted** `number` *required*

The number of events taken: every item of the batch.

A `202` means the batch is stored. A refusal has `error` and, for a body problem, `at`, which points into the batch, such as `/batch` or `/batch/2`. See [Errors](https://docs.maqetin.com/api-reference/errors.md#event-routes).

```bash cURL theme={null}
curl https://in.maqetin.com/v1/batch \
  -H 'Authorization: Bearer mq_live_…' \
  -H 'Content-Type: application/json' \
  -d '{
  "batch": [
    {
      "type": "identify",
      "userId": "user_123",
      "traits": { "email": "ada@example.com", "plan": "pro" },
      "channel": "rest"
    },
    {
      "type": "track",
      "userId": "user_123",
      "event": "order.completed",
      "properties": { "orderId": "ord_1002", "total": 12 },
      "channel": "rest"
    },
    {
      "type": "track",
      "anonymousId": "anon_456",
      "event": "plan.viewed",
      "properties": { "path": "/pricing" },
      "channel": "web"
    }
  ]
}'
```

```json 202 theme={null}
{ "accepted": 3 }
```

```json 400 theme={null}
{ "error": "invalid payload", "at": ["/batch"] }
```

```json 413 theme={null}
{ "error": "event too large", "at": ["/batch/0"] }
```


## Related topics

- [Send through your own domain](https://docs.maqetin.com/sdk/javascript-own-domain.md)
- [JavaScript SDK](https://docs.maqetin.com/sdk/javascript.md)
- [API reference](https://docs.maqetin.com/api-reference/introduction.md)
- [API keys](https://docs.maqetin.com/workspace/api-keys.md)
- [Events](https://docs.maqetin.com/data/events.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.