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.
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 for pagination
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]"
}
}
}
]
}
Post ID this comment belongs to
User ID of comment author
Comment content (max 1000 characters)
Parent comment ID for threaded replies
Expanded related records (e.g., author details)
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"
}'
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 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"
}'
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 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
When a comment is deleted, the post’s commentCount is automatically decremented.
Mentions
Comments support @username mentions. When a user is mentioned:
- The mention is automatically detected from comment content
- A notification is sent to the mentioned user
- 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.