# /Thread

## Overview

The `/thread` endpoint retrieves a reply thread that starts from a specified event. It returns an array of events, along with the profiles of the authors involved.

## Endpoint Details

* **URL**: `/thread`
* **Method**: GET
* **Auth Required**: No
* **Permissions Required**: None

## Request Parameters

| Parameter | Description                                                            | Required |
| --------- | ---------------------------------------------------------------------- | -------- |
| `id`      | The ID of the event whose replies are requested in hexadecimal format. | Yes      |
| `depth`   | The maximum depth of replies to fetch.                                 | No       |
| `limit`   | The maximum number of events to return.                                | No       |

## Response Schema

The response is a JSON object with the following structure:

```json
{
  "id": "root_event_id",
  "events": [
    {
      "id": "event_id",
      "pubkey": "author_pubkey",
      "created_at": 1234567890,
      "kind": 1,
      "tags": [],
      "content": "Event content",
      "sig": "event_signature"
    }
  ],
  "profiles": {
    "author_pubkey": {
      "id": "profile_event_id",
      "pubkey": "author_pubkey",
      "created_at": 1234567890,
      "kind": 0,
      "tags": [],
      "content": "Profile content",
      "sig": "profile_signature"
    }
  },
  "depth": 3
}
```

* `id`: The ID of the event whose comment thread is being retrieved.
* `events`: An array of events in the thread, including the original event.
* `profiles`: A map of author profiles, keyed by pubkey.
* `depth`: The actual depth reached in the thread.

## Example Call

```bash
curl -X GET "https://huddlers-ovduv.ondigitalocean.app/thread?id=5c3e529bb75f165d822b468114e3bc928288ae5679e38849452e0389124a333b&depth=3&limit=5"
```

## Notes

* If `depth` is not provided, it defaults to 2.
* Once the server collects as many events as are allowed by the `limit` constraint, it returns that set even though it may not have reached the maximum allowed `depth`. Similarly, once all replies up to the specified `depth` have been collected, the set is returned even if the `limit` has not been reached.

## Error Responses

* **400 Bad Request**: If the root event ID is missing or invalid.
* **404 Not Found**: If the root event cannot be found.
* **500 Internal Server Error**: If there's an issue processing the request.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.huddlers.dev/thread.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
