> ## Documentation Index
> Fetch the complete documentation index at: https://wuweism.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sessions

> List all sessions for the authenticated user and retrieve the messages within a session.

Two endpoints manage causal chat sessions: one to list all sessions associated with your account, and one to retrieve the full message history for a specific session.

## List sessions

```
GET /api/causal-chat/sessions
```

Returns all sessions belonging to the authenticated user, ordered by most recently updated.

### Authentication

Required. Include a session cookie or `Authorization: Bearer <token>` header.

### Response

**Status:** `200 OK`\
**Content-Type:** `application/json`

<ResponseField name="sessions" type="object[]" required>
  Array of session summary objects.

  <Expandable title="session properties" defaultOpen={true}>
    <ResponseField name="id" type="string" required>
      UUID uniquely identifying the session. Use this value as `sessionId` when sending messages or fetching session messages.
    </ResponseField>

    <ResponseField name="title" type="string" required>
      Human-readable title derived from the first question in the session.
    </ResponseField>

    <ResponseField name="updated_at" type="string" required>
      ISO 8601 timestamp of the most recent activity in the session.
    </ResponseField>

    <ResponseField name="domain_classified" type="string" required>
      Primary domain label assigned during the session's first causal analysis, e.g. `"neuroscience"`. May be `null` if classification has not yet completed.
    </ResponseField>
  </Expandable>
</ResponseField>

### Example

<CodeGroup>
  ```bash cURL theme={null}
  curl --request GET \
    --url https://wuweism.com/api/causal-chat/sessions \
    --header 'Authorization: Bearer <token>'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://wuweism.com/api/causal-chat/sessions', {
    headers: {
      'Authorization': 'Bearer <token>',
    },
  });
  const { sessions } = await response.json();
  ```
</CodeGroup>

```json 200 theme={null}
{
  "sessions": [
    {
      "id": "3f2504e0-4f89-11d3-9a0c-0305e82c3301",
      "title": "Does cortisol exposure causally increase hippocampal volume reduction?",
      "updated_at": "2026-04-05T14:32:00Z",
      "domain_classified": "neuroscience"
    },
    {
      "id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
      "title": "What is the causal effect of sleep deprivation on reaction time?",
      "updated_at": "2026-04-04T09:15:00Z",
      "domain_classified": "cognitive_science"
    }
  ]
}
```

***

## Get session messages

```
GET /api/causal-chat/sessions/{sessionId}
```

Returns the full ordered message history for a specific session.

### Authentication

Required. Include a session cookie or `Authorization: Bearer <token>` header.

### Path parameters

<ParamField path="sessionId" type="string" required>
  UUID of the session to retrieve. Obtain this from the `id` field in the [list sessions](#list-sessions) response.
</ParamField>

### Response

**Status:** `200 OK`\
**Content-Type:** `application/json`

<ResponseField name="messages" type="object[]" required>
  Chronologically ordered array of messages in the session.

  <Expandable title="message properties" defaultOpen={true}>
    <ResponseField name="id" type="string" required>
      UUID uniquely identifying this message.
    </ResponseField>

    <ResponseField name="role" type="string" required>
      Speaker role: `"user"` or `"assistant"`.
    </ResponseField>

    <ResponseField name="content" type="string" required>
      Full text content of the message.
    </ResponseField>

    <ResponseField name="created_at" type="string" required>
      ISO 8601 timestamp when the message was created.
    </ResponseField>

    <ResponseField name="causal_graph" type="object">
      Causal graph snapshot attached to this message, if any. Present on `"assistant"` messages that include a rendered SCM. The structure mirrors the tier-1/tier-2 schema returned in the `scm_loaded` SSE event. May be `null`.
    </ResponseField>
  </Expandable>
</ResponseField>

### Example

<CodeGroup>
  ```bash cURL theme={null}
  curl --request GET \
    --url https://wuweism.com/api/causal-chat/sessions/3f2504e0-4f89-11d3-9a0c-0305e82c3301 \
    --header 'Authorization: Bearer <token>'
  ```

  ```javascript JavaScript theme={null}
  const sessionId = '3f2504e0-4f89-11d3-9a0c-0305e82c3301';
  const response = await fetch(
    `https://wuweism.com/api/causal-chat/sessions/${sessionId}`,
    {
      headers: {
        'Authorization': 'Bearer <token>',
      },
    }
  );
  const { messages } = await response.json();
  ```
</CodeGroup>

```json 200 theme={null}
{
  "messages": [
    {
      "id": "a1b2c3d4-0000-0000-0000-000000000001",
      "role": "user",
      "content": "Does cortisol exposure causally increase hippocampal volume reduction?",
      "created_at": "2026-04-05T14:31:45Z",
      "causal_graph": null
    },
    {
      "id": "a1b2c3d4-0000-0000-0000-000000000002",
      "role": "assistant",
      "content": "Yes. The causal pathway from elevated cortisol to hippocampal volume reduction is well-supported by the loaded SCM...",
      "created_at": "2026-04-05T14:32:00Z",
      "causal_graph": {
        "modelKey": "neuroscience_hpa_axis",
        "version": "2.1.0",
        "tier1": {},
        "tier2": {}
      }
    }
  ]
}
```

## Error responses

| Status | Description                                                             |
| ------ | ----------------------------------------------------------------------- |
| `401`  | Missing or invalid authentication credentials.                          |
| `404`  | No session found with the given `sessionId` for the authenticated user. |
