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

# Get Conversation History

> Retrieve message history for a session.

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET https://api.thinnest.ai/sessions/{session_id}/messages \
    -H "Authorization: Bearer $THINNESTAI_API_KEY"
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.thinnest.ai/sessions/{session_id}/messages"
  headers = {
      "Authorization": "Bearer " + "YOUR_THINNESTAI_API_KEY",
  }

  response = requests.get(url, headers=headers)
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://api.thinnest.ai/sessions/{session_id}/messages", {
    method: "GET",
    headers: {
      "Authorization": "Bearer " + "YOUR_THINNESTAI_API_KEY",
    },
  });

  const data = await response.json();
  console.log(data);
  ```

  ```go Go theme={null}
  package main

  import (
      "fmt"
      "io"
      "net/http"
  )

  func main() {
      req, _ := http.NewRequest("GET", "https://api.thinnest.ai/sessions/{session_id}/messages", nil)
      req.Header.Set("Authorization", "Bearer YOUR_THINNESTAI_API_KEY")

      resp, err := http.DefaultClient.Do(req)
      if err != nil { panic(err) }
      defer resp.Body.Close()
      body, _ := io.ReadAll(resp.Body)
      fmt.Println(string(body))
  }
  ```
</RequestExample>

***

## Path Parameters

<ParamField path="session_id" type="string" required>
  The session ID from a chat response
</ParamField>

***

## Query Parameters

<ParamField query="limit" type="integer" default="50">
  Maximum number of messages to return
</ParamField>

***

## Response `200`

<ResponseExample>
  ```json 200 theme={null}
  {
    "session_id": "sess_customer_001",
    "messages": [
      {
        "role": "user",
        "content": "What are your business hours?",
        "timestamp": "2026-03-07T12:00:00Z"
      },
      {
        "role": "assistant",
        "content": "Our business hours are Monday through Friday, 9 AM to 6 PM EST.",
        "timestamp": "2026-03-07T12:00:01Z",
        "usage": {
          "input_tokens": 45,
          "output_tokens": 22
        }
      },
      {
        "role": "user",
        "content": "Are you open on weekends?",
        "timestamp": "2026-03-07T12:01:15Z"
      },
      {
        "role": "assistant",
        "content": "Yes, we're open on Saturdays from 10 AM to 2 PM. Closed on Sundays.",
        "timestamp": "2026-03-07T12:01:16Z",
        "usage": {
          "input_tokens": 78,
          "output_tokens": 20
        }
      }
    ]
  }
  ```
</ResponseExample>

### Response Fields

<ResponseField name="session_id" type="string">
  Session identifier
</ResponseField>

<ResponseField name="messages" type="array">
  Chronologically ordered message list
</ResponseField>

<ResponseField name="messages[].role" type="string">
  user or assistant
</ResponseField>

<ResponseField name="messages[].content" type="string">
  Message text
</ResponseField>

<ResponseField name="messages[].timestamp" type="string">
  ISO 8601 timestamp
</ResponseField>

<ResponseField name="messages[].usage" type="object">
  Token usage (assistant messages only)
</ResponseField>

***

## Errors

| Code  | Description                       |
| ----- | --------------------------------- |
| `401` | Missing or invalid authentication |
| `404` | Session not found                 |


## OpenAPI

````yaml GET /sessions/{session_id}/messages
openapi: 3.1.0
info:
  title: ThinnestAI API
  description: REST API for ThinnestAI — build, deploy, and manage AI agents.
  version: 1.0.0
servers: []
security: []
tags:
  - name: Agents
    description: Create, configure, and manage AI agents
  - name: Chat
    description: Send messages and get AI responses from agents
  - name: Knowledge
    description: Upload files, URLs, and text to agent knowledge bases
  - name: Sessions
    description: View and manage chat sessions and message history
  - name: Voice
    description: Start and manage voice call sessions
  - name: Recordings
    description: Manage voice call recordings
  - name: Campaigns
    description: Create and run automated outreach campaigns
  - name: Webhooks
    description: Register webhook endpoints for real-time event notifications
  - name: Evaluations
    description: Run and track agent evaluation benchmarks
  - name: Analytics
    description: Query agent performance metrics and usage data
  - name: Agent Tools
    description: View and manage tools attached to agents
  - name: BYOK
    description: >-
      Bring Your Own Key — manage credentials for LLM/STT/TTS providers,
      telephony BYOK (Vobiz/Twilio/Plivo/Exotel/Telnyx), and tool-specific BYOK
      (Razorpay UPI Payment, Surepass Aadhaar eKYC)
paths:
  /sessions/{session_id}/messages:
    get:
      tags:
        - Sessions
      summary: Get Session Messages
      description: Get all messages in a session.
      operationId: get_session_messages_sessions__session_id__messages_get
      parameters:
        - name: session_id
          in: path
          required: true
          schema:
            type: string
            title: Session Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    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

````