Base URL
Authentication
Currently, the Sessions API does not require authentication. In production environments, you should implement appropriate authentication mechanisms.Endpoints
Create Session
Creates a new conversation session with an agent.POST /api/messaging/sessions
Create a new session with configurable timeout policies
Get Session Information
Retrieves detailed information about a session including its current status.GET /api/messaging/sessions/{sessionId}
Get session details and current status
404 Not Found- Session does not exist410 Gone- Session has expired
Send Message
Sends a message within a session. Automatically renews the session if auto-renewal is enabled.POST /api/messaging/sessions/{sessionId}/messages
Send a message in the conversation
400 Bad Request- Invalid content or metadata404 Not Found- Session not found410 Gone- Session expired
Get Messages
Retrieves messages from a session with pagination support.GET /api/messaging/sessions/{sessionId}/messages
Retrieve conversation history
Renew Session
Manually renews a session to extend its expiration time.POST /api/messaging/sessions/{sessionId}/renew
Manually extend session lifetime
404 Not Found- Session not found410 Gone- Session expired422 Unprocessable Entity- Cannot renew (max duration reached)
Update Timeout Configuration
Updates the timeout configuration for an active session.PATCH /api/messaging/sessions/{sessionId}/timeout
Modify session timeout settings
SessionInfoResponse
Errors:
400 Bad Request- Invalid timeout configuration404 Not Found- Session not found410 Gone- Session expired
Send Heartbeat
Keeps a session alive and optionally renews it if auto-renewal is enabled.POST /api/messaging/sessions/{sessionId}/heartbeat
Keep session alive with periodic heartbeat
SessionInfoResponse with updated expiration information.
Errors:
404 Not Found- Session not found410 Gone- Session expired
Delete Session
Explicitly ends and removes a session.DELETE /api/messaging/sessions/{sessionId}
End and delete a session
404 Not Found- Session not found
List Sessions (Admin)
Lists all active sessions in the system. This is an administrative endpoint.GET /api/messaging/sessions
List all active sessions
Health Check
Checks the health status of the Sessions API service.GET /api/messaging/sessions/health
Check service health
Error Responses
All error responses follow a consistent format:Common Error Codes
| Status Code | Error Type | Description |
|---|---|---|
400 | Bad Request | Invalid input parameters or request body |
404 | Not Found | Session or resource not found |
410 | Gone | Session has expired |
422 | Unprocessable Entity | Operation cannot be completed (e.g., max duration reached) |
500 | Internal Server Error | Unexpected server error |
Error Classes
The API uses specific error classes for different scenarios:SessionNotFoundError- Session does not existSessionExpiredError- Session has exceeded its timeoutSessionCreationError- Failed to create sessionAgentNotFoundError- Specified agent not foundInvalidUuidError- Invalid UUID formatMissingFieldsError- Required fields missingInvalidContentError- Message content validation failedInvalidMetadataError- Metadata exceeds size limitInvalidPaginationError- Invalid pagination parametersInvalidTimeoutConfigError- Invalid timeout configurationSessionRenewalError- Cannot renew sessionMessageSendError- Failed to send message
Rate Limiting
Currently, the Sessions API does not implement rate limiting. In production, you should implement appropriate rate limiting based on your requirements.WebSocket Events
When using WebSocket connections alongside the Sessions API, the following events are available:Environment Variables
Configure the Sessions API behavior using these environment variables:| Variable | Default | Description |
|---|---|---|
SESSION_DEFAULT_TIMEOUT_MINUTES | 30 | Default session timeout |
SESSION_MIN_TIMEOUT_MINUTES | 5 | Minimum allowed timeout |
SESSION_MAX_TIMEOUT_MINUTES | 1440 | Maximum allowed timeout (24 hours) |
SESSION_MAX_DURATION_MINUTES | 720 | Maximum total session duration (12 hours) |
SESSION_WARNING_THRESHOLD_MINUTES | 5 | When to trigger expiration warning |
SESSION_CLEANUP_INTERVAL_MINUTES | 5 | How often to clean expired sessions |
CLEAR_SESSIONS_ON_SHUTDOWN | false | Clear all sessions on server shutdown |
SDK Examples
JavaScript/TypeScript Client
Python Client
Next Steps
Sessions Guide
Learn best practices and advanced patterns
WebSocket Integration
Add real-time capabilities to your sessions
Core Concepts
Understand ElizaOS architecture
Create a Plugin
Build custom plugins for your agents

