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

# Query agent sessions (Enterprise)

> The sessions list with every filter in the body, including end_user and external_id.



## OpenAPI

````yaml /swagger/5.16/ai-studio-swagger.yml post /agent-tracing/sessions/query
openapi: 3.0.1
info:
  title: Midsommar API
  description: This is the API for the Midsommar user and group management system.
  termsOfService: http://swagger.io/terms/
  contact:
    name: API Support
    url: http://www.swagger.io/support
    email: support@swagger.io
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  version: '1.0'
servers:
  - url: //localhost:8080/api/v1
security: []
paths:
  /agent-tracing/sessions/query:
    post:
      tags:
        - agent-tracing
      summary: Query agent sessions (Enterprise)
      description: >-
        The sessions list with every filter in the body, including end_user and
        external_id.
      requestBody:
        description: Filters
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/api.SessionQueryBody'
        required: true
      responses:
        '200':
          description: '{data: [session], next_cursor}'
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api.ErrorResponse'
        '402':
          description: Payment Required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api.ErrorResponse'
components:
  schemas:
    api.SessionQueryBody:
      type: object
      properties:
        agent:
          type: string
        app_id:
          type: integer
        cost_max_micros:
          type: integer
        cost_min_micros:
          type: integer
        cursor:
          type: string
        duration_max_ms:
          type: integer
        duration_min_ms:
          type: integer
        end_user:
          type: string
        external_id:
          type: string
        from:
          type: string
        has_errors:
          type: boolean
        has_gateway_events:
          type: boolean
        limit:
          type: integer
        model:
          type: string
        session_id:
          type: string
        sort:
          type: string
          description: a SessionSorts column, "-" prefix for descending
        source:
          type: string
        status:
          type: string
        to:
          type: string
        tool:
          type: string
        user_id:
          type: integer
        weak_links:
          type: boolean
    api.ErrorResponse:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              detail:
                type: string
              title:
                type: string
      description: Error response model

````