Skip to main content

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.
Building your own product on Junis? Add on_behalf_of to read the sessions of a user you provisioned, and use DELETE to purge their data when they leave. See User Provisioning.

Required Scopes

All Sessions API endpoints require specific API key scopes: Adding on_behalf_of to any of them also requires users:delegate.
sessions:delete is opt-in and is never part of a default key. Grant it from Dashboard → API Keys → New Key by ticking “Connect users from my own app”.
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

Query Parameters:
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

Path Parameters: 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

Path Parameters: Query Parameters:

Response

Status Code: 200 OK
When not processing:
When timed out (30 minutes):

Response Fields

Sessions automatically timeout after 30 minutes of processing.

cURL Example


Delete Session

Permanently delete a session together with its messages and stored state.
This cannot be undone. There is no soft delete and no recovery window.

Request

Path Parameters: Query Parameters:

Response

Status Code: 200 OK

cURL Example

Deletions are recorded in your organization’s audit log.

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