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

# Stream reconnectable durable-run events

> Stream ordered Praxa run events over SSE, persist the numeric cursor, and resume safely after a disconnect.

Stream ordered Praxa run events over SSE, persist the numeric cursor, and resume safely after a disconnect.

<Info>
  **Availability:** Production partner preview. **Required scope:** `runs:read`.
</Info>

## Authenticate safely

Create a disposable **personal workspace** API key with exactly `runs:read`. Send it as `Authorization: Bearer $PRAXA_API_KEY`. A Gateway OAuth token, Supabase JWT, provider credential, or organization memory key is not interchangeable with this key.

The hosted playground sends the credential from your browser session to the documented API through the configured playground proxy. Use test data, never share the key, and revoke it when the check ends.

## Request fields

<ParamField path="id" type="string" required>
  id path parameter.
</ParamField>

<ParamField header="Last-Event-ID" type="integer">
  Resume strictly after this task\_run\_events sequence.
</ParamField>

## Runnable request examples

<CodeGroup>
  ```bash cURL theme={null}
  curl --fail-with-body --no-buffer -X GET 'https://api.praxa.io/v1/runs/018f0000-0000-7000-8000-000000000001/events' \
    -H "Authorization: Bearer $PRAXA_API_KEY" \
    -H "Last-Event-ID: 0" \
    -H "Accept: text/event-stream"
  ```

  ```javascript Node.js theme={null}
  const response = await fetch("https://api.praxa.io/v1/runs/018f0000-0000-7000-8000-000000000001/events", {
    "method": "GET",
    "headers": {
      "Authorization": `Bearer ${process.env.PRAXA_API_KEY}`,
      "Last-Event-ID": "0",
      "Accept": "text/event-stream"
    }
  });
  if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
  if (!response.body) throw new Error("SSE response had no body");
  const decoder = new TextDecoder();
  let buffer = "";
  for await (const chunk of response.body) {
    buffer = (buffer + decoder.decode(chunk, { stream: true })).replaceAll("\r\n", "\n");
    for (;;) {
      const boundary = buffer.indexOf("\n\n");
      if (boundary < 0) break;
      const frame = buffer.slice(0, boundary);
      buffer = buffer.slice(boundary + 2);
      if (frame && !frame.startsWith(":")) console.log(frame);
    }
  }
  ```

  ```python Python theme={null}
  import json
  import os
  from urllib import error, request

  req = request.Request(
      "https://api.praxa.io/v1/runs/018f0000-0000-7000-8000-000000000001/events",
      method="GET",
      headers={
        "Authorization": f"Bearer {os.environ['PRAXA_API_KEY']}",
        "Last-Event-ID": "0",
        "Accept": "text/event-stream"
      },
  )
  try:
      with request.urlopen(req, timeout=30) as response:
          frame_lines = []
          for raw_line in response:
              line = raw_line.decode("utf-8").rstrip("\r\n")
              if line:
                  if not line.startswith(":"):
                      frame_lines.append(line)
              elif frame_lines:
                  print("\n".join(frame_lines), flush=True)
                  frame_lines.clear()
          if frame_lines:
              print("\n".join(frame_lines), flush=True)
  except error.HTTPError as exc:
      raise RuntimeError(f"{exc.code}: {exc.read().decode()}") from exc
  ```
</CodeGroup>

## What success means

A `200` response opens an SSE stream. Completion is proven only by a terminal event or authoritative run readback.

## Successful response

**200** — SSE frames include matching numeric id and payload sequence. Comment heartbeats may appear. During uncertain-outcome reconciliation, the run remains non-terminal and keeps the stream open. A completed, failed, or cancelled run closes it.

<ResponseExample>
  ```text 200 theme={null}
  id: 1
  event: run.accepted
  data: {"apiVersion":"v1","run_id":"018f0000-0000-7000-8000-000000000001","sequence":1,"at":"2026-08-13T12:00:00.000Z","type":"run.accepted","replayed":false}
  ```
</ResponseExample>

## Handle failures

| Response                    | Meaning                                                             | Safe action                                                                         |
| --------------------------- | ------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| `400 invalid_request`       | The method, path, headers, query, or body failed strict validation. | Correct the request; do not retry unchanged input.                                  |
| `401 authentication_failed` | The bearer key is missing, malformed, expired, or revoked.          | Stop and replace the key through the authenticated console.                         |
| `403 authorization_failed`  | The authenticated key lacks scope or tenant authority.              | Request only the missing least-privilege scope; never substitute another tenant ID. |
| `429 rate_limited`          | The principal exceeded a bounded rate.                              | Honor `retryAfterMs` or `Retry-After`, add jitter, and cap attempts.                |
| retryable `5xx`             | The server could not confirm a final response.                      | Reconcile reads or replay the exact keyed mutation before creating new work.        |

```json Example problem theme={null}
{
  "type": "https://docs.praxa.io/problems/authorization-failed",
  "title": "Authorization failed",
  "status": 403,
  "code": "authorization_failed",
  "detail": "The API key does not grant the required scope.",
  "retryable": false
}
```

## Verify the result

1. Require each event `id` to match its payload sequence.
2. Reconnect with `Last-Event-ID` and reject sequence regression.
3. Treat EOF before a terminal event as incomplete.

## Retry, cleanup, and production use

* Treat `401`, `403`, and `409` as authority or state signals, not generic retry prompts.
* For `429` or retryable 5xx responses, follow server retry guidance and keep a bounded attempt budget.
* Move the request into a trusted application backend before production; never ship the Praxa key in browser or mobile code.
* Revoke the disposable key, disable test webhooks, and erase disposable candidate data after validation.

Continue with [API authentication](/api-playground/authentication), the [failure and retry guide](/api-playground/errors), and the [end-to-end coverage matrix](/api-playground/coverage-and-testing).
