Skip to content

Overview

Sessions represent a unit of work in Contox. Events from the MCP server, CLI, and VS Code extension are grouped into sessions. Each session can be enriched to extract structured memory items from the raw event data.

List sessions

Retrieves all sessions for a project.

GET /api/v2/sessions

Query parameters

ParameterTypeDescription
projectIdstringFilter by project ID
statusstringFilter by status (active, completed, enriching, failed)

Response

json
[
  {
    "id": "sess_abc123",
    "projectId": "proj_xyz789",
    "status": "completed",
    "eventCount": 12,
    "createdAt": "2025-01-20T10:00:00Z",
    "completedAt": "2025-01-20T12:30:00Z"
  }
]

Create session

Manually creates a new session. Typically sessions are created automatically when events are ingested.

POST /api/v2/sessions

Request body

FieldTypeRequiredDescription
projectIdstringYesThe project ID

Get session

Retrieves a single session with full details.

GET /api/v2/sessions/[id]

Response

json
{
  "id": "sess_abc123",
  "projectId": "proj_xyz789",
  "status": "completed",
  "eventCount": 12,
  "itemsExtracted": 8,
  "enrichmentModel": "medium",
  "createdAt": "2025-01-20T10:00:00Z",
  "completedAt": "2025-01-20T12:30:00Z"
}

Update session

Updates session properties.

PATCH /api/v2/sessions/[id]

Request body

FieldTypeRequiredDescription
statusstringNoNew status

Trigger enrichment

Starts the AI enrichment pipeline for a session. This is the "Generate Memory" action in the dashboard.

POST /api/v2/sessions/[id]/enrich

The enrichment pipeline processes the session's events through multiple stages:

  1. Enrich -- AI extracts memory items from event chunks
  2. Embed -- Items are embedded for semantic search
  3. Dedup -- Duplicate items are detected and merged
  4. Drift check -- Existing items are checked for consistency

Response

json
{
  "jobId": "job_abc123",
  "status": "queued",
  "pipeline": ["enrich", "embed", "dedup", "drift_check"]
}

AI model selection

The AI model used for enrichment depends on your plan:

PlanModel
Free / PersonalSmall (faster, lower cost)
Team / Business / EnterpriseMedium (more accurate, higher cost)

Retry failed enrichment

Retries a failed enrichment job for a session.

POST /api/v2/sessions/[id]/retry

Response

json
{
  "jobId": "job_def456",
  "status": "queued",
  "retriedFrom": "job_abc123"
}

Use this when enrichment fails due to transient errors. The pipeline restarts from the failed stage.

List session events

Retrieves all raw events associated with a session.

GET /api/v2/sessions/[id]/events

Response

json
[
  {
    "id": "evt_abc123",
    "event": "session_save",
    "payload": {
      "summary": "Implemented auth middleware",
      "changes": [...]
    },
    "createdAt": "2025-01-20T10:15:00Z"
  }
]

List session jobs

Retrieves the enrichment jobs for a session, showing pipeline progress.

GET /api/v2/sessions/[id]/jobs

Response

json
[
  {
    "id": "job_abc123",
    "status": "completed",
    "pipeline": [
      { "stage": "enrich", "status": "completed", "duration": 4500 },
      { "stage": "embed", "status": "completed", "duration": 1200 },
      { "stage": "dedup", "status": "completed", "duration": 800 },
      { "stage": "drift_check", "status": "completed", "duration": 600 }
    ],
    "itemsExtracted": 8,
    "createdAt": "2025-01-20T12:00:00Z",
    "completedAt": "2025-01-20T12:02:00Z"
  }
]

Pipeline stages

StageDescription
enrichAI processes event chunks and extracts memory items
embedGenerates embeddings for semantic search
dedupDetects and merges duplicate items
drift_checkValidates consistency with existing brain

Next steps