Skip to contents

Handle all block operations in the Notion API

Note: Access this endpoint through the client instance, e.g., notion$blocks. Not to be instantiated directly.

Value

A list containing the parsed API response.

Public fields

children

Block children endpoint

Methods


Method new()

Initialise block endpoint. Not to be called directly, e.g., use notion$blocks instead.

Usage

BlocksEndpoint$new(client)

Arguments

client

Notion Client instance


Method retrieve()

Retrieve a block

Usage

BlocksEndpoint$retrieve(block_id)

Arguments

block_id

Character (required). The ID for a Notion block.


Method update()

Update a block

Usage

BlocksEndpoint$update(block_id, archived = FALSE, ...)

Arguments

block_id

Character (required). The ID for a Notion block.

archived

Boolean. Set to TRUE to archive (delete) a block. Set to FALSE to unarchive (restore) a block. Defaults to FALSE.

...

<dynamic-dots> Block-specific properties to update. Each argument should be named after a block type (e.g., heading_1, paragraph) with a named list value containing the block configuration.


Method delete()

Delete a block

Usage

BlocksEndpoint$delete(block_id)

Arguments

block_id

Character (required). The ID for a Notion block.

Examples

notion <- notion_client()

# ----- retrieve a block
notion$blocks$retrieve("23933ea0-c1e4-81dc-9f56-f3fa251a757f")
#> {
#>   "object": "block",
#>   "id": "23933ea0-c1e4-81dc-9f56-f3fa251a757f",
#>   "parent": {
#>     "type": "page_id",
#>     "page_id": "23933ea0-c1e4-81d6-a6f6-dd5b57ad4aba"
#>   },
#>   "created_time": "2025-07-23T05:00:00.000Z",
#>   "last_edited_time": "2025-07-23T05:00:00.000Z",
#>   "created_by": {
#>     "object": "user",
#>     "id": "6b786605-e456-4237-9c61-5efaff23c081"
#>   },
#>   "last_edited_by": {
#>     "object": "user",
#>     "id": "6b786605-e456-4237-9c61-5efaff23c081"
#>   },
#>   "has_children": false,
#>   "archived": false,
#>   "in_trash": false,
#>   "type": "heading_2",
#>   "heading_2": {
#>     "rich_text": [
#>       {
#>         "type": "text",
#>         "text": {
#>           "content": "Test Heading",
#>           "link": {}
#>         },
#>         "annotations": {
#>           "bold": false,
#>           "italic": false,
#>           "strikethrough": false,
#>           "underline": false,
#>           "code": false,
#>           "color": "default"
#>         },
#>         "plain_text": "Test Heading",
#>         "href": {}
#>       }
#>     ],
#>     "is_toggleable": false,
#>     "color": "default"
#>   },
#>   "request_id": "96790a47-fce1-4aac-ad55-b9d41d6cedd0"
#> } 

# ----- update a block
notion$blocks$update(
  "23933ea0-c1e4-81dc-9f56-f3fa251a757f",
  heading_2 = list(
    rich_text = list(
      list(
        text = list(
          content = "Updated Test Heading"
        )
      )
    )
  )
)
#> {
#>   "object": "block",
#>   "id": "23933ea0-c1e4-81dc-9f56-f3fa251a757f",
#>   "parent": {
#>     "type": "page_id",
#>     "page_id": "23933ea0-c1e4-81d6-a6f6-dd5b57ad4aba"
#>   },
#>   "created_time": "2025-07-23T05:00:00.000Z",
#>   "last_edited_time": "2025-07-23T05:00:00.000Z",
#>   "created_by": {
#>     "object": "user",
#>     "id": "6b786605-e456-4237-9c61-5efaff23c081"
#>   },
#>   "last_edited_by": {
#>     "object": "user",
#>     "id": "6b786605-e456-4237-9c61-5efaff23c081"
#>   },
#>   "has_children": false,
#>   "archived": false,
#>   "in_trash": false,
#>   "type": "heading_2",
#>   "heading_2": {
#>     "rich_text": [
#>       {
#>         "type": "text",
#>         "text": {
#>           "content": "Updated Test Heading",
#>           "link": {}
#>         },
#>         "annotations": {
#>           "bold": false,
#>           "italic": false,
#>           "strikethrough": false,
#>           "underline": false,
#>           "code": false,
#>           "color": "default"
#>         },
#>         "plain_text": "Updated Test Heading",
#>         "href": {}
#>       }
#>     ],
#>     "is_toggleable": false,
#>     "color": "default"
#>   },
#>   "request_id": "648d96cd-0c96-455e-b2e1-7a35eb889dd4"
#> } 

# ----- delete a block
notion$blocks$delete(block_id = "23933ea0-c1e4-81d6-a6f6-dd5b57ad4aba")
#> {
#>   "object": "block",
#>   "id": "23933ea0-c1e4-81d6-a6f6-dd5b57ad4aba",
#>   "parent": {
#>     "type": "page_id",
#>     "page_id": "22f33ea0-c1e4-80b9-9c77-d1ab72aedff9"
#>   },
#>   "created_time": "2025-07-23T05:00:00.000Z",
#>   "last_edited_time": "2025-07-23T05:01:00.000Z",
#>   "created_by": {
#>     "object": "user",
#>     "id": "6b786605-e456-4237-9c61-5efaff23c081"
#>   },
#>   "last_edited_by": {
#>     "object": "user",
#>     "id": "6b786605-e456-4237-9c61-5efaff23c081"
#>   },
#>   "has_children": true,
#>   "archived": true,
#>   "in_trash": true,
#>   "type": "child_page",
#>   "child_page": {
#>     "title": "Test Page for notionapi"
#>   },
#>   "request_id": "3371d06e-15fc-4e7c-b238-baea10ee7926"
#> }