Skip to main content

Overview

Retrieves the message history for a specific chat session. Returns paginated results with message content, timestamps, and token counts. Authentication: Authorization: Bearer {session_token} Use Cases:
  • Page refresh (restore chat state)
  • Resuming abandoned sessions
  • Exporting conversation history
  • Displaying chat history in UI

Request

Path Parameters: Headers:
Query Parameters: Example:

Response

Status: 200 OK

Response Fields


Pagination

Default Behavior

  • Limit: 50 messages (default)
  • Offset: 0 (start from beginning)
  • Maximum: 100 messages per request

Paginating Large Histories

Getting Last N Messages


Error Responses

401 Unauthorized

403 Forbidden

404 Not Found


Examples

cURL

JavaScript (Fetch)

React (Load on Mount)

Next.js (Server Component)


Use Cases

1. Restore Chat After Page Refresh

2. Export Conversation

3. Infinite Scroll History


Best Practices

1. Cache History Locally

2. Limit Initial Load

3. Handle Session Expiry

4. Preserve Scroll Position



Next Steps

Send Message

Continue the conversation with SSE streaming.

End Session

Properly end session to trigger cleanup.