API EndpointsCommentsCreate Comment

Create Comment

Endpoint

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

Method: POST

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


Description

This endpoint allows users to create a new comment or reply to an entity. Comments can include text content, GIFs, and mentions. If a comment is a reply, it must include a parentId referencing the parent comment.


Request

Headers

  • Content-Type: application/json
  • Authorization: Bearer <accessToken> (Required, must contain a valid access token)

Body Parameters

ParameterTypeRequiredDescription
entityIdstringYesID of the entity being commented on.
contentstringConditionalThe text content of the comment (required unless a GIF is provided).
gifobjectConditionalA GIF object containing metadata (required if content is not provided).
mentionsarrayNoArray of user mentions, each containing id and username. Defaults to an empty array.
parentIdstringNoID of the parent comment if this is a reply.

GIF Object Structure

ParameterTypeRequiredDescription
idstringYesUnique identifier of the GIF.
gifUrlstringYesURL of the GIF.
gifPreviewUrlstringYesURL for the GIF preview (if available).
altTextstringYesAlternative text for accessibility.
urlstringYesDirect URL to the GIF resource.
aspectRatiostringYesThe aspect ratio of the GIF.

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": ["<MENTIONS_ARRAY>"],
  "upvotes": [],
  "downvotes": [],
  "createdAt": "<TIMESTAMP>",
  "updatedAt": "<TIMESTAMP>",
  "deletedAt": null
}
 

Error Responses

Missing entityId (400 Bad Request)

{
  "error": "Missing entity ID"
}
 

Reason: The request must include an entityId to associate the comment with an entity.

Missing Required Content (400 Bad Request)

{
  "error": "Missing required comment content"
}
 

Reason: Either content or gif must be provided to create a comment.

Entity Not Found (404 Not Found)

{
  "error": "Entity not found"
}
 

Reason: The specified entityId does not correspond to any existing entity.

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 comment must include either content or a gif but not be empty.
  • If parentId is provided, the comment will be treated as a reply.
  • The user’s reputation will be automatically updated upon posting a comment.
  • Notifications are automatically generated for mentioned users and parent comment authors.
  • The Authorization header must be provided and contain a valid access token.