> 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/collections/collection.md).

# Collection

A Collection is an extension type that registers under a unique alias and uses a **Collection Repository** to fetch items. **Collection Views** bind themselves to the collection via that alias to display the items.

## Manifest

Register a collection using the `collection` extension type. The `repositoryAlias` in `meta` must match the alias of a registered Collection Repository.

{% code title="umbraco-package.json" %}

```json
{
  "type": "collection",
  "kind": "default",
  "alias": "My.Collection",
  "name": "My Collection",
  "meta": {
    "repositoryAlias": "My.Collection.Repository"
  }
}
```

{% endcode %}

## Collection Repository

A Collection Repository fetches and returns the items displayed in the collection. It must implement the `UmbCollectionRepository` interface, which requires a single `requestCollection` method.

### Manifest

Register the repository as a separate extension. The `api` property points to the file that exports the repository class:

{% code title="umbraco-package.json" %}

```json
{
  "type": "repository",
  "alias": "My.Collection.Repository",
  "name": "My Collection Repository",
  "api": "/App_Plugins/my-collection/my-collection.repository.js"
}
```

{% endcode %}

### Item model

Define the shape of the items your repository returns by extending `UmbCollectionItemModel`. The property names you add here are what Collection Views use when rendering the items.

The base Collection Item Model that all items must satisfy is:

```typescript
export interface UmbCollectionItemModel {
  unique: string;
  entityType: string;
  name?: string;
  icon?: string;
}
```

{% code title="types.ts" %}

```typescript
import type { UmbCollectionItemModel } from '@umbraco-cms/backoffice/collection';

export interface MyCollectionItemModel extends UmbCollectionItemModel {
  status: string;
  creator: string;
}
```

{% endcode %}

### Implementation

Extend `UmbRepositoryBase` and implement `UmbCollectionRepository`. The `requestCollection` method receives a filter object with `skip` and `take` for pagination, and must return `{ data: { items, total } }`. For guidance on making HTTP requests to a server API, see [Fetching Data](/umbraco-cms/extend-your-project/backoffice-extensions/foundation/fetching-data.md):

{% code title="my-collection.repository.ts" %}

```typescript
import type { MyCollectionItemModel } from './types.js';
import { UmbRepositoryBase } from '@umbraco-cms/backoffice/repository';
import type { UmbCollectionRepository, UmbCollectionFilterModel } from '@umbraco-cms/backoffice/collection';

export class MyCollectionRepository
  extends UmbRepositoryBase
  implements UmbCollectionRepository<MyCollectionItemModel>
{
  async requestCollection(filter: UmbCollectionFilterModel) {
    const skip = filter.skip ?? 0;
    const take = filter.take ?? 10;

    // Replace this with a real API call.
    const allItems: MyCollectionItemModel[] = [
      {
        unique: 'b3e31e9c-7d66-4c99-a9e5-d9f2b1e2b22f',
        entityType: 'my-entity',
        name: 'Item One',
        status: 'Published',
        creator: 'Admin',
      },
      {
        unique: 'ac9b6e24-4b11-4dd6-8d4e-7c4f70e59f3c',
        entityType: 'my-entity',
        name: 'Item Two',
        status: 'Draft',
        creator: 'Editor',
      },
    ];

    const items = allItems.slice(skip, skip + take);

    return {
      data: {
        items,
        total: allItems.length,
      },
    };
  }
}

export { MyCollectionRepository as api };
```

{% endcode %}

The exported `api` alias lets the extension registry instantiate the class when the collection loads.

## Next steps

With a collection and repository registered, add a [Collection View](/umbraco-cms/extend-your-project/backoffice-extensions/extending-overview/extension-types/collections/collection-view.md) to control how the items are displayed.


---

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