Deleting Pages and Directories#

Use delete() to move pages and directories into the notebook’s API Deleted Items folder. This is a safe delete workflow rather than a permanent erase.

How Deletion Works#

When you delete a page or directory:

  1. The item is renamed with a deletion timestamp.

  2. The item is moved to API Deleted Items under the notebook root.

This preserves the content so you can recover it later.

Delete a Page#

page = notebook.traverse("My Folder/Page to Delete")
page.delete()

After deletion, the page is renamed to something like:

Page to Delete - Deleted at 2024-01-15 14:30:22

Delete a Directory#

directory = notebook.traverse("Old Project")
directory.delete()

Warning

Deleting a directory moves all of its pages and subdirectories together. Confirm that you want to relocate the entire subtree before you call delete().

Recover Deleted Items#

To recover a deleted item, navigate to API Deleted Items and move it back:

from labapi import Index

deleted_items = notebook[Index.Name:"API Deleted Items"][0]
deleted_page = deleted_items["Page to Delete - Deleted at 2024-01-15 14:30:22"]

original_folder = notebook.traverse("My Folder")
deleted_page.move_to(original_folder)
deleted_page.name = "Page to Delete"

Entry Deletion#

Note

Individual entries such as text entries, attachments, and headers cannot be deleted through the API at this time.