Session Management
List Sessions
Retrieves a list of all active sessions.
GET/api/sessions
Responses
Success (200)
{
"sessions": [
{
"id": "b4a2a3e8-72b1-4d00-a5c3-1a2c3d4e5f6a",
"createdAt": "2023-10-27T10:00:00.000Z",
"lastActivity": "2023-10-27T10:05:00.000Z",
"messageCount": 4
}
]
}
Create Session
Creates a new session.
POST/api/sessions
Request Body
sessionId
(string, optional): A custom ID for the new session.
Responses
Success (201)
{
"session": {
"id": "c5b3b4f9-83c2-5e11-b6d4-2b3d4e5f6a7b",
"createdAt": "2023-10-27T11:00:00.000Z",
"lastActivity": "2023-10-27T11:00:00.000Z",
"messageCount": 0
}
}
Get Session Details
Fetches details for a specific session.
GET/api/sessions/:sessionId
Responses
Success (200)
{
"session": {
"id": "b4a2a3e8-72b1-4d00-a5c3-1a2c3d4e5f6a",
"createdAt": "2023-10-27T10:00:00.000Z",
"lastActivity": "2023-10-27T10:05:00.000Z",
"messageCount": 4,
"history": 8
}
}
Error (404)
{
"error": "Session not found"
}
Get Session History
Retrieves the conversation history for a session.
GET/api/sessions/:sessionId/history
Responses
Success (200)
{
"history": [
{ "role": "user", "content": "Hello" },
{ "role": "assistant", "content": "Hi! How can I help?" }
]
}
Delete Session
Permanently deletes a session and all its conversation history. This action cannot be undone.
DELETE/api/sessions/:sessionId
Responses
Success (200)
{
"status": "deleted",
"sessionId": "b4a2a3e8-72b1-4d00-a5c3-1a2c3d4e5f6a"
}
Load Session
Sets a session as the current "active" session.
POST/api/sessions/:sessionId/load
Responses
Success (200)
{
"status": "loaded",
"sessionId": "b4a2a3e8-72b1-4d00-a5c3-1a2c3d4e5f6a",
"currentSession": "b4a2a3e8-72b1-4d00-a5c3-1a2c3d4e5f6a"
}