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

# Get History

> Get conversation history for a session.

Returns messages in chronological order (oldest first).

Args:
    request: FastAPI request with tenant context
    session_id: Session identifier
    limit: Maximum messages to return (default: 50, max: 200)
    offset: Pagination offset (default: 0)

Returns:
    GetHistoryResponse with message history

Raises:
    NotFoundError: If session not found

Example:
    ```bash
    curl -X GET "http://localhost:8000/v1/agents/sessions/ses_abc123/history?limit=20&offset=0" \
      -H "Authorization: Bearer {api_key}" \
      -H "X-Namespace: {namespace_id}"
    ```



## OpenAPI

````yaml get /v1/agents/sessions/{session_id}/history
openapi: 3.1.0
info:
  title: Mixpeek API
  description: >-
    This is the Mixpeek API, providing access to various endpoints for data
    processing and retrieval.
  termsOfService: https://mixpeek.com/terms
  contact:
    name: Mixpeek Support
    url: https://mixpeek.com/contact
    email: info@mixpeek.com
  version: '0.82'
servers:
  - url: https://api.mixpeek.com
    description: Production
security: []
paths:
  /v1/agents/sessions/{session_id}/history:
    get:
      tags:
        - Agent Sessions
      summary: Get History
      description: |-
        Get conversation history for a session.

        Returns messages in chronological order (oldest first).

        Args:
            request: FastAPI request with tenant context
            session_id: Session identifier
            limit: Maximum messages to return (default: 50, max: 200)
            offset: Pagination offset (default: 0)

        Returns:
            GetHistoryResponse with message history

        Raises:
            NotFoundError: If session not found

        Example:
            ```bash
            curl -X GET "http://localhost:8000/v1/agents/sessions/ses_abc123/history?limit=20&offset=0" \
              -H "Authorization: Bearer {api_key}" \
              -H "X-Namespace: {namespace_id}"
            ```
      operationId: get_history_v1_agents_sessions__session_id__history_get
      parameters:
        - name: session_id
          in: path
          required: true
          schema:
            type: string
            description: Session ID
            title: Session Id
          description: Session ID
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            maximum: 200
            minimum: 1
            description: Maximum messages to return
            default: 50
            title: Limit
          description: Maximum messages to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            title: Offset
            description: Pagination offset
            default: 0
          description: Pagination offset
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetHistoryResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    GetHistoryResponse:
      properties:
        session_id:
          type: string
          title: Session Id
          description: Session identifier
        messages:
          items:
            $ref: '#/components/schemas/MessageHistoryItem'
          type: array
          title: Messages
          description: Message history
        total_messages:
          type: integer
          title: Total Messages
          description: Total messages in session
        returned_messages:
          type: integer
          title: Returned Messages
          description: Messages returned
        has_more:
          type: boolean
          title: Has More
          description: Whether more messages available
      type: object
      required:
        - session_id
        - messages
        - total_messages
        - returned_messages
        - has_more
      title: GetHistoryResponse
      description: |-
        Response for retrieving conversation history.

        Attributes:
            session_id: Session identifier
            messages: List of messages in chronological order
            total_messages: Total number of messages in session
            returned_messages: Number of messages returned (may be limited)
            has_more: Whether there are more messages available

        Example:
            ```python
            response = GetHistoryResponse(
                session_id="ses_abc123",
                messages=[...],
                total_messages=50,
                returned_messages=20,
                has_more=True
            )
            ```
    ErrorResponse:
      properties:
        success:
          type: boolean
          title: Success
          description: Always false for error responses
          default: false
        status:
          type: integer
          title: Status
          description: HTTP status code for this error
        error:
          $ref: '#/components/schemas/ErrorDetail'
          description: Error details payload
      type: object
      required:
        - status
        - error
      title: ErrorResponse
      description: Error response model.
      examples:
        - error:
            details:
              id: ns_123
              resource: namespace
            message: Namespace not found
            type: NotFoundError
          status: 404
          success: false
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    MessageHistoryItem:
      properties:
        message_id:
          type: string
          title: Message Id
          description: Message identifier
        role:
          type: string
          title: Role
          description: Message role
        content:
          type: string
          title: Content
          description: Message content
        content_type:
          type: string
          title: Content Type
          description: Content type
        tool_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Tool Name
          description: Tool name (if tool message)
        tool_inputs:
          anyOf:
            - type: string
            - type: 'null'
          title: Tool Inputs
          description: Tool inputs (if tool call)
        tool_outputs:
          anyOf:
            - type: string
            - type: 'null'
          title: Tool Outputs
          description: Tool outputs (if tool result)
        tool_status:
          anyOf:
            - type: string
            - type: 'null'
          title: Tool Status
          description: Tool status (if tool message)
        timestamp:
          type: string
          format: date-time
          title: Timestamp
          description: Message timestamp
      type: object
      required:
        - message_id
        - role
        - content
        - content_type
        - timestamp
      title: MessageHistoryItem
      description: |-
        Single message in conversation history.

        Attributes:
            message_id: Message identifier
            role: Message role (user, assistant, tool)
            content: Message text content
            content_type: Content type (text, tool_call, tool_result)
            tool_name: Tool name (if tool message)
            tool_inputs: Tool inputs (if tool call)
            tool_outputs: Tool outputs (if tool result)
            tool_status: Tool execution status (if tool message)
            timestamp: Message timestamp
    ErrorDetail:
      properties:
        message:
          type: string
          title: Message
          description: Human-readable error message
        type:
          type: string
          title: Type
          description: Stable error type identifier (machine-readable)
        code:
          anyOf:
            - type: string
            - type: 'null'
          title: Code
          description: >-
            Fine-grained error code for programmatic handling (e.g.,
            namespace_name_taken, feature_extractor_not_found). Present only
            when consumers may need to branch on a specific error condition.
        details:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Details
          description: >-
            Optional structured details to help debugging (validation errors,
            IDs, etc.)
      type: object
      required:
        - message
        - type
      title: ErrorDetail
      description: Error detail model.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````