POST /posts/{postId}/comments

Adds a comment to a post (only if comments are allowed on the post).

Path parameters

  • postId string Required

    The post ID

application/json

Body Required

  • postId string Required

    ID of the post

  • content string Required

    Comment content

Responses

  • 201 application/json

    Comment created successfully

    Hide response attributes Show response attributes object
    • success boolean
    • code integer(int32)
    • message string
    • data object

      Comment on a post

      Hide data attributes Show data attributes object
      • id string Required

        Unique identifier for the comment

      • postId string Required

        ID of the post

      • userId string Required

        ID of the user who commented

      • content string Required

        Comment content

      • createdAt string(date-time)

        Timestamp when comment was created

      • updatedAt string(date-time)

        Timestamp when comment was last updated

      • deletedAt string(date-time) | null

        Timestamp when comment was deleted

  • 400 application/json

    Bad Request - Invalid input data or malformed request

    Hide response attributes Show response attributes object
    • success boolean
    • code integer
    • errorCode string
    • message string
    • timestamp string(date-time)
  • 401 application/json

    Unauthorized - Invalid or missing authentication token

    Hide response attributes Show response attributes object
    • success boolean
    • code integer
    • errorCode string
    • message string
    • timestamp string(date-time)
  • 403 application/json

    Forbidden - Comments not allowed on this post

    Hide response attributes Show response attributes object
    • success boolean
    • code integer
    • errorCode string
    • message string
    • timestamp string(date-time)
  • 404 application/json

    Post not found

    Hide response attributes Show response attributes object
    • success boolean
    • code integer
    • errorCode string
    • message string
    • timestamp string(date-time)
  • 500 application/json

    Internal Server Error

    Hide response attributes Show response attributes object
    • success boolean
    • code integer
    • errorCode string
    • message string
    • timestamp string(date-time)
POST /posts/{postId}/comments
curl \
 --request POST 'https://api.huy-devops.site/api/posts/{postId}/comments' \
 --header "Authorization: Bearer $ACCESS_TOKEN" \
 --header "Content-Type: application/json" \
 --data '{"postId":"550e8400-e29b-41d4-a716-446655440008","content":"Thanks for the update!"}'
Request examples
{
  "postId": "550e8400-e29b-41d4-a716-446655440008",
  "content": "Thanks for the update!"
}
Response examples (201)
{
  "success": true,
  "code": 200,
  "message": "string",
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440009",
    "postId": "550e8400-e29b-41d4-a716-446655440008",
    "userId": "550e8400-e29b-41d4-a716-446655440002",
    "content": "Thanks for the update!",
    "createdAt": "2024-09-20T11:00:00Z",
    "updatedAt": "2024-09-20T11:30:00Z",
    "deletedAt": "2026-05-04T09:42:00Z"
  }
}
Response examples (400)
{
  "success": false,
  "code": 42,
  "errorCode": "string",
  "message": "string",
  "timestamp": "2026-05-04T09:42:00Z"
}
Response examples (401)
{
  "success": false,
  "code": 42,
  "errorCode": "string",
  "message": "string",
  "timestamp": "2026-05-04T09:42:00Z"
}
Response examples (403)
{
  "success": false,
  "code": 42,
  "errorCode": "string",
  "message": "string",
  "timestamp": "2026-05-04T09:42:00Z"
}
Response examples (404)
{
  "success": false,
  "code": 42,
  "errorCode": "string",
  "message": "string",
  "timestamp": "2026-05-04T09:42:00Z"
}
Response examples (500)
{
  "success": false,
  "code": 42,
  "errorCode": "string",
  "message": "string",
  "timestamp": "2026-05-04T09:42:00Z"
}