Overview
The Sessions API allows you to retrieve conversation history and access message details. All sessions are scoped to your organization and the API key creator.Sessions are automatically created when you send messages via Chat Completions API.
Required Scopes
All Sessions API endpoints require specific API key scopes:When creating an API key in the Admin panel, ensure you enable the appropriate scopes. Without the required scopes, requests will return a
403 Forbidden error.Endpoints
List Sessions
Retrieve all sessions created by your API key.Request
Sessions are automatically sorted by
last_update_time (most recent first). Custom sorting is not currently supported.Response
Status Code:200 OK
Response Fields
cURL Example
Get Session Messages
Retrieve all messages from a specific session.Request
Query Parameters:
Response
Status Code:200 OK
Message Object
Messages are always returned in chronological order (oldest first).
cURL Example
Get Session Processing Status
Check if a session is currently processing a message.Request
Response
Status Code:200 OK
Response Fields
Sessions automatically timeout after 30 minutes of processing.
cURL Example
Error Handling
Common Errors
Best Practices
- Use Pagination: Always use pagination with appropriate
page_size(max: 100 for sessions, 200 for messages) to avoid timeouts - Cache Session Data: Implement caching to reduce API calls (recommended TTL: 5 minutes)
- Poll Status for Long-Running Requests: Use the status endpoint to check if a session is still processing
- Handle Errors: Check for 404 (session not found) and 400 (invalid parameters) responses
Next Steps
Chat Completions API
Send messages and create sessions
Authentication
Learn about API key authentication
Rate Limits
Understand rate limiting
