# Send Events

## Send Events

You can send Vision Events using a Workflow block, the REST API, or edge device backup.

* [Workflow Block](#workflow-block) - Workflows users will probably find it easiest to use the official Roboflow block
* [REST API](#rest-api) - Users choosing to deploy models outside of workflows can use our REST API
* [Edge Device Backup](#edge-device-backup) - Users deploying Roboflow Edge devices will find it most convenient to configure automated backup from the local event store on device

### Workflow Block

The recommended approach for most users. Add the **Vision Event** block to any Roboflow Workflow to automatically create events from inference results with no code needed.

#### Setup

{% stepper %}
{% step %}
**Open the Workflow Editor**

Navigate to **Workflows** in your workspace and open the workflow you want to add events to.
{% endstep %}

{% step %}
**Add the Vision Event Block**

Search for "Vision Event" in the block catalog and add it to your workflow.
{% endstep %}

{% step %}
**Connect Inputs**

Connect the image input and model prediction outputs to the Vision Event block.
{% endstep %}

{% step %}
**Configure the Use Case**

Set the Use Case name (`useCaseId`). You can also map custom metadata from upstream blocks.
{% endstep %}

{% step %}
**Deploy the Workflow**

Deploy or update your workflow. Events are created automatically each time the workflow runs.
{% endstep %}
{% endstepper %}

{% hint style="info" %}
The Workflow block handles image upload and event creation in a single step.
{% endhint %}

### REST API

For custom integrations or pipelines not using Workflows, you can send events directly via the REST API. For complete request and response schemas, see the [Vision Events API Reference](https://docs.roboflow.com/developer/rest-api/vision-events).

#### Authentication

All write endpoints require an API key with `visionEvents.write` or `device.update` scope. Pass the API key as a Bearer token:

```
Authorization: Bearer YOUR_API_KEY
```

#### End-to-End Example: Upload Image + Create Event

{% hint style="warning" %}
You must create a Use Case before sending events. Events referencing a `useCaseId` that does not exist will be rejected.
{% endhint %}

When sending events via the API, you first upload the image, then create the event referencing the uploaded image.

**Step 1: Upload the image**

```bash
curl -X POST "https://api.roboflow.com/vision-events/upload" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "file=@inspection_photo.jpg"
```

**Response:**

```json
{
  "success": true,
  "sourceId": "abc123def456",
  "url": "https://storage.googleapis.com/your-workspace/abc123def456/original.jpg"
}
```

**Step 2: Create the event, referencing the uploaded image**

```bash
curl -X POST "https://api.roboflow.com/vision-events" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "eventType": "quality_check",
    "useCaseId": "assembly-line-qa",
    "timestamp": "2026-03-30T14:30:00.000Z",
    "deviceId": "factory-cam-01",
    "streamId": "line-3",
    "images": [
      {
        "sourceId": "abc123def456",
        "objectDetections": [
          {
            "class": "defect",
            "x": 320,
            "y": 240,
            "width": 50,
            "height": 40,
            "confidence": 0.95
          }
        ]
      }
    ],
    "eventData": {
      "result": "fail"
    },
    "customMetadata": {
      "line_id": "line-3",
      "shift": "morning",
      "part_number": "PN-4421"
    }
  }'
```

**Response:**

```json
{
  "eventId": "evt-789ghi",
  "created": true
}
```

#### Batch Create Events

Send up to 100 events in a single request using the batch endpoint:

```bash
curl -X POST "https://api.roboflow.com/vision-events/batch" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "events": [
      {
        "eventType": "quality_check",
        "useCaseId": "alksjdflaalsf32",
        "eventData": { "result": "pass" },
        "customMetadata": { "line_id": "line-1" }
      },
      {
        "eventType": "quality_check",
        "useCaseId": "alksjdflaalsf32",
        "eventData": { "result": "fail" },
        "customMetadata": { "line_id": "line-2" }
      }
    ]
  }'
```

{% hint style="info" %}
Maximum 100 events per batch request.
{% endhint %}

### Edge Device Backup

For enterprise deployments where connectivity may be intermittent, the edge device stores events locally and syncs them to Roboflow when connectivity is restored.

{% hint style="info" %}
Edge Device Backup requires Deployment Manager. See the [Deployment Manager documentation](https://docs.roboflow.com/deploy/device-manager) for setup instructions.
{% endhint %}

To enable Vision Events backup:

1. Open **Deployment Manager** in your workspace
2. Select the device to configure
3. Enable **Vision Events Backup** in the device's Event Store configuration
4. Events are written to the local event store on the device
5. When the device reconnects, events sync to Roboflow automatically

Events appear in the Vision Events dashboard after sync completes.

<figure><img src="https://662926385-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M6S9nPJhEX9FYH6clfW%2Fuploads%2FxsgkG53PwvUtPzZIi1ez%2Fimage.png?alt=media&#x26;token=58085ee0-285e-4a76-8a5a-1fda3efd59a3" alt="" width="375"><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.roboflow.com/deploy/vision-events/send-events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
