All comment endpoints require a valid JWT in theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/barcode8/VideoHub/llms.txt
Use this file to discover all available pages before exploring further.
Authorization header — unauthenticated requests are rejected. Comments are always scoped to a specific video identified by videoId. The paginated list endpoint joins owner profile data and live like counts into every comment document so that clients need only one request to render a full comment thread.
GET /api/v1/comments/:videoId
Returns a paginated list of comments for a given video, sorted from newest to oldest. Each comment is enriched with the owner’s public profile fields, a total like count, and a per-userisLiked flag.
Path parameters
The MongoDB ObjectId of the video whose comments you want to fetch. Returns
400 if the value is missing or not a valid ObjectId.Query parameters
The page of results to return. Must be a positive integer.
Maximum number of comments to return per page.
Response
Returns amongoose-aggregate-paginate-v2 result envelope containing a docs array of comment objects.
Array of comment objects for the requested page.
Total number of comments for this video.
The
limit value used for this page.The current page number.
Total number of available pages.
Whether a next page exists.
Whether a previous page exists.
Example
POST /api/v1/comments/:videoId
Adds a new comment to the specified video. The comment is associated with the authenticated user as owner.Path parameters
The MongoDB ObjectId of the video to comment on. Returns
400 if missing or invalid.Body parameters
The text body of the comment. Must be non-empty after trimming whitespace. Returns
400 if absent or blank.Response
Returns200 with the newly created comment document.
Unique identifier of the created comment.
The submitted comment text.
ObjectId of the video the comment was added to.
ObjectId of the authenticated user who created the comment.
ISO 8601 creation timestamp.
ISO 8601 last-updated timestamp.
Errors
| Status | Message |
|---|---|
400 | "Comment body is mandatory" — content was empty or whitespace-only. |
400 | "Invalid Video ID format" — videoId is not a valid MongoDB ObjectId. |
Example
PATCH /api/v1/comments/c/:commentId
Updates the text of an existing comment. Only the user who originally authored the comment may edit it — attempting to edit someone else’s comment returns a400 error.
Path parameters
The MongoDB ObjectId of the comment to update. Returns
400 if missing or invalid.Body parameters
The new text body to replace the existing comment. Must be non-empty after trimming whitespace.
Response
Returns200 with the full updated comment document.
Unique identifier of the comment.
The updated comment text.
ObjectId of the associated video.
ObjectId of the comment author.
ISO 8601 creation timestamp.
ISO 8601 timestamp of the most recent edit.
Errors
| Status | Message |
|---|---|
400 | "You do not have permission to edit this comment" — authenticated user is not the comment owner. |
400 | "Comment body is mandatory" — content was empty or whitespace-only. |
400 | "Comment could not be found" — no comment exists with the given commentId. |
400 | "Invalid Comment ID format" — commentId is not a valid MongoDB ObjectId. |
Example
DELETE /api/v1/comments/c/:commentId
Permanently deletes a comment. Only the comment’s original author may delete it. After deletion the comment is removed from the database and associated likes are no longer referenced.Path parameters
The MongoDB ObjectId of the comment to delete. Returns
400 if missing or invalid.Response
Returns200 with an object containing the ID of the deleted comment.
The MongoDB ObjectId of the comment that was deleted.
Errors
| Status | Message |
|---|---|
400 | "You do not have permission to delete this comment" — authenticated user is not the comment owner. |
400 | "Comment could not be found" — no comment exists with the given commentId. |
400 | "Invalid Comment ID format" — commentId is not a valid MongoDB ObjectId. |
Example
Comment object schema
The base Comment document stored in MongoDB has the following shape. List responses augment this with the computed fields described above.MongoDB-generated unique identifier for the comment.
Text body of the comment. Required and must be non-empty.
Reference to the
Video document this comment is attached to.Reference to the
User document who authored the comment.Automatically set by Mongoose
timestamps on document creation.Automatically updated by Mongoose
timestamps on every save.List responses (
GET /api/v1/comments/:videoId) include three additional computed fields not stored in the database: ownerDetails (username, fullName, avatar), likesCount, and isLiked. These are resolved at query time via MongoDB aggregation using $lookup on the users and likes collections respectively, then paginated with Comment.aggregatePaginate.