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

# Get Message History

> Retrieve conversation history for a session

### Authorization

<ParamField header="Authorization" type="string" required>
  Bearer token. Format: `Bearer synthra_live_abc123def456`
</ParamField>

### Path Parameters

<ParamField path="sessionId" type="string" required>
  Unique session identifier. Format: `session_<16 chars>`
</ParamField>

### Query Parameters

<ParamField query="limit" type="number" default="50">
  Maximum number of messages to return. Max: 100
</ParamField>

<ParamField query="cursor" type="string">
  Cursor for pagination. Use `nextCursor` from previous response.
</ParamField>

<ParamField query="order" type="string" default="desc">
  Sort order. Options: `asc`, `desc`
</ParamField>

### Response

<ResponseField name="data" type="array">
  Array of message objects
</ResponseField>

<ResponseField name="pagination" type="object">
  Pagination metadata

  Properties:

  * `hasMore` (boolean): Whether more messages exist
  * `nextCursor` (string): Cursor for next page
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request GET \
    --url 'https://api.synthra.ai/v1/sessions/session_abc123def456/messages?limit=20' \
    --header 'Authorization: Bearer synthra_live_abc123def456'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    'https://api.synthra.ai/v1/sessions/session_abc123def456/messages?limit=20',
    {
      headers: {
        'Authorization': `Bearer ${process.env.SYNTHRA_API_KEY}`
      }
    }
  );
  ```

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

  response = requests.get(
      'https://api.synthra.ai/v1/sessions/session_abc123def456/messages',
      headers={
          'Authorization': f'Bearer {api_key}'
      },
      params={
          'limit': 20
      }
  )
  ```
</RequestExample>

<ResponseExample>
  ```json 200 - Success theme={null}
  {
    "data": [
      {
        "messageId": "msg_abc123def456",
        "sessionId": "session_abc123def456",
        "role": "user",
        "content": "Hello, Synthra!",
        "tokens": 4,
        "createdAt": "2024-03-08T14:30:00Z"
      },
      {
        "messageId": "msg_xyz789ghi012",
        "sessionId": "session_abc123def456",
        "role": "assistant",
        "content": "Hello! How can I help you today?",
        "tokens": 8,
        "createdAt": "2024-03-08T14:30:01Z"
      }
    ],
    "pagination": {
      "hasMore": true,
      "nextCursor": "msg_xyz789ghi012"
    }
  }
  ```
</ResponseExample>
