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

# Restore the full conversation and document state for a previous session.

> Returns complete message history (user and AI), final document HTML with chunk IDs preserved, attachment list, and editor actions (font, color, alignment changes). Use to continue editing a document you started in a prior session. The AI rehydrates with full context of all prior decisions, chunk IDs, and attachments. Pass include_document_html=false to skip the full document body when you only need the conversation.



## OpenAPI

````yaml /openapi.json get /v1/sessions/{session_id}/history
openapi: 3.1.0
info:
  title: Universal Document AI API
  description: AI-powered document editing with multi-tenant organization support
  version: 2.0.0
servers: []
security: []
paths:
  /v1/sessions/{session_id}/history:
    get:
      tags:
        - v1
        - mcp
        - sessions
      summary: Restore the full conversation and document state for a previous session.
      description: >-
        Returns complete message history (user and AI), final document HTML with
        chunk IDs preserved, attachment list, and editor actions (font, color,
        alignment changes). Use to continue editing a document you started in a
        prior session. The AI rehydrates with full context of all prior
        decisions, chunk IDs, and attachments. Pass include_document_html=false
        to skip the full document body when you only need the conversation.
      operationId: get_session_history
      parameters:
        - name: session_id
          in: path
          required: true
          schema:
            type: string
            title: Session Id
        - name: focus_document_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              Durable id of the document to focus on restore (e.g. the file the
              user clicked in the Files view). When set, that document is shown
              in the editor and marked focused in the roster; omit to use the
              session's own last-focused document.
            title: Focus Document Id
          description: >-
            Durable id of the document to focus on restore (e.g. the file the
            user clicked in the Files view). When set, that document is shown in
            the editor and marked focused in the roster; omit to use the
            session's own last-focused document.
        - name: include_document_html
          in: query
          required: false
          schema:
            type: boolean
            description: >-
              When false, omit the restored document's full HTML body
              (document_state.html_content) to keep your context small — agents
              that just need the conversation + metadata should set false.
              Default true (the web app needs the body to re-render the editor).
            default: true
            title: Include Document Html
          description: >-
            When false, omit the restored document's full HTML body
            (document_state.html_content) to keep your context small — agents
            that just need the conversation + metadata should set false. Default
            true (the web app needs the body to re-render the editor).
        - name: authorization
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Authorization
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnhancedChatHistoryResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    EnhancedChatHistoryResponse:
      properties:
        session_id:
          type: string
          title: Session Id
          description: Session identifier.
        messages:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Messages
          description: >-
            Ordered list of messages. Each item has: id (string), sender ('user'
            or 'ai'), content (string), timestamp (ISO 8601), turn_index (int),
            checkpoint_id (string or null — present on turns recorded after the
            revertability feature shipped; null for legacy turns where revert is
            unavailable).
        document_state:
          anyOf:
            - $ref: '#/components/schemas/DocumentState'
            - type: 'null'
          description: >-
            Current document state. Present if the session has an active
            document.
        editor_action:
          type: string
          title: Editor Action
          description: >-
            Client instruction: 'update' (load document_state HTML into editor),
            'clear' (reset editor), or 'keep' (no change).
          default: keep
      type: object
      required:
        - session_id
        - messages
      title: EnhancedChatHistoryResponse
      description: Conversation history with document state and restoration instructions.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    DocumentState:
      properties:
        html_content:
          anyOf:
            - type: string
            - type: 'null'
          title: Html Content
          description: Full document HTML content with data-chunk-id attributes.
        document_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Document Id
          description: >-
            Session-local id (slug) of the focused document. Identifies the
            document on restore so a restored tab stays in sync with edits made
            to it in other sessions.
        version_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Version Id
          description: Document version identifier (UUID string).
        chunk_count:
          type: integer
          title: Chunk Count
          description: Number of content sections in the document.
          default: 0
        last_modified:
          anyOf:
            - type: string
            - type: 'null'
          title: Last Modified
          description: ISO 8601 timestamp of the last modification.
        attachments:
          anyOf:
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
          title: Attachments
          description: >-
            Session attachments. Each item has: id (string), filename (string),
            file_extension (string), processing_status ('ready', 'processing',
            or 'failed').
        page_setup:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Page Setup
          description: >-
            Source page geometry of the focused document (width_in, height_in,
            margin_in{top,right,bottom,left}, orientation) when known, else
            null. The editor renders the page at this geometry on restore; null
            ⇒ US-Letter + 1in default.
      type: object
      title: DocumentState
      description: Current document state for session restoration.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````