API EndpointsModerationCreate Report

Create Report

Endpoint

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

Method: POST

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


Description

This endpoint allows users to report an entity or a comment. If a report already exists for the target, the reporting user will be added to the list of reporters. Otherwise, a new report will be created.


Request

Headers

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

URL Parameters

ParameterTypeRequiredDescription
projectIdstringYesThe project ID associated with the report.

Request Body

ParameterTypeRequiredDescription
targetIdstringYesThe ID of the comment or entity being reported.
targetTypestringYesThe type of the reported item. Must be either Comment or Entity.
reasonstringYesThe reason for reporting the target.
detailsstringNoAdditional details about the report.

Additional details about the report.

Example Request Body

{
  "targetId": "<TARGET_ID>",
  "targetType": "Comment",
  "reason": "illegalActivity",
  "details": "This comment contains offensive language."
}

Response

Success Response (201 Created)

{
  "message": "Report submitted successfully"
}

Success Response (200 OK) - User Already Reported

{
  "message": "Report already registered by this user"
}

Success Response (200 OK) - Report Updated

{
  "message": "Report updated successfully"
}

Error Responses

Missing Required Fields (400 Bad Request)

{
  "error": "Missing required fields in request body"
}

Reason: The request is missing targetId, targetType, or reason.

Invalid targetType (400 Bad Request)

{
  "error": "Invalid targetType. Must be 'Comment' or 'Entity'."
}

Reason: The targetType must be either Comment or Entity.

Target Not Found (404 Not Found)

{
  "error": "Comment not found"
}

Reason: The specified targetId does not exist or is not a valid comment.

{
  "error": "Entity not found"
}

Reason: The specified targetId does not exist or is not a valid entity.

Invalid Foreign Key (400 Bad Request)

{
  "error": "Invalid targetId or projectId"
}

Reason: The provided targetId or projectId does not exist in the database.

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

  • Users can only report an entity or a comment.
  • If a report already exists for the target, the user is added to the list of reporters.
  • Reports are stored at the project level.
  • The Authorization header must be provided and contain a valid access token.