# Server-Sent Events (SSE)

Server-Sent Events (SSE) is a protocol for sending real-time updates from a server to a client over a single HTTP connection. Your flows can both consume SSE streams (using `Http Fetch Streamed` and expose SSE endpoints to send events to connected clients (using various functions in the `Http Server-Sent Events` module).

## Consuming SSE Endpoints

<figure><img src="/files/HgAEO7ox6w6Q2e5c18aN" alt=""><figcaption></figcaption></figure>

An SSE stream can be consumed using [`Http Fetch Streamed`](/midio-docs/built-in-nodes/http.md#fetchstreamed) to initiate a request, and then `Parse SSE Stream` to extract messages one at a time as they arrive. Notice that after handling each event, we loop back to the `Parse SSE Stream` function, which then lets us handle the next message. When the `stream closed` trigger fires, we don't loop back but just print a message to the log.

## Serving SSE Endpoints

<figure><img src="/files/g8s7InfZWGNgE5lvZ7xP" alt=""><figcaption></figcaption></figure>

You can respond with an SSE stream from your own endpoints by first calling `Start SSE Response`, and then call `Send SSE Event` as many times as you like with the data you want to transmit. The example above sends each word in the string one at a time.


---

# 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.midio.com/midio-docs/guides/http/server-sent-events-sse.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.
