Skip to main content

Overview

Creates or resumes a session in the LongMem database. Sessions track related observations and prompts across a coding workflow.

Authentication

Requires Bearer token if authToken is configured in daemon settings.
Authorization: Bearer <your-token>

Request

session_id
string
required
Unique identifier for the session (typically from your AI coding tool)
project
string
default:"default"
Project name or identifier
directory
string
Working directory path for this session

Response

status
string
Always “ok” on success
db_id
number
Internal database ID for this session

Example

cURL
curl -X POST http://localhost:38741/session/start \
  -H "Content-Type: application/json" \
  -d '{
    "session_id": "my-coding-session-123",
    "project": "my-app",
    "directory": "/home/user/projects/my-app"
  }'
Response
{
  "status": "ok",
  "db_id": 42
}

Use Cases

Integration Setup

Call this when starting a new coding session to ensure observations are properly tracked:
const response = await fetch('http://localhost:38741/session/start', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    session_id: generateSessionId(),
    project: getCurrentProject(),
    directory: process.cwd()
  })
});

const { db_id } = await response.json();

Session Recovery

If your tool crashes and restarts, calling /session/start with the same session_id will resume the existing session rather than create a duplicate.

Implementation Details

From daemon/routes.ts:234-243:
  • Creates a new session in SQLite if session_id doesn’t exist
  • Returns existing db_id if session already exists
  • Caches the session ID mapping for fast lookups
  • Sessions remain active until explicitly ended or daemon restarts

Error Responses

Missing session_id

{
  "error": "session_id required"
}
Status: 400

Build docs developers (and LLMs) love