# Read or stream events (/brain/docs/api/generated/events)

Returns a page of retained events as JSON, or streams history and live updates when called with Accept: text/event-stream. Pass after (or Last-Event-ID) with the last retained event's cursor to resume from a known position. Returns 409 cursor_unavailable if the cursor points to an unsynced tail lost during restore.

## GET /sessions/{id}/events

Bearer authentication is required.

```json
{
  "openapi": "3.1.0",
  "info": {
    "description": "HTTP API for the Brain agent session server.",
    "title": "Brain",
    "version": "current"
  },
  "servers": [
    {
      "description": "Local development",
      "url": "http://127.0.0.1:8080"
    }
  ],
  "paths": {
    "/sessions/{id}/events": {
      "get": {
        "description": "Returns a page of retained events as JSON, or streams history and live updates when called with Accept: text/event-stream. Pass after (or Last-Event-ID) with the last retained event's cursor to resume from a known position. Returns 409 cursor_unavailable if the cursor points to an unsynced tail lost during restore.",
        "operationId": "events",
        "parameters": [
          {
            "description": "Opaque session ID.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "pattern": "^[a-fA-F0-9]{32}$",
              "type": "string"
            }
          },
          {
            "description": "Opaque cursor from the last retained event.",
            "in": "query",
            "name": "after",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Maximum number of items to return (JSON mode).",
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 100,
              "maximum": 1000,
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "description": "SSE reconnect cursor (used when the after query parameter is omitted).",
            "in": "header",
            "name": "Last-Event-ID",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventList"
                }
              },
              "text/event-stream": {
                "example": "id: OPAQUE_CURSOR\nevent: assistant.message\ndata: {\"id\":\"EVENT_ID\",\"type\":\"assistant.message\",\"time\":\"2026-10-15T12:00:00Z\",\"input_id\":\"INPUT_ID\",\"data\":{\"text\":\"Hello\"},\"cursor\":\"OPAQUE_CURSOR\"}\n\n",
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "Read or stream events"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Error. 400 invalid_request; 401 missing/invalid Bearer token; 403 forbidden; 404 not_found; 409 conflict or cursor_unavailable; 413 body limit; 422 unsupported; 429 overloaded (Retry-After: 1); 500 brain_error. X-Request-ID is present on every response."
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Read or stream events"
      }
    }
  },
  "components": {
    "schemas": {
      "EventList": {
        "additionalProperties": false,
        "properties": {
          "events": {
            "items": {
              "$ref": "#/components/schemas/Event"
            },
            "type": "array"
          },
          "next_cursor": {
            "type": "string"
          }
        },
        "required": [
          "events",
          "next_cursor"
        ],
        "type": "object"
      },
      "Event": {
        "additionalProperties": false,
        "properties": {
          "cursor": {
            "type": "string"
          },
          "data": {},
          "id": {
            "type": "string"
          },
          "input_id": {
            "type": "string"
          },
          "time": {
            "format": "date-time",
            "type": "string"
          },
          "type": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "type",
          "time",
          "data"
        ],
        "type": "object"
      },
      "ErrorResponse": {
        "additionalProperties": false,
        "properties": {
          "error": {
            "$ref": "#/components/schemas/ErrorDetail"
          },
          "request_id": {
            "type": "string"
          }
        },
        "required": [
          "error",
          "request_id"
        ],
        "type": "object"
      },
      "ErrorDetail": {
        "additionalProperties": false,
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "code",
          "message"
        ],
        "type": "object"
      }
    },
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "type": "http"
      }
    }
  }
}
```

[Complete OpenAPI document](/brain/openapi.json)