API EndpointsCommentsUpvote Comment

Upvote Comment

Endpoint

URL: https://api.replyke.com/:projectId/comments/:commentId/upvote

Method: PATCH

Authentication Required: Yes (Requires a valid access token in the Authorization header)


Description

This endpoint allows a user to upvote a comment. If a user has already upvoted the comment, they cannot upvote it again. If the user had previously downvoted the comment, their downvote will be removed.


Request

Headers

  • Authorization: Bearer <accessToken> (Required, must contain a valid access token)

URL Parameters

ParameterTypeRequiredDescription
projectIdstringYesThe project ID associated with the comment.
commentIdstringYesThe ID of the comment to be upvoted.

Response

Success Response (200 OK)

{
  "id": "<COMMENT_ID>",
  "projectId": "<PROJECT_ID>",
  "userId": "<USER_ID>",
  "entityId": "<ENTITY_ID>",
  "parentId": "<PARENT_ID>",
  "content": "<COMMENT_CONTENT>",
  "gif": {
    "id": "<GIF_ID>",
    "gifUrl": "<GIF_URL>",
    "gifPreviewUrl": "<GIF_PREVIEW_URL>",
    "altText": "<ALT_TEXT>",
    "url": "<URL>",
    "aspectRatio": "<ASPECT_RATIO>"
  },
  "mentions": ["<UPDATED_MENTIONS_ARRAY>"],
  "upvotes": ["<UPDATED_UPVOTES_ARRAY>"],
  "downvotes": ["<UPDATED_DOWNVOTES_ARRAY>"]
}

Error Responses

Missing commentId (400 Bad Request)

{
  "error": "Missing required data"
}

Reason: The request must include a commentId to specify which comment to upvote.

Comment Not Found (404 Not Found)

{
  "error": "Comment not found"
}

Reason: The specified commentId does not exist or does not belong to the given projectId.

Already Upvoted (409 Conflict)

{
  "error": "User has already upvoted this comment"
}

Reason: The user has already upvoted this comment and cannot upvote it again.

Unauthorized Request (401 Unauthorized)

{
  "error": "Missing or invalid authorization token"
}

Reason: The request did not include a valid access token in the Authorization header.

Server Error (500 Internal Server Error)

{
  "error": "Server error"
}

Reason: An unexpected error occurred while processing the request.


Notes

  • A user cannot upvote a comment more than once.
  • If a user has previously downvoted the comment, their downvote will be removed upon upvoting.
  • The Authorization header must be provided and contain a valid access token.
  • The response will contain the updated upvotes and downvotes arrays reflecting the latest state.
  • A notification is sent to the comment owner when their comment is upvoted.