# Vision Events

The Roboflow Python SDK provides methods for working with vision events on the `Workspace` object. You can create events, query them with filters and pagination, upload images, and manage use cases.

For full details on event schemas, filtering options, and response formats, see the [Vision Events REST API documentation](https://docs.roboflow.com/developer/rest-api/vision-events).

## Quick Start

```python
import roboflow

roboflow.login()

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

# Create a use case
result = ws.create_vision_event_use_case("manufacturing-qa")
use_case_id = result["id"]

# Upload an image
img = ws.upload_vision_event_image("photo.jpg")

# Create an event with the uploaded image
ws.write_vision_event({
    "eventId": "c3d4e5f6-a1b2-4c3d-8e5f-6a7b8c9d0e1f",
    "eventType": "quality_check",
    "useCaseId": use_case_id,
    "timestamp": "2024-01-15T10:30:00Z",
    "images": [{"sourceId": img["sourceId"]}],
    "eventData": {"result": "pass"},
})

# Query events
for page in ws.query_all_vision_events(use_case_id):
    for evt in page:
        print(evt["eventId"], evt["eventType"])
```

## Available Methods

| Method                                                                                                                          | Description                                      |
| ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
| [`upload_vision_event_image()`](https://docs.roboflow.com/developer/python-sdk/vision-events/upload-a-vision-event-image)       | Upload an image for use in events                |
| [`write_vision_event()`](https://docs.roboflow.com/developer/python-sdk/vision-events/create-a-vision-event)                    | Create a single vision event                     |
| [`write_vision_events_batch()`](https://docs.roboflow.com/developer/python-sdk/vision-events/batch-create-vision-events)        | Create up to 100 events in one request           |
| [`query_vision_events()`](https://docs.roboflow.com/developer/python-sdk/vision-events/query-vision-events)                     | Query events with filters and pagination         |
| [`query_all_vision_events()`](https://docs.roboflow.com/developer/python-sdk/query-vision-events#paginate-through-all-results)  | Auto-paginating query across all matching events |
| [`list_vision_event_use_cases()`](https://docs.roboflow.com/developer/python-sdk/vision-events/manage-use-cases)                | List use cases in your workspace                 |
| [`create_vision_event_use_case()`](https://docs.roboflow.com/developer/python-sdk/manage-use-cases#create-a-use-case)           | Create a new use case                            |
| [`rename_vision_event_use_case()`](https://docs.roboflow.com/developer/python-sdk/manage-use-cases#rename-a-use-case)           | Rename a use case                                |
| [`archive_vision_event_use_case()`](https://docs.roboflow.com/developer/python-sdk/manage-use-cases#archive-a-use-case)         | Archive a use case                               |
| [`unarchive_vision_event_use_case()`](https://docs.roboflow.com/developer/python-sdk/manage-use-cases#unarchive-a-use-case)     | Unarchive a use case                             |
| [`get_vision_event_metadata_schema()`](https://docs.roboflow.com/developer/python-sdk/vision-events/get-custom-metadata-schema) | Get discovered custom metadata field types       |
