> ## 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 Thread Messages

> Retrieve all messages from a conversation thread

## Overview

Get all messages from a specific conversation thread. Messages are fetched from the database and automatically enriched with full content LLM for assistant responses.

## Path Parameters

<ParamField path="threadId" type="string" required>
  Thread identifier (UUID)
</ParamField>

## Response

<ResponseField name="data" type="array">
  Array of messages in chronological order (oldest first)

  <Expandable title="message object">
    <ResponseField name="id" type="string">
      Message identifier
    </ResponseField>

    <ResponseField name="thread_id" type="string">
      Thread identifier
    </ResponseField>

    <ResponseField name="content" type="string">
      Message content (automatically fetched LLM for assistant messages)
    </ResponseField>

    <ResponseField name="role" type="string">
      Sender role: `user` or `assistant`
    </ResponseField>

    <ResponseField name="response_id" type="string">
      LLM response ID (for assistant messages)
    </ResponseField>

    <ResponseField name="created_at" type="string">
      Message creation timestamp (ISO 8601)
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="count" type="number">
  Total number of messages in the thread
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET https://api.myweave.ai/functions/v1/threads/550e8400-e29b-41d4-a716-446655440000/messages \
    -H "X-API-Key: your-api-key-here"
  ```

  ```javascript JavaScript theme={null}
  const threadId = '550e8400-e29b-41d4-a716-446655440000';
  const response = await fetch(
    `https://api.myweave.ai/functions/v1/threads/${threadId}/messages`,
    {
      method: 'GET',
      headers: {
        'X-API-Key': 'your-api-key-here'
      }
    }
  );

  const { data, count } = await response.json();
  console.log(`Retrieved ${count} messages`);
  data.forEach(msg => {
    console.log(`[${msg.role}]: ${msg.content}`);
  });
  ```

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

  thread_id = '550e8400-e29b-41d4-a716-446655440000'
  url = f"https://api.myweave.ai/functions/v1/threads/{thread_id}/messages"
  headers = {"X-API-Key": "your-api-key-here"}

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

  print(f"Retrieved {result['count']} messages")
  for message in result['data']:
      print(f"[{message['role']}]: {message['content']}")
  ```
</RequestExample>

<ResponseExample>
  ```json 200 Success theme={null}
  {
    "data": [
      {
        "id": "b8f3e1c0-1234-5678-9abc-def012345678",
        "thread_id": "550e8400-e29b-41d4-a716-446655440000",
        "content": "Hello, I need help with leadership development",
        "role": "user",
        "response_id": null,
        "created_at": "2024-01-15T10:30:00Z"
      },
      {
        "id": "c9f4e2d1-2345-6789-abcd-ef0123456789",
        "thread_id": "550e8400-e29b-41d4-a716-446655440000",
        "content": "I'd be happy to help you with leadership development. Let's start by understanding your current goals and challenges in your leadership role...",
        "role": "assistant",
        "response_id": "resp_abc123xyz",
        "created_at": "2024-01-15T10:30:15Z"
      }
    ],
    "count": 2
  }
  ```

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

  ```json 404 Not Found theme={null}
  {
    "error": "Thread not found"
  }
  ```

  ```json 500 Server Error theme={null}
  {
    "error": "Failed to fetch messages"
  }
  ```
</ResponseExample>

## Features

* **Automatic Content Enrichment**: Assistant messages are automatically fetched LLM with full content
* **Chronological Order**: Messages returned in order from oldest to newest
* **Database-backed**: Fast retrieval from database with LLM enrichment
* **Complete History**: All user and assistant messages in the conversation

## Use Cases

* **Display Conversation**: Show full chat history to users
* **Context Retrieval**: Get conversation context for analysis
* **Message Export**: Export conversation for records
* **UI Rendering**: Populate chat interface with history

## Notes

* Messages are ordered by `created_at` in **ascending order** (oldest first)
* Assistant messages with `response_id` are enriched with full content LLM
* Thread must exist in the database to retrieve messages
* Only returns `user` and `assistant` role messages (no system messages)
