Comments allow integrations to read and create comments on pages and blocks within Notion. Comments support rich text content and are associated with discussion threads.
Find out more here: https://developers.notion.com/reference/comment-object
CommentsApi commentsApi = client.getCommentsApi();CommentsApi
Retrieves a list of unresolved comments from a page or block. Requires the integration to have read comment capabilities.
Find out more here: https://developers.notion.com/reference/list-comments
CompletableFuture<ApiResponse<PaginatedList>> listCommentsAsync(
final String notionVersion,
final UUID blockId,
final String startCursor,
final Integer pageSize)This endpoint requires bearerAuth
| Parameter | Type | Tags | Description |
|---|---|---|---|
notionVersion |
String |
Header, Required | The version of the Notion API to use. The current version is 2022-06-28. This header is required for all API requests. |
blockId |
UUID |
Query, Required | The ID of the block or page to retrieve comments for. |
startCursor |
String |
Query, Optional | Pagination cursor to continue fetching results. |
pageSize |
Integer |
Query, Optional | Maximum number of comments to return (max 100). Constraints: <= 100 |
200: Comments successfully retrieved.
This method returns an ApiResponse instance. The getResult() getter of this instance returns the response data which is of type PaginatedList.
String notionVersion = "2022-06-28";
UUID blockId = UUID.fromString("00000abc-0000-0000-0000-000000000000");
commentsApi.listCommentsAsync(notionVersion, blockId, null, null).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
Throwable cause = exception.getCause();
if (cause instanceof ErrorException) {
ErrorException errorException = (ErrorException) cause;
errorException.printStackTrace();
} else {
// fallback for unexpected errors
exception.printStackTrace();
}
return null;
});| HTTP Status Code | Error Description | Exception Class |
|---|---|---|
| 401 | The bearer token is missing, invalid, or the integration lacks access. | ErrorException |
| 404 | The requested resource does not exist or the integration lacks access to it. | ErrorException |
| 429 | The request has been rate limited. Notion enforces rate limits of 3 requests per second for integrations. Retry after the specified delay. | ErrorException |
Creates a comment on a page or in an existing discussion thread. The integration must have comment capabilities to use this endpoint.
Find out more here: https://developers.notion.com/reference/create-a-comment
CompletableFuture<ApiResponse<Comment>> createCommentAsync(
final String notionVersion,
final CommentsRequest body)This endpoint requires bearerAuth
| Parameter | Type | Tags | Description |
|---|---|---|---|
notionVersion |
String |
Header, Required | The version of the Notion API to use. The current version is 2022-06-28. This header is required for all API requests. |
body |
CommentsRequest |
Body, Required | - |
200: Comment successfully created.
This method returns an ApiResponse instance. The getResult() getter of this instance returns the response data which is of type Comment.
String notionVersion = "2022-06-28";
CommentsRequest body = new CommentsRequest.Builder(
Arrays.asList(
new RichText.Builder(
Type2.EQUATION,
"plain_text4"
)
.build()
)
)
.build();
commentsApi.createCommentAsync(notionVersion, body).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
Throwable cause = exception.getCause();
if (cause instanceof ErrorException) {
ErrorException errorException = (ErrorException) cause;
errorException.printStackTrace();
} else {
// fallback for unexpected errors
exception.printStackTrace();
}
return null;
});| HTTP Status Code | Error Description | Exception Class |
|---|---|---|
| 400 | The request was invalid or malformed. | ErrorException |
| 401 | The bearer token is missing, invalid, or the integration lacks access. | ErrorException |
| 404 | The requested resource does not exist or the integration lacks access to it. | ErrorException |
| 429 | The request has been rate limited. Notion enforces rate limits of 3 requests per second for integrations. Retry after the specified delay. | ErrorException |