Skip to main content

REST API

The Claude Session Tools server exposes a REST API for session management.

Base URL​

http://localhost:41820/api

Endpoints​

List Sessions​

Retrieve all monitored sessions.

GET /api/sessions

Response

{
"sessions": [
{
"name": "my-project",
"claude": {
"primary": "active",
"detail": "thinking",
"health": "ALIVE",
"timestamp": "2024-01-15T10:30:00.000Z",
"unchangedCount": 0
}
}
]
}

Response Fields

FieldTypeDescription
sessionsarrayList of session objects
sessions[].namestringSession identifier
sessions[].claudeobjectClaude status information
sessions[].claude.primarystringPrimary status
sessions[].claude.detailstringDetail status (nullable)
sessions[].claude.healthstringHealth state
sessions[].claude.timestampstringISO 8601 timestamp
sessions[].claude.unchangedCountnumberConsecutive unchanged checks

Create Session​

Add a session to monitoring.

POST /api/sessions

Request Body

{
"name": "my-project"
}

Request Fields

FieldTypeRequiredDescription
namestringYesSession name (must match loggable-session name)

Response (Success)

{
"success": true,
"session": {
"name": "my-project",
"claude": {
"primary": "idle",
"detail": "waiting_input",
"health": "ALIVE",
"timestamp": "2024-01-15T10:30:00.000Z",
"unchangedCount": 0
}
}
}

Response (Error)

{
"success": false,
"error": "Session not found"
}

Status Codes

CodeDescription
200Session created and monitoring started
400Invalid request (missing name)
404Session not found in loggable-session
409Session already being monitored

Delete Session​

Remove a session from monitoring.

DELETE /api/sessions/:name

Path Parameters

ParameterTypeDescription
namestringSession name to remove

Response (Success)

{
"success": true
}

Response (Error)

{
"success": false,
"error": "Session not found"
}

Status Codes

CodeDescription
200Session removed from monitoring
404Session not being monitored

Error Handling​

All error responses follow this format:

{
"success": false,
"error": "Error message description"
}

Common error scenarios:

ErrorCauseResolution
Session not foundSession name does not exist in loggable-sessionVerify session is running with logsession list
Session already monitoredAttempting to add duplicate sessionSession is already being tracked
Invalid session nameEmpty or malformed nameProvide valid session identifier

Usage Examples​

cURL​

List sessions:

curl http://localhost:41820/api/sessions

Create session:

curl -X POST http://localhost:41820/api/sessions \
-H "Content-Type: application/json" \
-d '{"name": "my-project"}'

Delete session:

curl -X DELETE http://localhost:41820/api/sessions/my-project

JavaScript (fetch)​

// List sessions
const response = await fetch('http://localhost:41820/api/sessions');
const data = await response.json();

// Create session
await fetch('http://localhost:41820/api/sessions', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name: 'my-project' })
});

// Delete session
await fetch('http://localhost:41820/api/sessions/my-project', {
method: 'DELETE'
});

Rate Limiting​

The API does not currently implement rate limiting. For production deployments with many clients, consider adding rate limiting middleware.

Authentication​

The API does not currently implement authentication. For production deployments, consider:

  • Adding API key authentication
  • Implementing JWT tokens
  • Using reverse proxy authentication