Overview
Sessions store conversation history between the user and the agent. Each session has a unique key and includes all messages, timestamps, and metadata. The Sessions API provides CRUD operations for managing these sessions.GET /api/v1/sessions
List all session keys with metadata.Request
Response
Array of session key strings.
Total number of sessions.
Example Response
Python Example
GET /api/v1/sessions/
Get detailed information about a specific session.Request
The session key (URL path parameter). Can contain slashes, colons, and special characters.
Session keys can contain special characters like colons and slashes. URL-encode keys if they contain spaces or other reserved characters.
Response
The session key.
Total number of messages (user + assistant) in the session.
Unix timestamp (seconds since epoch) when the session was created.
Unix timestamp when the session was last updated.
Time in seconds since the session was created (rounded to 1 decimal place).
Example Response
Python Example
Error Responses
404 Not Found - Session does not exist:DELETE /api/v1/sessions/
Delete a session by key. This permanently removes the session file and all conversation history.Request
The session key to delete (URL path parameter).
Response
Always
true on successful deletion.The session key that was deleted.
Example Response
Python Example
Error Responses
404 Not Found - Session does not exist:Session File Structure
Sessions are stored as JSON files in<workspace>/sessions/:
Session Key Formats
Session keys follow different patterns depending on the source:| Source | Format | Example |
|---|---|---|
| API (auto) | api:<12-hex> | api:a3f9c2e8b1d4 |
| API (custom) | User-defined | user:alice:project-planning |
| CLI | cli:default | cli:default |
| Telegram | telegram:<user-id> | telegram:123456789 |
| Discord | discord:<user-id> | discord:987654321 |
| Slack | slack:<user-id> | slack:U01234ABCDE |
^[\w:.@-]+$ (max 128 characters).
Bulk Operations
Delete Multiple Sessions
No bulk delete endpoint exists. To delete multiple sessions, iterate:Export Session Data
To export conversation history, read the session files directly:Rate Limiting
All session endpoints are subject to standard rate limits:- Per-IP: 60 requests/min
- Per-token: 60 requests/min
Best Practices
Use descriptive session keys
Use descriptive session keys
Custom keys like
user:alice:project-planning are easier to manage than auto-generated keys like api:a3f9c2e8b1d4.Clean up old sessions periodically
Clean up old sessions periodically
List sessions, filter by age or prefix, and delete unused ones to save disk space.
Back up important sessions
Back up important sessions
Copy session JSON files before deletion or server migration. They’re stored in
<workspace>/sessions/.Monitor session count
Monitor session count
Use the list endpoint to track total sessions. Set up alerts if the count grows unexpectedly.
Next Steps
Chat API
Create and manage sessions through chat
Management API
View system status and metrics