Comments

Comment management

Get Comments by Blog

get

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
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-09-14T10:36:41.893Z",
      "updatedAt": "2025-09-14T10:36:41.893Z"
    }
  ]
}

Create Comment

post

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
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-09-14T10:36:41.893Z",
    "updatedAt": "2025-09-14T10:36:41.893Z"
  }
}

Delete Comment

delete

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.

No content

delete
DELETE /api/v1/comments/{commentId} HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Accept: */*

No content

Was this helpful?