# 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](/developer/rest-api/vision-events.md).

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


---

# 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/developer/python-sdk/vision-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.
