GET /api/sessions Bearer

List Sessions

Retrieve all chat sessions with metadata including titles, message counts, creation dates, and active status. Sessions are returned sorted by most recent activity for easy navigation.

Overview

Returns a paginated list of all chat sessions with their metadata. Uses the fast session index for efficient retrieval.

Parameters

Query Parameters

limit
integer = 50

Maximum number of sessions to return.

Response

sessions array

Array of session objects, sorted by last activity (most recent first).

id string
Unique session identifier
title string
Session title (auto-generated or user-set)
created_at string
ISO 8601 creation timestamp
updated_at string
ISO 8601 last activity timestamp
message_count integer
Number of messages in the session
channel string
Origin channel (web, telegram, discord, etc.)

total integer

Total number of sessions available.

Terminal window
curl -X GET "http://localhost:8000/api/sessions?limit=50" \
-H "Authorization: Bearer <token>"
const response = await fetch("http://localhost:8000/api/sessions?limit=50", {
headers: { "Authorization": "Bearer <token>" }
});
const data = await response.json();
console.log(data);
import requests
response = requests.get(
"http://localhost:8000/api/sessions",
params={"limit": 50},
headers={"Authorization": "Bearer <token>"},
)
print(response.json())
{
"sessions": [
{
"id": "session_abc123",
"title": "Python prime numbers",
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T11:45:00Z",
"message_count": 12,
"channel": "web"
},
{
"id": "session_def456",
"title": "Docker deployment help",
"created_at": "2024-01-14T08:00:00Z",
"updated_at": "2024-01-14T09:30:00Z",
"message_count": 8,
"channel": "telegram"
}
],
"total": 42
}
Request
curl -X GET "http://localhost:8000/api/sessions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <token>"
const response = await fetch("http://localhost:8000/api/sessions", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
},
});

const data = await response.json();
console.log(data);
import requests

response = requests.get(
    "http://localhost:8000/api/sessions",
    headers={'Content-Type':'application/json','Authorization':'Bearer <token>'},
)

print(response.json())
package main

import (
    "fmt"
    "net/http"
    "io"
)

func main() {
    req, _ := http.NewRequest("GET", "http://localhost:8000/api/sessions", nil)
    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("Authorization", "Bearer <token>")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
Response
Send a request to see the response