Comments
Comment management
Retrieves all comments associated with a specific blog post.
Authorizations
Path parameters
blogIdstring · objectidRequired
ID of the blog post.
Responses
200
A list of comments for the blog.
application/json
401
Authentication information is missing or invalid (e.g., missing/expired token).
application/json
404
The specified resource was not found.
application/json
500
An unexpected error occurred on the server.
application/json
get
GET /api/v1/comments/blog/{blogId} HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Accept: */*
{
"comments": [
{
"_id": "text",
"blogId": "text",
"userId": "text",
"content": "text",
"likesCount": 0,
"createdAt": "2025-07-28T18:46:02.088Z",
"updatedAt": "2025-07-28T18:46:02.088Z"
}
]
}
Adds a new comment to a specific blog post. Increments comments count.
Authorizations
Path parameters
blogIdstring · objectidRequired
ID of the blog post.
Body
contentstring · max: 1000Required
The comment text
Responses
201
Comment created successfully.
application/json
400
Invalid input data provided. See errors object for details.
application/json
401
Authentication information is missing or invalid (e.g., missing/expired token).
application/json
404
The specified resource was not found.
application/json
500
An unexpected error occurred on the server.
application/json
post
POST /api/v1/comments/blog/{blogId} HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Content-Type: application/json
Accept: */*
Content-Length: 18
{
"content": "text"
}
{
"comment": {
"_id": "text",
"blogId": "text",
"userId": "text",
"content": "text",
"likesCount": 0,
"createdAt": "2025-07-28T18:46:02.088Z",
"updatedAt": "2025-07-28T18:46:02.088Z"
}
}
Deletes a specific comment. Requires user to be author or admin. Decrements comments count.
Authorizations
Path parameters
commentIdstring · objectidRequired
ID of the comment.
Responses
204
Request successful, no response body.
401
Authentication information is missing or invalid (e.g., missing/expired token).
application/json
403
Access denied due to insufficient permissions.
application/json
404
The specified resource was not found.
application/json
500
An unexpected error occurred on the server.
application/json
delete
DELETE /api/v1/comments/{commentId} HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Accept: */*
No content
Was this helpful?