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:| Parameter | Type | Required | Description |
|---|---|---|---|
conversation_id | string | ✅ | Session ID from create session response |
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
limit | number | ❌ | 50 | Max messages to return (max: 100) |
offset | number | ❌ | 0 | Skip this many messages |
Response
Status:200 OK
Response Fields
| Field | Type | Description |
|---|---|---|
messages | array | List of message objects |
messages[].role | string | user or assistant |
messages[].content | string | Message text content |
messages[].timestamp | string | ISO 8601 datetime |
messages[].token_count | number | Token count (assistant messages only) |
count | number | Total messages returned |
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
Related Endpoints
- Create Session — Start new session
- Send Message — Send messages with SSE
- End Session — End and cleanup
Next Steps
Send Message
Continue the conversation with SSE streaming.
End Session
Properly end session to trigger cleanup.