> For the complete documentation index, see [llms.txt](https://docs.roboflow.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.roboflow.com/deployment/monitoring-and-analytics/vision-events/batch-create-vision-events.md).

# Batch Create Vision Events

## About

This endpoint records multiple [Vision Events](/deployment/monitoring-and-analytics/vision-events.md) in a single request, up to 100 at a time. Use it when a deployment needs to ingest many observations at once, which is more efficient than creating events individually. To record a single event, see [Create a Vision Event](/deployment/monitoring-and-analytics/vision-events/create-a-vision-event.md).

## HTTP API

Create up to 100 vision events in a single request. This is more efficient than creating events individually when you need to ingest multiple events at once.

**Required scope:** `vision-events:write` or `device:update`

{% openapi src="/files/sCDP9kVopV4JkkRK7GDd" path="/vision-events/batch" method="post" %}
[openapi.yaml](https://1583372177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoksNmwps1HmYr8TqHDnX%2Fuploads%2Fgit-blob-dfdc1702ad3d1a62ad0a661e9609f6bbe2fc8d4c%2Fopenapi.yaml?alt=media)
{% endopenapi %}

### Example Request

```bash
curl -X POST "https://api.roboflow.com/vision-events/batch" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "events": [
      {
        "eventId": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
        "eventType": "quality_check",
        "useCaseId": "a1b3c8e1",
        "timestamp": "2024-01-15T10:30:00Z",
        "eventData": {
          "result": "pass"
        }
      },
      {
        "eventId": "9c4d6a2e-81f3-4b7a-bc9e-3f1a2d4e5c6b",
        "eventType": "quality_check",
        "useCaseId": "a1b3c8e1",
        "timestamp": "2024-01-15T10:31:00Z",
        "eventData": {
          "result": "fail"
        }
      }
    ]
  }'
```

### Request Body Parameters

* **`events`** (array, required, max 100): An array of event objects. Each event follows the same schema as the [Create a Vision Event](/deployment/monitoring-and-analytics/vision-events/create-a-vision-event.md#http-api) endpoint.

{% hint style="info" %}
To include images in your events, first upload each image using the [Upload a Vision Event Image](/deployment/monitoring-and-analytics/vision-events/upload-a-vision-event-image.md#http-api) endpoint, then reference the returned `sourceId` in the image object. See [Image Objects](/deployment/monitoring-and-analytics/vision-events/create-a-vision-event.md#image-objects) for details.
{% endhint %}

### Example Response

{% tabs %}
{% tab title="201" %}

```json
{
  "created": 2,
  "eventIds": ["f47ac10b-58cc-4372-a567-0e02b2c3d479", "9c4d6a2e-81f3-4b7a-bc9e-3f1a2d4e5c6b"]
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Batch size exceeds maximum of 100 events"
}
```

{% endtab %}

{% tab title="403" %}

```json
{
  "error": "Insufficient permissions for this resource."
}
```

{% endtab %}
{% endtabs %}

The response may also include a `warnings` object containing per-event validation warnings (keyed by event index), and a `deprecations` array if deprecated field names were used. See [Validation and Warnings](/deployment/monitoring-and-analytics/vision-events/create-a-vision-event.md#validation-and-warnings) for details.

## Python SDK

Create multiple vision events in a single request. The server allows up to 100 events per batch.

```python
import roboflow

roboflow.login()

rf = roboflow.Roboflow()
ws = rf.workspace()

result = ws.write_vision_events_batch([
    {
        "eventId": "e5f6a7b8-c3d4-4e5f-a0b1-c2d3e4f5a6b7",
        "eventType": "quality_check",
        "useCaseId": "a1b3c8e1",
        "timestamp": "2024-01-15T10:00:00Z",
        "eventData": {"result": "pass"},
    },
    {
        "eventId": "f6a7b8c9-d4e5-4f6a-b1c2-d3e4f5a6b7c8",
        "eventType": "quality_check",
        "useCaseId": "a1b3c8e1",
        "timestamp": "2024-01-15T10:01:00Z",
        "eventData": {"result": "fail"},
        "customMetadata": {"line": "A1"},
    },
])

print(result["created"])    # Number of events created
print(result["eventIds"])   # List of created event IDs
```

Each event in the list follows the same schema as a [single event](/deployment/monitoring-and-analytics/vision-events/create-a-vision-event.md#python-sdk). For full details on event schemas and validation behavior, see the [REST API reference](#http-api).
