# Stream notifications (SSE)

> GET /api/stream/{publicId}: receive Alphorn notifications in real time over Server-Sent Events. Event format, connection limits, and errors.

Source: https://docs.alphorn.dev/endpoints/stream-notifications/

OpenAPI 3.1 specification (with all referenced components): https://docs.alphorn.dev/openapi.json

## GET /api/stream/{publicId}

```json
{
  "operationId": "streamNotifications",
  "tags": [
    "Streaming"
  ],
  "summary": "Stream notifications (SSE)",
  "description": "Opens a Server-Sent Events stream for a Live Stream channel. Every notification routed to the channel arrives as an event. The server sends a `: connected` comment right away and a `: keepalive` comment every 30 seconds. No authentication: the channel's stream ID is the secret.",
  "security": [],
  "parameters": [
    {
      "name": "publicId",
      "in": "path",
      "required": true,
      "description": "The Live Stream channel's stream ID.",
      "schema": {
        "type": "string"
      }
    }
  ],
  "responses": {
    "200": {
      "description": "Event stream. With the channel's JSON output format, each `data:` line is a JSON StreamEvent (`x-event-data`); with the text format, a single line of fields separated by ` | `.",
      "content": {
        "text/event-stream": {
          "schema": {
            "type": "string"
          },
          "x-event-data": {
            "type": "object",
            "required": [
              "message",
              "timestamp"
            ],
            "properties": {
              "title": {
                "type": "string",
                "description": "Present when the notification has a title."
              },
              "message": {
                "type": "string"
              },
              "timestamp": {
                "type": "string",
                "format": "date-time",
                "description": "Time the event was streamed."
              },
              "priority": {
                "type": "number",
                "description": "Present when switched on in the channel and the notification has one."
              },
              "tags": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Present when switched on in the channel and the notification has tags."
              },
              "payload": {
                "type": "object",
                "additionalProperties": true,
                "description": "Present when switched on. The JSON request body, or {} for plain-text notifications."
              }
            }
          }
        }
      }
    },
    "404": {
      "description": "The stream ID does not exist, the channel is disabled, or it is not a Live Stream channel.",
      "content": {
        "text/plain": {
          "schema": {
            "type": "string"
          }
        }
      }
    },
    "429": {
      "description": "Too many connections (by default 20 per channel and 20 per client IP).",
      "content": {
        "text/plain": {
          "schema": {
            "type": "string"
          }
        }
      }
    },
    "503": {
      "description": "Self-hosted only: the instance runs the standalone SSE server but /api/stream/* is not routed to it.",
      "content": {
        "text/plain": {
          "schema": {
            "type": "string"
          }
        }
      }
    }
  }
}
```
