Skip to main content

Session API

/api/sessions - Session management endpoints

Overview

The Session API provides independent session management functionality for task execution and agent interaction.

Endpoint List

MethodPathDescription
GET/api/sessionsList sessions
POST/api/sessionsCreate session
GET/api/sessions/:idGet session details
PATCH/api/sessions/:idUpdate session
DELETE/api/sessions/:idDelete session
POST/api/sessions/:id/messageSend message

Detailed Description

GET /api/sessions

List sessions.

Query Parameters:

ParameterTypeRequiredDescription
task_idstringNoFilter by task
agent_idstringNoFilter by agent
statusstringNoFilter by status

Response:

{
"sessions": [
{
"id": "session-abc123",
"agent_id": "CLAUDE_CODE",
"task_id": "task-xyz",
"status": "active",
"created_at": "2024-01-16T10:00:00Z",
"last_active": "2024-01-16T14:30:00Z",
"message_count": 42
}
]
}

POST /api/sessions

Create a new session.

Request Body:

{
"agent_id": "CLAUDE_CODE",
"task_id": "task-xyz",
"prompt": "Initial prompt for the session"
}
FieldTypeRequiredDescription
agent_idstringYesAgent ID
task_idstringNoAssociated task ID
promptstringNoInitial prompt

Response:

{
"id": "session-abc123",
"agent_id": "CLAUDE_CODE",
"task_id": "task-xyz",
"status": "created",
"created_at": "2024-01-16T10:00:00Z"
}

GET /api/sessions/:id

Get session details.

Response:

{
"id": "session-abc123",
"agent_id": "CLAUDE_CODE",
"task_id": "task-xyz",
"status": "active",
"created_at": "2024-01-16T10:00:00Z",
"last_active": "2024-01-16T14:30:00Z",
"message_count": 42,
"data": {
"workdir": "/path/to/project",
"model": "claude-3-sonnet"
}
}

PATCH /api/sessions/:id

Update a session.

Request Body:

{
"status": "paused",
"data": {
"notes": "Paused for review"
}
}
FieldTypeDescription
statusstringSession status
dataobjectSession data
promptstringUpdate prompt

POST /api/sessions/:id/message

Send a message to a session.

Request Body:

{
"content": "Please continue with the implementation"
}

Response:

{
"message_id": "msg-xyz",
"status": "sent",
"timestamp": "2024-01-16T14:35:00Z"
}

Session Status

StatusDescription
createdJust created
activeActive
pausedPaused
completedCompleted
failedFailed