Skip to main content

Overview

The Comments API allows users to create, read, update, and delete comments on posts. Comments support mentions and trigger notifications to post authors and mentioned users.

List Comments

Retrieve all comments for a specific post.

Request

curl -X GET "https://your-domain.com/api/posts/{postId}/comments?page=1&perPage=50" \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN"
page
number
default:"1"
Page number for pagination
perPage
number
default:"50"
Number of comments per page (max 100)

Response

{
  "page": 1,
  "perPage": 50,
  "totalItems": 10,
  "totalPages": 1,
  "items": [
    {
      "id": "RECORD_ID",
      "collectionId": "comments_collection_id",
      "collectionName": "comments",
      "created": "2026-03-01 12:00:00.000Z",
      "updated": "2026-03-01 12:00:00.000Z",
      "post": "POST_ID",
      "author": "USER_ID",
      "content": "Great post!",
      "parent": null,
      "expand": {
        "author": {
          "id": "USER_ID",
          "username": "username",
          "email": "[email protected]"
        }
      }
    }
  ]
}
items
array
Array of comment objects
items[].id
string
Comment ID
items[].post
string
Post ID this comment belongs to
items[].author
string
User ID of comment author
items[].content
string
Comment content (max 1000 characters)
items[].parent
string | null
Parent comment ID for threaded replies
items[].expand
object
Expanded related records (e.g., author details)

Create Comment

Add a new comment to a post.

Request

curl -X POST "https://your-domain.com/api/posts/{postId}/comments" \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Great post! @username"
  }'
content
string
required
Comment content (max 1000 characters). Supports @username mentions.

Response

{
  "id": "RECORD_ID",
  "collectionId": "comments_collection_id",
  "collectionName": "comments",
  "created": "2026-03-01 12:00:00.000Z",
  "updated": "2026-03-01 12:00:00.000Z",
  "post": "POST_ID",
  "author": "USER_ID",
  "content": "Great post! @username",
  "parent": null,
  "expand": {
    "author": {
      "id": "USER_ID",
      "username": "username",
      "email": "[email protected]"
    }
  }
}

Update Comment

Update an existing comment. Users can only update their own comments.

Request

curl -X PUT "https://your-domain.com/api/comments/{id}" \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Updated comment content"
  }'
content
string
required
Updated comment content (max 1000 characters)

Response

{
  "id": "RECORD_ID",
  "collectionId": "comments_collection_id",
  "collectionName": "comments",
  "created": "2026-03-01 12:00:00.000Z",
  "updated": "2026-03-01 13:00:00.000Z",
  "post": "POST_ID",
  "author": "USER_ID",
  "content": "Updated comment content",
  "parent": null
}

Delete Comment

Delete a comment. Users can only delete their own comments.

Request

curl -X DELETE "https://your-domain.com/api/comments/{id}" \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN"

Response

{
  "success": true
}
When a comment is deleted, the post’s commentCount is automatically decremented.

Mentions

Comments support @username mentions. When a user is mentioned:
  1. The mention is automatically detected from comment content
  2. A notification is sent to the mentioned user
  3. The post author is notified (unless they are the comment author)
Mention format: @username anywhere in the comment text. Example:
"Hey @alice, check out @bob's comment above!"

Notifications

Comments trigger the following notifications:
  • Comment notification: Sent to post author when someone comments on their post
  • Mention notification: Sent to users who are mentioned in the comment
Notifications are automatically created and can be retrieved via the notifications API.

Content Sanitization

Comment content is automatically sanitized to prevent XSS attacks. HTML tags are stripped or escaped.

Threaded Replies

Comments support threaded replies using the parent field:
{
  "content": "This is a reply",
  "parent": "PARENT_COMMENT_ID"
}
Note: The current API implementation has basic support for parent comments. Full threading UI may require additional client-side logic.

Build docs developers (and LLMs) love