Skip to main content
The Sessions API provides a comprehensive set of endpoints for managing stateful conversations with ElizaOS agents. This reference covers all available endpoints, request/response schemas, and error handling.

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
Request Body:
Response (201 Created):
Example:

Get Session Information

Retrieves detailed information about a session including its current status.

GET /api/messaging/sessions/{sessionId}

Get session details and current status
Response (200 OK):
Errors:
  • 404 Not Found - Session does not exist
  • 410 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
Request Body:
Response (201 Created):
Errors:
  • 400 Bad Request - Invalid content or metadata
  • 404 Not Found - Session not found
  • 410 Gone - Session expired

Get Messages

Retrieves messages from a session with pagination support.

GET /api/messaging/sessions/{sessionId}/messages

Retrieve conversation history
Query Parameters:
Response (200 OK):

Renew Session

Manually renews a session to extend its expiration time.

POST /api/messaging/sessions/{sessionId}/renew

Manually extend session lifetime
Response (200 OK):
Errors:
  • 404 Not Found - Session not found
  • 410 Gone - Session expired
  • 422 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
Request Body:
Response (200 OK): Returns updated SessionInfoResponse Errors:
  • 400 Bad Request - Invalid timeout configuration
  • 404 Not Found - Session not found
  • 410 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
Response (200 OK): Returns SessionInfoResponse with updated expiration information. Errors:
  • 404 Not Found - Session not found
  • 410 Gone - Session expired

Delete Session

Explicitly ends and removes a session.

DELETE /api/messaging/sessions/{sessionId}

End and delete a session
Response (200 OK):
Errors:
  • 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
Response (200 OK):

Health Check

Checks the health status of the Sessions API service.

GET /api/messaging/sessions/health

Check service health
Response (200 OK):

Error Responses

All error responses follow a consistent format:

Common Error Codes

Error Classes

The API uses specific error classes for different scenarios:
  • SessionNotFoundError - Session does not exist
  • SessionExpiredError - Session has exceeded its timeout
  • SessionCreationError - Failed to create session
  • AgentNotFoundError - Specified agent not found
  • InvalidUuidError - Invalid UUID format
  • MissingFieldsError - Required fields missing
  • InvalidContentError - Message content validation failed
  • InvalidMetadataError - Metadata exceeds size limit
  • InvalidPaginationError - Invalid pagination parameters
  • InvalidTimeoutConfigError - Invalid timeout configuration
  • SessionRenewalError - Cannot renew session
  • MessageSendError - 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:

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