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

# Query events as a table (SDK)

> Returns event rows for the given agent and eventName. `mode: 'raw'` returns individual events; `mode: 'aggregate'` groups rows by a property key and applies the listed metrics (count/sum/avg/min/max). Filters, date ranges, sort and pagination are all server-side.



## OpenAPI

````yaml /api-reference/openapi.json post /api/v1/runtime/v1/observability/events/query
openapi: 3.0.0
info:
  title: Runflow Runtime API
  description: >-
    Programmatic surface for the Runflow platform — used by the SDK, the CLI,
    the execution engine, and any server-to-server caller. Authenticate with an
    `x-api-key` header (or `Authorization: Bearer ...`).
  version: 1.0.0
  contact: {}
servers:
  - url: https://api.runflow.ai
    description: Production
  - url: http://localhost:3000
    description: Local development
security: []
tags: []
paths:
  /api/v1/runtime/v1/observability/events/query:
    post:
      tags:
        - Runtime API - Events
      summary: Query events as a table (SDK)
      description: >-
        Returns event rows for the given agent and eventName. `mode: 'raw'`
        returns individual events; `mode: 'aggregate'` groups rows by a property
        key and applies the listed metrics (count/sum/avg/min/max). Filters,
        date ranges, sort and pagination are all server-side.
      operationId: RuntimeEventsController_queryEvents
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - eventName
              properties:
                agentId:
                  type: string
                  description: >-
                    Agent UUID. Defaults to the agent bound to the API key when
                    omitted.
                eventName:
                  type: string
                mode:
                  type: string
                  enum:
                    - raw
                    - aggregate
                  default: raw
                columns:
                  type: array
                  items:
                    type: string
                groupBy:
                  type: string
                metrics:
                  type: array
                  items:
                    type: object
                    required:
                      - aggregation
                      - alias
                    properties:
                      aggregation:
                        type: string
                        enum:
                          - count
                          - sum
                          - avg
                          - min
                          - max
                      propertyKey:
                        type: string
                      alias:
                        type: string
                filters:
                  type: array
                  items:
                    type: object
                    required:
                      - propertyKey
                      - operator
                      - value
                    properties:
                      propertyKey:
                        type: string
                      operator:
                        type: string
                        enum:
                          - eq
                          - neq
                          - gt
                          - lt
                          - gte
                          - lte
                          - contains
                          - in
                      value: {}
                dateFrom:
                  format: date-time
                  type: string
                dateTo:
                  format: date-time
                  type: string
                sortBy:
                  type: string
                sortOrder:
                  type: string
                  enum:
                    - asc
                    - desc
                limit:
                  type: integer
                offset:
                  type: integer
      responses:
        '200':
          description: Query result.
        '400':
          description: Invalid request body.
      security:
        - bearer: []
components: {}

````