0

Delete Block

by
Published today

Move a block, or a page by its ID, to the trash.

Script notion Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 3 hours ago
1
//native
2

3
/**
4
 * Delete Block
5
 * Move a block to the trash, with its children. A page ID also works. Restore it with Update Block content {"in_trash": false}, or a page with Move Page to Trash or Restore.
6
 */
7
export async function main(auth: RT.Notion, block_id: string) {
8
  const response = await fetch(`https://api.notion.com/v1/blocks/${block_id}`, {
9
    method: "DELETE",
10
    headers: {
11
      Authorization: `Bearer ${auth.token}`,
12
      Accept: "application/json",
13
      "Notion-Version": "2026-03-11",
14
    },
15
  })
16

17
  if (!response.ok) {
18
    throw new Error(`${response.status} ${await response.text()}`)
19
  }
20

21
  return await response.json()
22
}
23