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

# SSE

> Stream order status

`GET /v1/sse/operations/:id` streams status changes for one order as server-sent events. It is not in the OpenAPI spec; this page is the reference.

## Request

The key goes in the `token` query parameter. Server keys need no read token. Client keys need `orders:sse` and an order-bound `readToken` from `/submit` or `/onramp`, issued to the same key and matching `ORDER_ID`:

```
GET /v1/sse/operations/ORDER_ID?token=SERVER_KEY
GET /v1/sse/operations/ORDER_ID?token=CLIENT_KEY&readToken=READ_TOKEN
```

An order that does not exist or belongs to another partner returns `404 not_found`. The limit is 30 connections per minute per IP.

Direct client SSE accepts `readToken` only in the query. A `/quote` token is bound to the quote, not the order ID: keep polling status by `quoteId` or stream through your backend.

## Events

A `status` frame carries the current state on connect, followed by live updates. A `heartbeat` frame arrives every 15 seconds:

```
event: status
data: {"status":"swapping"}

event: heartbeat
data:
```

`paused` orders stream as `processing`. Reconnecting reads current state; it does not replay missed transitions or support `Last-Event-ID` recovery. Reconcile through the status API.

## Close

The server closes the stream after `completed`, `failed`, or `refunded`. It stays open on `unfulfilled`, because a late deposit can resume the order.

## Browsers

Keep server keys on your backend. Authorize the caller's access to the order before proxying the stream with `Content-Type: text/event-stream`. The browser connects to your proxy:

```javascript theme={null}
const stream = new EventSource(`/api/orders/${orderId}/events`);

stream.addEventListener("status", (e) => {
  const { status } = JSON.parse(e.data);
  render(status);
  if (["completed", "failed", "refunded"].includes(status)) stream.close();
});
```

`EventSource` reconnects automatically. Fall back to authenticated status polling every 3 seconds if streaming remains unavailable.
