---
title: "Batching"
description: "Send up to 500 events per request."
canonical_url: "https://docs.logstrace.dev/guides/sending-logs/batching"
---
# Batching

> Send up to 500 events per request.

The request body can be one event, an array of events, or `{ "events": [...] }`.

<code-group>

```json [Object]
{ "events": [
  { "channel": "payments", "text": "Payment 8812 for order 10293 captured 49.90 USD" },
  { "channel": "payments", "level": "warn", "text": "Payment 8813 for order 10294 declined 120.00 USD" }
] }
```

```json [Array]
[
  { "channel": "payments", "text": "Payment 8812 for order 10293 captured 49.90 USD" },
  { "channel": "payments", "level": "warn", "text": "Payment 8813 for order 10294 declined 120.00 USD" }
]
```

</code-group>

Response: `{ "accepted": 2, "status": "ok" }`

## Limits

<table>
<thead>
  <tr>
    <th>
      Limit
    </th>
    
    <th>
      Value
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      Events per request
    </td>
    
    <td>
      1–500
    </td>
  </tr>
  
  <tr>
    <td>
      Body size
    </td>
    
    <td>
      2 MB
    </td>
  </tr>
  
  <tr>
    <td>
      Requests per key
    </td>
    
    <td>
      1,200 per minute
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        text
      </code>
    </td>
    
    <td>
      16 KB
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        data
      </code>
    </td>
    
    <td>
      32 KB per event
    </td>
  </tr>
</tbody>
</table>

A batch is all-or-nothing: if one event is invalid, the whole request is rejected with `400` and a message naming the event, for example `Invalid event. events.3.level: …`.

## Recommended pattern

Buffer events in memory and flush every second or every 200 events, whichever comes first. On `429`, wait for the time in the `Retry-After` header and retry the same batch. See the [integrations](https://docs.logstrace.dev/guides/integrations/http) for ready-made senders.


## Sitemap

See the full [sitemap](https://docs.logstrace.dev/sitemap.md) for all pages.
