> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# events

# `prefect.server.api.events`

## Functions

### `create_events` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/events.py#L48](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/events.py#L48)</sup>

```python theme={null}
create_events(events: List[Event], ephemeral_request: bool = Depends(is_ephemeral_request)) -> None
```

Record a batch of Events.

For more information, see [https://www.prefect.io/docs/v3/concepts/events](https://www.prefect.io/docs/v3/concepts/events).

### `stream_events_in` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/events.py#L65](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/events.py#L65)</sup>

```python theme={null}
stream_events_in(websocket: WebSocket) -> None
```

Open a WebSocket to stream incoming Events

### `stream_workspace_events_out` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/events.py#L83](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/events.py#L83)</sup>

```python theme={null}
stream_workspace_events_out(websocket: WebSocket) -> None
```

Open a WebSocket to stream Events

### `verified_page_token` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/events.py#L167](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/events.py#L167)</sup>

```python theme={null}
verified_page_token(page_token: str = Query(..., alias='page-token')) -> str
```

### `read_events` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/events.py#L184](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/events.py#L184)</sup>

```python theme={null}
read_events(request: Request, filter: Optional[EventFilter] = Body(None, description='Additional optional filter criteria to narrow down the set of Events'), limit: int = Body(INTERACTIVE_PAGE_SIZE, ge=0, le=INTERACTIVE_PAGE_SIZE, embed=True, description='The number of events to return with each page'), db: PrefectDBInterface = Depends(provide_database_interface)) -> EventPage
```

Queries for Events matching the given filter criteria in the given Account.  Returns
the first page of results, and the URL to request the next page (if there are more
results).

### `read_account_events_page` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/events.py#L224](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/events.py#L224)</sup>

```python theme={null}
read_account_events_page(request: Request, page_token: str = Depends(verified_page_token), db: PrefectDBInterface = Depends(provide_database_interface)) -> EventPage
```

Returns the next page of Events for a previous query against the given Account, and
the URL to request the next page (if there are more results).

### `generate_next_page_link` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/events.py#L248](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/events.py#L248)</sup>

```python theme={null}
generate_next_page_link(request: Request, page_token: Optional[str]) -> Optional[str]
```

### `count_account_events` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/events.py#L265](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/events.py#L265)</sup>

```python theme={null}
count_account_events(filter: EventFilter, countable: Countable = Path(...), time_unit: TimeUnit = Body(default=TimeUnit.day), time_interval: float = Body(default=1.0, ge=0.01), db: PrefectDBInterface = Depends(provide_database_interface)) -> List[EventCount]
```

Returns distinct objects and the count of events associated with them.  Objects
that can be counted include the day the event occurred, the type of event, or
the IDs of the resources associated with the event.

### `handle_event_count_request` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/events.py#L287](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/events.py#L287)</sup>

```python theme={null}
handle_event_count_request(session: AsyncSession, filter: EventFilter, countable: Countable, time_unit: TimeUnit, time_interval: float) -> List[EventCount]
```
