Skip to main content
GET
/
v1
/
sessions
List Sessions
curl --request GET \
  --url https://api.example.com/v1/sessions \
  --header 'Authorization: <authorization>'
[
  {
    "session_id": "f6a7b0e6-7f46-4a0d-9a47-92b7f0a4d2d3",
    "agent_name": "agi-0",
    "status": "running",
    "created_at": "2025-10-05T18:04:34.281Z"
  },
  {
    "session_id": "a1b2c3d4-5e6f-7g8h-9i0j-k1l2m3n4o5p6",
    "agent_name": "agi-0-fast",
    "status": "completed",
    "created_at": "2025-10-05T17:30:15.123Z"
  }
]

Overview

Returns a list of all sessions belonging to the authenticated user, including both active and completed sessions.

Request

Authorization
string
required
Bearer token for authentication

Response

Returns an array of session objects.
session_id
string
Unique identifier for the session
agent_name
string
The agent model being used
status
string
Current session statusPossible values:
  • initializing - Session is being set up
  • ready - Ready to receive messages
  • running - Actively executing a task
  • paused - Execution is paused
  • completed - Task finished successfully
  • error - Session encountered an error
  • terminated - Session has been deleted
created_at
string
ISO 8601 timestamp of session creation
[
  {
    "session_id": "f6a7b0e6-7f46-4a0d-9a47-92b7f0a4d2d3",
    "agent_name": "agi-0",
    "status": "running",
    "created_at": "2025-10-05T18:04:34.281Z"
  },
  {
    "session_id": "a1b2c3d4-5e6f-7g8h-9i0j-k1l2m3n4o5p6",
    "agent_name": "agi-0-fast",
    "status": "completed",
    "created_at": "2025-10-05T17:30:15.123Z"
  }
]

Example Requests

curl https://api.agi.tech/v1/sessions \
  -H "Authorization: Bearer $AGI_API_KEY"

Use Cases

Monitor Active Sessions

# Get all running sessions
sessions = get_sessions()
active = [s for s in sessions if s['status'] == 'running']
print(f"Active sessions: {len(active)}")

Clean Up Old Sessions

# Delete completed sessions
sessions = get_sessions()
for session in sessions:
    if session['status'] in ['completed', 'error']:
        delete_session(session['session_id'])

Session Dashboard

Build a dashboard showing all user sessions with their current status and creation time.

Best Practices

Poll this endpoint periodically to monitor session health and automatically clean up completed sessions
Use this endpoint to prevent duplicate session creation by checking for existing active sessions