Skip to main content

Sessions API

Query and analyze user sessions.

List Sessions

GET /api/v1/sessions

Request

curl "https://recall.brainzlab.ai/api/v1/sessions?since=24h" \
  -H "Authorization: Bearer sk_live_xxx"

Query Parameters

ParameterTypeDescription
sincestringTime range (e.g., 24h, 7d)
user_idstringFilter by user ID
limitintegerMax results (default: 50)
offsetintegerPagination offset

Response

{
  "data": [
    {
      "session_id": "sess_abc123",
      "user_id": "123",
      "started_at": "2024-01-15T10:00:00Z",
      "ended_at": "2024-01-15T10:30:00Z",
      "log_count": 45,
      "error_count": 2,
      "duration_seconds": 1800
    }
  ],
  "meta": {
    "total": 100,
    "limit": 50,
    "offset": 0
  }
}

Get Session Logs

GET /api/v1/sessions/:session_id/logs

Request

curl https://recall.brainzlab.ai/api/v1/sessions/sess_abc123/logs \
  -H "Authorization: Bearer sk_live_xxx"

Response

{
  "data": {
    "session": {
      "session_id": "sess_abc123",
      "user_id": "123",
      "started_at": "2024-01-15T10:00:00Z"
    },
    "logs": [
      {
        "id": "log_001",
        "level": "info",
        "message": "User logged in",
        "timestamp": "2024-01-15T10:00:00Z"
      },
      {
        "id": "log_002",
        "level": "info",
        "message": "Dashboard viewed",
        "timestamp": "2024-01-15T10:00:30Z"
      }
    ]
  }
}

Session Timeline

Get a timeline view:
GET /api/v1/sessions/:session_id/timeline

Response

{
  "data": {
    "session_id": "sess_abc123",
    "events": [
      {
        "timestamp": "2024-01-15T10:00:00Z",
        "type": "navigation",
        "data": { "path": "/dashboard" }
      },
      {
        "timestamp": "2024-01-15T10:00:30Z",
        "type": "action",
        "data": { "action": "clicked_button" }
      },
      {
        "timestamp": "2024-01-15T10:01:00Z",
        "type": "error",
        "data": { "message": "Payment failed" }
      }
    ]
  }
}

Session Stats

GET /api/v1/sessions/stats

Request

curl "https://recall.brainzlab.ai/api/v1/sessions/stats?since=7d" \
  -H "Authorization: Bearer sk_live_xxx"

Response

{
  "data": {
    "total_sessions": 5000,
    "unique_users": 1200,
    "avg_duration_seconds": 600,
    "avg_log_count": 25,
    "sessions_with_errors": 150,
    "error_rate": 0.03
  }
}