# /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.
