Comments API
Endpoints for retrieving and submitting comments.
/comments
Retrieves all comments for a specific post, structured hierarchically with replies.
Query Parameters
postSlug
RequiredThe slug of the post to fetch comments for.
Response
Returns an array of top-level comment objects. Each comment can contain a `replies` array with nested comment objects.
[
{
"id": "clwbigexs000008l4hy227j4a",
"content": "This is a great post, very informative!",
"createdAt": "2025-08-12T10:30:00.000Z",
"user": {
"id": "user_2aVq...",
"name": "Alice",
"image": "https://.../alice.png"
},
"parentId": null,
"replies": [
{
"id": "clwbigz2h000208l44f1g1g1g",
"content": "I agree, I learned a lot.",
"createdAt": "2025-08-12T11:00:00.000Z",
"user": {
"id": "user_2bXy...",
"name": "Bob",
"image": "https://.../bob.png"
},
"parentId": "clwbigexs000008l4hy227j4a",
"replies": []
}
]
}
]
/comments
Submits a new comment or a reply to an existing comment. Requires end-user authentication.
Warning
End-User Authentication Required
This endpoint requires a separate end-user authentication layer (e.g., JWT in the `Authorization` header) to identify the commenter. The organization API key is still required to authorize the action against your account.
Request Body
content
RequiredThe text content of the comment.
postSlug
RequiredThe slug of the post being commented on.
parentId
OptionalThe ID of the parent comment if this is a reply.
Example Body (New Comment)
{
"content": "This is a fantastic article!",
"postSlug": "my-first-blog-post"
}
Example Body (Reply)
{
"content": "This is a reply to a comment.",
"postSlug": "my-first-blog-post",
"parentId": "clwbigexs000008l4hy227j4a"
}
Response (Status 201)
Returns the newly created comment object.
{
"id": "clwbii7k9000408l4e6q7h7h7",
"content": "This is a fantastic article!",
"createdAt": "2025-08-12T12:00:00.000Z",
"parentId": null,
"user": {
"id": "user_2cVz...",
"name": "Charlie",
"image": "https://.../charlie.png"
}
}