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

# Get Session Chat

> Returns the chat's persisted UI message stream plus its current streaming state so callers can hydrate or refresh a chat view. `messages` is an array of `parts` payloads — one per `chat_messages` row — ordered by `created_at` ascending (ties broken by id). `isStreaming` is derived from `activeStreamId`.



## OpenAPI

````yaml api-reference/openapi/sessions.json GET /api/sessions/{sessionId}/chats/{chatId}
openapi: 3.1.0
info:
  title: Recoup API - Sessions
  description: >-
    Sessions — sandboxed runs of an LLM-driven agent with tool use, lifecycle
    hooks, and persistence. Each session pairs one Vercel Sandbox with one or
    more chat threads.
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.recoupable.dev
security:
  - ApiKeyAuth: []
  - BearerAuth: []
paths:
  /api/sessions/{sessionId}/chats/{chatId}:
    get:
      summary: Get session chat
      description: >-
        Returns the chat's persisted UI message stream plus its current
        streaming state so callers can hydrate or refresh a chat view.
        `messages` is an array of `parts` payloads — one per `chat_messages` row
        — ordered by `created_at` ascending (ties broken by id). `isStreaming`
        is derived from `activeStreamId`.
      parameters:
        - name: sessionId
          in: path
          required: true
          description: The id of the parent session.
          schema:
            type: string
        - name: chatId
          in: path
          required: true
          description: The id of the chat being fetched.
          schema:
            type: string
      responses:
        '200':
          description: Chat retrieved successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionChatResponse'
        '401':
          description: Unauthorized — invalid or missing API key / Bearer token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Forbidden — the authenticated account does not own this session.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: >-
            Not found — no session exists with the given id, the chat does not
            exist, or the chat belongs to a different session.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    SessionChatResponse:
      type: object
      description: >-
        Response body for `GET /api/sessions/{sessionId}/chats/{chatId}`.
        Carries the full chat row plus its streaming state and persisted UI
        message stream — enough for both initial render and in-tab refresh.
      required:
        - chat
        - isStreaming
        - messages
      properties:
        chat:
          $ref: '#/components/schemas/Chat'
        isStreaming:
          type: boolean
          description: True when `chat.activeStreamId` is non-null.
        messages:
          type: array
          description: >-
            Persisted UI message stream — one serialized `UIMessage` per
            `chat_messages` row, ordered by `created_at` ascending (ties broken
            by `id`). Each item is the full message object, not a bare parts
            array.
          items:
            type: object
            description: A serialized `UIMessage` as stored by the agent.
            required:
              - id
              - role
              - parts
            properties:
              id:
                type: string
                description: Message id.
              role:
                type: string
                enum:
                  - user
                  - assistant
              parts:
                type: array
                description: Ordered message parts (text, tool calls, data parts, etc.).
                items:
                  type: object
                  additionalProperties: true
            additionalProperties: true
    Error:
      type: object
      required:
        - status
        - error
      properties:
        status:
          type: string
          enum:
            - error
          description: Always `"error"` for error responses.
        error:
          type: string
          description: Human-readable error message.
    Chat:
      type: object
      required:
        - id
        - sessionId
        - title
        - modelId
        - createdAt
        - updatedAt
      properties:
        id:
          type: string
          description: Chat id (nanoid).
        sessionId:
          type: string
          description: Owning session id.
        title:
          type: string
          description: >-
            Display title for the chat. The initial chat created with a session
            is titled `New chat`.
        modelId:
          type: string
          description: >-
            AI Gateway model identifier the chat is configured to use (e.g.
            `openai/gpt-5.4`).
        activeStreamId:
          type: string
          nullable: true
          description: Id of an in-flight assistant stream, if one is active.
        lastAssistantMessageAt:
          type: string
          format: date-time
          nullable: true
          description: Timestamp of the most recent assistant message in this chat.
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
    BearerAuth:
      type: http
      scheme: bearer

````