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

# Get a session

> Returns a session and its API runs, ordered from newest to oldest.
The session must belong to the authenticating API key.

Pagination parameters apply to the `runs` array. Use `limit`, `after`, and `before` for cursor pagination.




## OpenAPI

````yaml /api/platform/v1/openapi-kapso-agent.yaml get /kapso-agent/sessions/{id}
openapi: 3.1.0
info:
  title: Kapso Agent API
  version: 0.1.0
  description: >
    Trigger runs in built-in modes with the API trigger enabled or custom modes
    with the `api` surface enabled.

    Inspect sessions, control run lifecycles, and handle approvals
    programmatically.
servers:
  - url: https://api.kapso.ai/platform/v1
    description: Production
security:
  - ApiKeyAuth: []
tags:
  - name: Agent Modes
    description: Discover the agent modes and which ones accept API runs
  - name: Agent Sessions
    description: List API sessions and inspect their runs
  - name: Agent Runs
    description: Create, poll, and control Kapso Agent runs
paths:
  /kapso-agent/sessions/{id}:
    get:
      tags:
        - Agent Sessions
      summary: Get a session
      description: >
        Returns a session and its API runs, ordered from newest to oldest.

        The session must belong to the authenticating API key.


        Pagination parameters apply to the `runs` array. Use `limit`, `after`,
        and `before` for cursor pagination.
      operationId: getAgentSession
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: Session `conversation_id`
        - $ref: '#/components/parameters/LegacyPage'
        - $ref: '#/components/parameters/LegacyPerPage'
        - $ref: '#/components/parameters/CursorLimit'
        - $ref: '#/components/parameters/CursorBefore'
        - $ref: '#/components/parameters/CursorAfter'
      responses:
        '200':
          description: Session and runs
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentSessionDetailResponse'
        '400':
          description: Invalid pagination parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginationErrorResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/SessionNotFound'
components:
  parameters:
    LegacyPage:
      name: page
      in: query
      deprecated: true
      description: >-
        Page number for legacy offset pagination. Use cursor pagination for new
        integrations.
      schema:
        type: integer
        minimum: 1
        maximum: 50
        default: 1
    LegacyPerPage:
      name: per_page
      in: query
      description: Number of results for legacy offset pagination.
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 20
    CursorLimit:
      name: limit
      in: query
      description: Maximum number of results for cursor pagination.
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 20
    CursorBefore:
      name: before
      in: query
      description: Cursor for the previous page.
      schema:
        type: string
    CursorAfter:
      name: after
      in: query
      description: Cursor for the next page.
      schema:
        type: string
  schemas:
    AgentSessionDetailResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/AgentSessionDetail'
        meta:
          $ref: '#/components/schemas/PaginationMeta'
        paging:
          $ref: '#/components/schemas/Paging'
    PaginationErrorResponse:
      type: object
      description: Invalid cursor, limit, or legacy offset window
      properties:
        error:
          type: string
          description: Present for invalid cursor parameters
        message:
          type: string
          description: Present when the legacy offset window exceeds its limit
        detail:
          type: string
          description: Instructions for switching to cursor pagination
    AgentSessionDetail:
      type: object
      properties:
        session:
          $ref: '#/components/schemas/AgentSession'
        runs:
          type: array
          items:
            $ref: '#/components/schemas/SessionRun'
    PaginationMeta:
      type: object
      properties:
        page:
          type: integer
          minimum: 1
        per_page:
          type: integer
          minimum: 1
        total_pages:
          type: integer
          minimum: 0
        total_count:
          type: integer
          minimum: 0
        has_next:
          type: boolean
        total_count_estimated:
          type: boolean
          description: The total is an estimate for bounded offset pagination
    Paging:
      type: object
      properties:
        cursors:
          $ref: '#/components/schemas/PaginationCursor'
        next:
          type:
            - string
            - 'null'
          description: Cursor for the next page
        previous:
          type:
            - string
            - 'null'
          description: Cursor for the previous page
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable error message
    AgentSession:
      type: object
      properties:
        conversation_id:
          type: string
          format: uuid
          description: Session identifier used to continue a conversation
        title:
          type:
            - string
            - 'null'
        status:
          type: string
          enum:
            - active
            - paused
            - terminated
        created_at:
          type: string
          format: date-time
        run_count:
          type: integer
          minimum: 0
          description: Total API runs in the session
        latest_run:
          $ref: '#/components/schemas/SessionLatestRun'
        last_activity_at:
          type: string
          format: date-time
    SessionRun:
      allOf:
        - $ref: '#/components/schemas/Run'
        - type: object
          properties:
            result:
              type: 'null'
              description: >-
                Session history omits the result. Retrieve the run to get its
                result.
    PaginationCursor:
      type: object
      properties:
        before:
          type:
            - string
            - 'null'
          description: Cursor for the previous page
        after:
          type:
            - string
            - 'null'
          description: Cursor for the next page
    SessionLatestRun:
      type:
        - object
        - 'null'
      properties:
        run_id:
          type: string
          format: uuid
        status:
          $ref: '#/components/schemas/RunStatus'
        created_at:
          type: string
          format: date-time
    Run:
      type: object
      properties:
        run_id:
          type: string
          format: uuid
        conversation_id:
          type: string
          format: uuid
          description: The agent session this run belongs to
        status:
          $ref: '#/components/schemas/RunStatus'
        mode:
          type: string
          examples:
            - api
        title:
          type:
            - string
            - 'null'
        kind:
          type: string
          enum:
            - ask
            - continue
        prompt:
          type:
            - string
            - 'null'
        provider_model:
          type:
            - string
            - 'null'
          examples:
            - gpt-5.5
        reasoning_effort:
          type:
            - string
            - 'null'
          examples:
            - medium
        error_message:
          type:
            - string
            - 'null'
        ai_cost_microdollars:
          type: integer
          description: AI cost of the run in microdollars
        result:
          $ref: '#/components/schemas/RunResult'
        pending_approval:
          $ref: '#/components/schemas/PendingApproval'
        created_at:
          type: string
          format: date-time
        started_at:
          type:
            - string
            - 'null'
          format: date-time
        paused_at:
          type:
            - string
            - 'null'
          format: date-time
        finished_at:
          type:
            - string
            - 'null'
          format: date-time
        status_url:
          type: string
          description: Path to poll this run
        finding:
          type: object
          description: Present for a finding investigation run
          properties:
            id:
              type: string
              format: uuid
            investigation_id:
              type: string
              format: uuid
    RunStatus:
      type: string
      enum:
        - queued
        - running
        - paused
        - waiting_for_approval
        - completed
        - failed
        - cancelled
    RunResult:
      type:
        - object
        - 'null'
      description: Present when the run completed
      properties:
        type:
          type: string
          enum:
            - message
            - finding_investigation
        message_id:
          type: string
          format: uuid
          description: Present when type is message
        content:
          type: string
          description: Present when type is message
        data:
          type: object
          description: Present when type is finding_investigation
    PendingApproval:
      type:
        - object
        - 'null'
      properties:
        id:
          type: string
          format: uuid
        status:
          type: string
          examples:
            - pending
        tool_name:
          type: string
        parameters:
          type: object
          description: Sanitized tool parameters
        created_at:
          type: string
          format: date-time
  responses:
    Unauthorized:
      description: Missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    SessionNotFound:
      description: Session not found or not accessible with this API key
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                examples:
                  - record_not_found
              detail:
                type: string
                examples:
                  - Session not found.
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key

````