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

# Subscribe to events

> Subscribe to native event payloads for the server. Volatile by contract: a slow consumer overflows and fails the stream, and events during disconnection are missed.



## OpenAPI

````yaml /openapi.json get /api/event
openapi: 3.1.0
info:
  title: opencode HttpApi
  version: 0.0.1
  description: Experimental HttpApi surface for selected instance routes.
servers: []
security: []
tags:
  - name: health
  - name: server
  - name: location
  - name: agent
  - name: plugin
    description: Experimental plugin routes.
  - name: session
    description: Experimental session routes.
  - name: session
    description: Experimental message routes.
  - name: model
    description: Experimental model routes.
  - name: generate
    description: Experimental one-shot generation routes.
  - name: provider
    description: Experimental provider routes.
  - name: integration
    description: Integration discovery and authentication routes.
  - name: mcp
    description: MCP server and resource routes.
  - name: credential
  - name: project
    description: Location-scoped project routes.
  - name: form
    description: Session form routes.
  - name: permission
    description: Experimental permission routes.
  - name: filesystem
    description: Experimental location-scoped filesystem routes.
  - name: command
    description: Experimental command routes.
  - name: skill
    description: Experimental skill routes.
  - name: event
    description: Experimental event stream routes.
  - name: pty
    description: Experimental location-scoped PTY routes.
  - name: shell
    description: Experimental location-scoped shell command routes.
  - name: question
    description: Experimental session question routes.
  - name: reference
    description: Location-scoped project references.
  - name: projectCopy
    description: Project copy management routes.
  - name: vcs
    description: Location-scoped version control routes.
  - name: debug
paths:
  /api/event:
    get:
      tags:
        - event
      summary: Subscribe to events
      description: >-
        Subscribe to native event payloads for the server. Volatile by contract:
        a slow consumer overflows and fails the stream, and events during
        disconnection are missed.
      operationId: v2.event.subscribe
      parameters: []
      responses:
        '200':
          description: Success
          content:
            text/event-stream:
              schema:
                type: object
                properties:
                  id:
                    anyOf:
                      - type: string
                      - type: 'null'
                  event:
                    type: string
                  data:
                    $ref: '#/components/schemas/V2EventStream'
                required:
                  - id
                  - event
                  - data
                additionalProperties: false
              x-effect-stream:
                encoding: sse
                causeSchema:
                  type: array
                  items:
                    anyOf:
                      - type: object
                        properties:
                          _tag:
                            type: string
                            enum:
                              - Fail
                          error:
                            not: {}
                        required:
                          - _tag
                          - error
                        additionalProperties: false
                      - type: object
                        properties:
                          _tag:
                            type: string
                            enum:
                              - Die
                          defect: {}
                        required:
                          - _tag
                          - defect
                        additionalProperties: false
                      - type: object
                        properties:
                          _tag:
                            type: string
                            enum:
                              - Interrupt
                          fiberId:
                            anyOf:
                              - type: number
                              - type: 'null'
                        required:
                          - _tag
                          - fiberId
                        additionalProperties: false
                errorSchema:
                  not: {}
                failureEvent: effect/httpapi/stream/failure
        '400':
          description: InvalidRequestError
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvalidRequestError'
        '401':
          description: UnauthorizedError
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
      security: []
components:
  schemas:
    V2EventStream:
      type: string
      contentSchema:
        $ref: '#/components/schemas/V2Event'
      contentMediaType: application/json
    InvalidRequestError:
      type: object
      properties:
        _tag:
          type: string
          enum:
            - InvalidRequestError
        message:
          type: string
        kind:
          anyOf:
            - type: string
            - type: 'null'
        field:
          anyOf:
            - type: string
            - type: 'null'
      required:
        - _tag
        - message
      additionalProperties: false
    UnauthorizedError:
      type: object
      properties:
        _tag:
          type: string
          enum:
            - UnauthorizedError
        message:
          type: string
      required:
        - _tag
        - message
      additionalProperties: false

````