# /Root

## Overview

The `/root` endpoint retrieves all the events in a thread, starting from the root event all the way down to the event whose id is provided. This is useful for tracing the ancestry of a reply in a conversation thread.

## Endpoint Details

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

## Request Parameters

| Parameter | Description                                         | Required |
| --------- | --------------------------------------------------- | -------- |
| `id`      | The ID of the post to trace back to its root event. | Yes      |

## Response Schema

The response is a JSON object with the following structure:

```json
{
  "id": "requested_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"
    }
  }
}
```

* `id`: The event ID of the requested post.
* `events`: An array of events, starting from the root event and ending with the requested event.
* `profiles`: A map of author profiles for all events in the response, keyed by pubkey.

## Example Call

```bash
curl -X GET "https://huddlers-ovduv.ondigitalocean.app/root?id=11d37558b861b0d42872777ea8dda6c2d9ab88d370e05867ef2c880ade2e7200"
```

## Notes

* The events are returned in the correct order, with the root event first and the requested event last.
* If the requested event is already a root event, only that event will be returned.
* The endpoint uses the new NIP-10 spec--it maps the reply chain using the `root` and `reply` markers in `e` tags.

## Error Responses

* **400 Bad Request**: If the event ID is missing or invalid.
* **404 Not Found**: If the requested event or its root 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/root.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.
