Skip to contents

Handle all comments operations in the Notion API

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

Value

A list containing the parsed API response.

Methods


Method new()

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

Usage

CommentsEndpoint$new(client)

Arguments

client

Notion Client instance


Method create()

Create a comment

Usage

CommentsEndpoint$create(
  parent = NULL,
  discussion_id = NULL,
  rich_text,
  attachments = NULL,
  display_name = NULL
)

Arguments

parent

List (JSON object). The parent page where comment is created. Required if discussion_id is not provided

discussion_id

Character. The ID of the discussion thread for the comment. Required if parent is not provided.

rich_text

List of lists (JSON array) (required). Rich text object(s) representing the comment content.

attachments

List of lists (JSON array). Attachments to include in the comment.

display_name

Named list (JSON object). Custom display name of the comment.


Method retrieve()

Retrieve comments for a block

Usage

CommentsEndpoint$retrieve(block_id, start_cursor = NULL, page_size = NULL)

Arguments

block_id

Character. The ID for a Notion block.

start_cursor

Character. For pagination. If provided, returns results starting from this cursor. If NULL, returns the first page of results.

page_size

Integer. Number of items to return per page (1-100). Defaults to 100.

Examples

notion <- notion_client()

# ----- create comment
notion$comments$create(
  list(page_id = "23933ea0-c1e4-81d6-a6f6-dd5b57ad4aba"),
  rich_text = list(list(
    text = list(
      content = "Hello world"
    )
  ))
)
#> {
#>   "object": "comment",
#>   "id": "23933ea0-c1e4-8180-a10e-001d4fcf0d39",
#>   "parent": {
#>     "type": "page_id",
#>     "page_id": "23933ea0-c1e4-81d6-a6f6-dd5b57ad4aba"
#>   },
#>   "discussion_id": "23933ea0-c1e4-81ea-a476-001c4f062db0",
#>   "created_time": "2025-07-23T05:01:00.000Z",
#>   "last_edited_time": "2025-07-23T05:01:00.000Z",
#>   "created_by": {
#>     "object": "user",
#>     "id": "6b786605-e456-4237-9c61-5efaff23c081"
#>   },
#>   "rich_text": [
#>     {
#>       "type": "text",
#>       "text": {
#>         "content": "Hello world",
#>         "link": {}
#>       },
#>       "annotations": {
#>         "bold": false,
#>         "italic": false,
#>         "strikethrough": false,
#>         "underline": false,
#>         "code": false,
#>         "color": "default"
#>       },
#>       "plain_text": "Hello world",
#>       "href": {}
#>     }
#>   ],
#>   "display_name": {
#>     "type": "integration",
#>     "resolved_name": "brenwin-internal"
#>   },
#>   "request_id": "adbd7b2a-2d2a-4165-8269-4f00cea711ba"
#> } 

# ----- retrieve comments
notion$comments$retrieve(block_id = "23933ea0-c1e4-81d6-a6f6-dd5b57ad4aba")
#> {
#>   "object": "list",
#>   "results": [
#>     {
#>       "object": "comment",
#>       "id": "23933ea0-c1e4-8180-a10e-001d4fcf0d39",
#>       "parent": {
#>         "type": "page_id",
#>         "page_id": "23933ea0-c1e4-81d6-a6f6-dd5b57ad4aba"
#>       },
#>       "discussion_id": "23933ea0-c1e4-81ea-a476-001c4f062db0",
#>       "created_time": "2025-07-23T05:01:00.000Z",
#>       "last_edited_time": "2025-07-23T05:01:00.000Z",
#>       "created_by": {
#>         "object": "user",
#>         "id": "6b786605-e456-4237-9c61-5efaff23c081"
#>       },
#>       "rich_text": [
#>         {
#>           "type": "text",
#>           "text": {
#>             "content": "Hello world",
#>             "link": {}
#>           },
#>           "annotations": {
#>             "bold": false,
#>             "italic": false,
#>             "strikethrough": false,
#>             "underline": false,
#>             "code": false,
#>             "color": "default"
#>           },
#>           "plain_text": "Hello world",
#>           "href": {}
#>         }
#>       ],
#>       "display_name": {
#>         "type": "integration",
#>         "resolved_name": "brenwin-internal"
#>       }
#>     }
#>   ],
#>   "next_cursor": {},
#>   "has_more": false,
#>   "type": "comment",
#>   "comment": {},
#>   "request_id": "b1a5dbcc-d2b8-405b-82c3-16f6df2c3cdf"
#> }