Retrieve the full conversation history for a session. Useful for restoring chat state when a user revisits a page.
Endpoint
GET /api/history?session_id={session_id}
Query Parameters
| Parameter | Type | Required | Description |
|---|
| string | Yes | The session ID used in requests |
Response
200 OK
Returns an array of messages in chronological order. Only
and
roles are returned.
{
"messages": [
{
"role": "user",
"content": "Hello! I need help with my order.",
"created_at": "2026-04-05T10:00:00.000000Z"
},
{
"role": "assistant",
"content": "I'd be happy to help! Could you share your order number?",
"created_at": "2026-04-05T10:00:01.000000Z"
}
]
}
If the session has no conversation yet (or has expired), an empty array is returned:
Example
cURL
curl https://ai.vindex.ai/api/history?session_id=user-abc-123 \
-H "X-API-Key: amgai_your-channel-key-here"
JavaScript
async function loadHistory(sessionId, apiKey) {
const response = await fetch(
`https://ai.vindex.ai/api/history?session_id=${sessionId}`,
{
headers: { 'X-API-Key': apiKey }
}
);
const { messages } = await response.json();
return messages; // [{ role, content, created_at }, ...]
}
Python
import requests
response = requests.get(
'https://ai.vindex.ai/api/history',
params={'session_id': 'user-abc-123'},
headers={'X-API-Key': 'amgai_your-channel-key-here'}
)
messages = response.json()['messages']
for msg in messages:
print(f"{msg['role']}: {msg['content']}")
Note: History is tied to the session's conversation window. Sessions expire after 24 hours of inactivity, after which
will return empty.