> 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/upload-a-vision-event-image.md).

# Upload a Vision Event Image

Upload a workspace-level image and reference its sourceId when creating a Vision Event.

## About

This endpoint uploads an image to your workspace for use in [Vision Events](https://docs.roboflow.com/deployment/monitoring-and-analytics/vision-events.md). The upload is workspace-level and is not tied to any project; the returned `sourceId` can then be referenced in the `images` array when you [create an event](https://docs.roboflow.com/deployment/monitoring-and-analytics/vision-events/create-a-vision-event.md). Use it to attach the original or output frames a model processed so they are viewable alongside the event.

## HTTP API

Upload an image for use in vision events. This is a workspace-level upload that is not associated with any specific project. The returned `sourceId` can be referenced in the `images` array when creating events.

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

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

Put the returned `sourceId` in `images[].sourceId` when you [create a vision event](https://docs.roboflow.com/deployment/monitoring-and-analytics/vision-events/create-a-vision-event.md#http-api).

## Python SDK

Upload a local image for use in vision events. The returned `sourceId` can be referenced in the `images` array when creating events.

```python
import roboflow

roboflow.login()

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

# Upload an image
result = ws.upload_vision_event_image("inspection-photo.jpg")
source_id = result["sourceId"]

# You can also provide an optional name and metadata
result = ws.upload_vision_event_image(
    "inspection-photo.jpg",
    name="line-a-check-001",
    metadata={"camera": "cam-1", "shift": "morning"},
)
```

The `sourceId` from the response is used in the `images` array when [creating a vision event](https://docs.roboflow.com/deployment/monitoring-and-analytics/vision-events/create-a-vision-event.md#python-sdk):

```python
ws.write_vision_event({
    "eventId": "d4e5f6a7-b2c3-4d4e-9f6a-7b8c9d0e1f2a",
    "eventType": "quality_check",
    "useCaseId": "a1b3c8e1",
    "timestamp": "2024-01-15T10:30:00Z",
    "images": [
        {
            "sourceId": source_id,
            "label": "inspection-photo",
            "objectDetections": [
                {"class": "defect", "x": 100, "y": 200, "width": 50, "height": 30, "confidence": 0.95}
            ],
        }
    ],
    "eventData": {"result": "fail"},
})
```

For supported image formats and metadata constraints, see the [REST API reference](#http-api).
