Edits history of script submission #23129 for ' Delete Block (notion)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * Delete Block
     * 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.
     */
    export async function main(auth: RT.Notion, block_id: string) {
      const response = await fetch(`https://api.notion.com/v1/blocks/${block_id}`, {
        method: "DELETE",
        headers: {
          Authorization: `Bearer ${auth.token}`,
          Accept: "application/json",
          "Notion-Version": "2026-03-11",
        },
      })
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 4 hours ago