> For the complete documentation index, see [llms.txt](https://docs.umbraco.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.umbraco.com/umbraco-cms/extend-your-project/backoffice-extensions/extending-overview/extension-types/tree/tree-repository.md).

# Tree Repository

A Tree Repository provides data to populate your Tree. It implements methods to return the root, root items, children of items, and ancestors.

The repository is referenced by your Tree Manifest via `meta.repositoryAlias`.

## Interface

The `UmbTreeRepository` interface defines the methods your repository must implement:

```typescript
interface UmbTreeRepository {
  requestTreeRoot();
  requestTreeRootItems();
  requestTreeItemsOf();
  requestTreeItemAncestors();
}
```

See the full interface in the [UI API Documentation](https://apidocs.umbraco.com/v18/ui-api/interfaces/packages_core_tree.UmbTreeRepository.html).

## Registering the Repository

Register the Repository in your Manifest:

```typescript
{
  type: 'repository',
  alias: 'My.Tree.Repository',
  name: 'My Tree Repository',
  api: () => import('./my-tree.repository.js'),
}
```

## Implementing a Tree Repository

Extend `UmbControllerBase` and implement the `UmbTreeRepository` interface.

### Static Data Example

{% code title="static-tree.repository.ts" %}

```typescript
import { UmbControllerBase } from "@umbraco-cms/backoffice/class-api";
import type { UmbApi } from "@umbraco-cms/backoffice/extension-api";
import type { UmbTreeRepository } from "@umbraco-cms/backoffice/tree";

const staticItems = [
  {
    unique: "1",
    entityType: "my-item",
    parent: { unique: null, entityType: "my-root" },
    name: "First Item",
    hasChildren: false,
    isFolder: false,
    icon: "icon-document",
  },
  {
    unique: "2",
    entityType: "my-item",
    parent: { unique: null, entityType: "my-root" },
    name: "Second Item",
    hasChildren: false,
    isFolder: false,
    icon: "icon-document",
  },
];

export class MyStaticTreeRepository
  extends UmbControllerBase
  implements UmbTreeRepository, UmbApi
{
  async requestTreeRoot() {
    return {
      data: {
        unique: null,
        entityType: "my-root",
        name: "My Static Tree",
        hasChildren: true,
        isFolder: true,
        icon: "icon-folder",
      },
    };
  }

  async requestTreeRootItems() {
    const items = staticItems.filter((item) => item.parent.unique === null);
    return { data: { items, total: items.length } };
  }

  async requestTreeItemsOf(args) {
    const items = staticItems.filter(
      (item) => item.parent.unique === args.parent.unique
    );
    return { data: { items, total: items.length } };
  }

  async requestTreeItemAncestors() {
    // Implement as needed
    return { data: [] };
  }
}

export { MyStaticTreeRepository as api };
```

{% endcode %}

## Related

* [Tree Models](/umbraco-cms/extend-your-project/backoffice-extensions/extending-overview/extension-types/tree/tree-models.md) - `UmbTreeItemModel` and `UmbTreeRootModel` interfaces.
* [Trees & Workspaces](/umbraco-cms/extend-your-project/backoffice-extensions/extending-overview/extension-types/tree/trees-and-workspaces.md) - How Tree clicks navigate to Workspaces.
* [Trees](/umbraco-cms/extend-your-project/backoffice-extensions/extending-overview/extension-types/tree.md) - Main Tree extension documentation.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.umbraco.com/umbraco-cms/extend-your-project/backoffice-extensions/extending-overview/extension-types/tree/tree-repository.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
