# Bookmark API

[`BookmarkService`](https://doc.ibexa.co/en/latest/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-BookmarkService.html) enables you to read, add and remove bookmarks from content.

Bookmark REST API

To learn how to manage bookmarks using the REST API, see [REST API reference](https://doc.ibexa.co/en/latest/api/rest_api/rest_api_reference/rest_api_reference.html#tag/Bookmark).

To view a list of all bookmarks, use [`BookmarkService::loadBookmarks`](https://doc.ibexa.co/en/latest/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-BookmarkService.html#method_loadBookmarks):

```
        $bookmarkList = $this->bookmarkService->loadBookmarks();

        $output->writeln('Total bookmarks: ' . $bookmarkList->totalCount);

        foreach ($bookmarkList->items as $bookmark) {
            $output->writeln($bookmark->getContentInfo()->name);
        }
```

You can add a bookmark to a content item by providing its Location object to the [`BookmarkService::createBookmark`](https://doc.ibexa.co/en/latest/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-BookmarkService.html#method_createBookmark) method:

```
        $location = $this->locationService->loadLocation($locationId);

        $this->bookmarkService->createBookmark($location);
```

You can remove a bookmark from a location with [`BookmarkService::deleteBookmark`](https://doc.ibexa.co/en/latest/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-BookmarkService.html#method_deleteBookmark):

```
            $this->bookmarkService->deleteBookmark($location);
```
