Move a page to the trash, or restore it from the trash.
1
//native
2
3
/**
4
* Move Page to Trash or Restore
5
* Move a page to the trash (`in_trash` true), or restore it from the trash (`in_trash` false). Trashed pages can be restored until Notion empties the trash.
6
*/
7
export async function main(
8
auth: RT.Notion,
9
page_id: string,
10
in_trash: boolean = true
11
) {
12
const response = await fetch(`https://api.notion.com/v1/pages/${page_id}`, {
13
method: "PATCH",
14
headers: {
15
Authorization: `Bearer ${auth.token}`,
16
"Content-Type": "application/json",
17
Accept: "application/json",
18
"Notion-Version": "2026-03-11",
19
},
20
body: JSON.stringify({ in_trash }),
21
})
22
23
if (!response.ok) {
24
throw new Error(`${response.status} ${await response.text()}`)
25
}
26
27
return await response.json()
28
29