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

# Get User Threads

> Retrieve all conversation threads for a specific user

## Overview

Get all conversation threads for a user. Returns thread metadata including coach information, ordered by most recently updated.

## Path Parameters

<ParamField path="userId" type="string" required>
  User identifier
</ParamField>

## Query Parameters

<ParamField query="coachId" type="string">
  Optional filter to get threads with a specific coach only
</ParamField>

## Response

<ResponseField name="data" type="array">
  Array of thread objects

  <Expandable title="thread object">
    <ResponseField name="id" type="string">
      Thread identifier (UUID)
    </ResponseField>

    <ResponseField name="title" type="string">
      Thread title
    </ResponseField>

    <ResponseField name="created_at" type="string">
      When the thread was created (ISO 8601)
    </ResponseField>

    <ResponseField name="updated_at" type="string">
      When the thread was last updated (ISO 8601)
    </ResponseField>

    <ResponseField name="coach_id" type="string">
      Coach/expert identifier
    </ResponseField>

    <ResponseField name="user_id" type="string">
      User identifier
    </ResponseField>

    <ResponseField name="coach_profiles" type="object">
      Coach information

      <Expandable title="properties">
        <ResponseField name="name" type="string">
          Coach full name
        </ResponseField>

        <ResponseField name="title" type="string">
          Coach professional title
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="count" type="number">
  Total number of threads returned
</ResponseField>

<RequestExample>
  ```bash cURL - All Threads theme={null}
  curl -X GET https://api.myweave.ai/functions/v1/users/user_abc123/threads \
    -H "X-API-Key: your-api-key-here"
  ```

  ```bash cURL - Filter by Coach theme={null}
  curl -X GET "https://api.myweave.ai/functions/v1/users/user_abc123/threads?coachId=coach_xyz789" \
    -H "X-API-Key: your-api-key-here"
  ```

  ```javascript JavaScript theme={null}
  const userId = 'user_abc123';
  const response = await fetch(
    `https://api.myweave.ai/functions/v1/users/${userId}/threads`,
    {
      method: 'GET',
      headers: {
        'X-API-Key': 'your-api-key-here'
      }
    }
  );

  const { data, count } = await response.json();
  console.log(`Found ${count} threads`);
  data.forEach(thread => {
    console.log(`- ${thread.title} with ${thread.coach_profiles.name}`);
  });
  ```

  ```javascript Filter by Coach theme={null}
  const userId = 'user_abc123';
  const coachId = 'coach_xyz789';
  const response = await fetch(
    `https://api.myweave.ai/functions/v1/users/${userId}/threads?coachId=${coachId}`,
    {
      method: 'GET',
      headers: {
        'X-API-Key': 'your-api-key-here'
      }
    }
  );

  const { data } = await response.json();
  ```

  ```python Python theme={null}
  import requests

  user_id = 'user_abc123'
  url = f"https://api.myweave.ai/functions/v1/users/{user_id}/threads"
  headers = {"X-API-Key": "your-api-key-here"}

  response = requests.get(url, headers=headers)
  result = response.json()

  print(f"Found {result['count']} threads")
  for thread in result['data']:
      print(f"- {thread['title']} with {thread['coach_profiles']['name']}")
  ```

  ```python Filter by Coach theme={null}
  import requests

  user_id = 'user_abc123'
  coach_id = 'coach_xyz789'
  url = f"https://api.myweave.ai/functions/v1/users/{user_id}/threads"
  headers = {"X-API-Key": "your-api-key-here"}
  params = {"coachId": coach_id}

  response = requests.get(url, headers=headers, params=params)
  threads = response.json()['data']
  ```
</RequestExample>

<ResponseExample>
  ```json 200 Success theme={null}
  {
    "data": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "title": "Leadership Development Session",
        "created_at": "2024-01-15T10:30:00Z",
        "updated_at": "2024-01-16T14:20:00Z",
        "coach_id": "coach_xyz789",
        "user_id": "user_abc123",
        "coach_profiles": {
          "name": "Dr. Sarah Johnson",
          "title": "Executive Leadership Coach"
        }
      },
      {
        "id": "660e8400-e29b-41d4-a716-446655440001",
        "title": "Career Planning Discussion",
        "created_at": "2024-01-10T09:15:00Z",
        "updated_at": "2024-01-12T16:45:00Z",
        "coach_id": "coach_abc456",
        "user_id": "user_abc123",
        "coach_profiles": {
          "name": "Michael Chen",
          "title": "Career Development Coach"
        }
      }
    ],
    "count": 2
  }
  ```

  ```json 400 Bad Request theme={null}
  {
    "error": "userId is required in path"
  }
  ```

  ```json 500 Server Error theme={null}
  {
    "error": "Failed to fetch threads",
    "details": "Database connection error"
  }
  ```
</ResponseExample>

## Use Cases

* **User Dashboard**: Display all conversations for a user
* **Coach Filter**: Show threads with a specific coach
* **Conversation History**: List all past consultations
* **Thread Management**: Get thread IDs for continuing conversations

## Response Details

* Threads are ordered by `updated_at` in **descending order** (most recent first)
* Includes coach profile information via join
* Returns empty array if no threads found
* Coach filter is optional - omit to get all threads
