Once a video is on the platform, VideoHub provides endpoints to fetch its full details — including like counts and ownership info — update its metadata, remove it entirely from both the database and Cloudinary, or flip its visibility between published and hidden. All write operations require authentication. The toggle endpoint enforces ownership; the update and delete endpoints authenticate the caller but do not verify ownership in the controller.Documentation 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.
GET /api/v1/videos/:videoId
Fetches a single video document enriched with owner details, total like count, and — when a valid JWT is present — whether the requesting user has liked the video. Authentication: Optional (verifyJWTIfAvailable)
Path Parameters
The MongoDB ObjectId of the video to retrieve.
Errors
| Status | Cause |
|---|---|
400 | videoId parameter is missing |
400 | videoId is not a valid MongoDB ObjectId format |
404 | No video found with the given ID |
Response
Thelikes array used internally for aggregation is removed from the final response via $project: { likes: 0 }. Only the computed fields below are returned.
The unique MongoDB ObjectId of the video.
The display title of the video.
The video description.
Cloudinary URL pointing to the video file. Will read
"processing" while the background upload is still in progress.Cloudinary URL pointing to the thumbnail image. Will read
"processing" while the background upload is still in progress.Video length in seconds as reported by Cloudinary. Reads
0 while processing.Total view count.
Whether the video is publicly visible.
Embedded owner information resolved from the
users collection via $lookup.Total number of likes the video has received, computed via
$lookup against the likes collection.true if the authenticated requester’s _id is found in the likedBy field of the likes documents for this video; false if they have not liked it or if the request was unauthenticated.ISO 8601 timestamp of when the document was created.
ISO 8601 timestamp of the most recent document update.
Example
PATCH /api/v1/videos/:videoId
Updates one or more metadata fields on an existing video. All body fields are optional, but at least one must be supplied. When a new thumbnail is provided, the old one is automatically removed from Cloudinary before the new URL is saved. Authentication: Required (verifyJwt)
Only
title, description, and thumbnail can be changed via this endpoint. To change the actual video file you must delete the video and re-upload it using the two-step publish flow.Path Parameters
The MongoDB ObjectId of the video to update.
Request Body (multipart/form-data)
Replacement title for the video. Ignored if empty or whitespace-only.
Replacement description for the video. Ignored if empty or whitespace-only.
A new thumbnail image. When provided, the existing thumbnail’s public ID is extracted from its Cloudinary URL and destroyed via
cloudinary.uploader.destroy before the new one is uploaded and saved.Errors
| Status | Cause |
|---|---|
400 | videoId is not a valid ObjectId format, or no valid update fields were provided |
404 | No video found with the given ID |
500 | Thumbnail upload to Cloudinary failed |
Response
Returns the full updated video document (post-update snapshot from MongoDB).Example
DELETE /api/v1/videos/:videoId
Permanently removes a video from the platform. Both the video file and thumbnail are destroyed on Cloudinary before the MongoDB document is deleted. Authentication: Required (verifyJwt)
The controller does not verify that the caller is the video’s owner before deleting. Any authenticated user who knows the
videoId can delete the video.Path Parameters
The MongoDB ObjectId of the video to delete.
Errors
| Status | Cause |
|---|---|
400 | videoId is not a valid MongoDB ObjectId format |
404 | No video found with the given ID |
500 | Cloudinary deletion failed; the database record is preserved |
Response
Returns the video document as it existed just before deletion.Example
PATCH /api/v1/videos/toggle/publish/:videoId
Flips theisPublished flag on a video between true and false. Only the video’s owner can call this endpoint — ownership is verified in the controller before the toggle is applied.
Authentication: Required (verifyJwt)
This endpoint is mounted at
/toggle/publish/:videoId, which takes precedence over the generic /:videoId route. Make sure to use the full path as shown.Path Parameters
The MongoDB ObjectId of the video whose publish status should be toggled.
Errors
| Status | Cause |
|---|---|
400 | videoId parameter is missing or not a valid MongoDB ObjectId format |
403 | The authenticated user is not the owner of the video |
404 | No video found with the given ID |
Response
The new publish status after the toggle —
true if the video is now public, false if it is now hidden.validateBeforeSave: false so that the toggle bypasses other schema validations.
Example
Video Object Schema
The following fields make up the video document stored in MongoDB and returned by all endpoints in this section.Unique MongoDB ObjectId identifying the video. Pre-generated by the
POST /api/v1/videos/init endpoint before the database record is created.The display title of the video. Required (
required: true in schema).A text description of the video’s content. Required at the schema level (
required: true); can be updated via the PATCH endpoint.Cloudinary URL for the video file. Required (
required: true in schema). Populated with "processing" while the background upload is running; replaced with the real URL on completion.Cloudinary URL for the thumbnail image. Required (
required: true in schema). Populated with "processing" while the background upload is running; replaced with the real URL (or an auto-generated still frame) on completion.Video duration in seconds as reported by Cloudinary. Required (
required: true in schema). Set to 0 while processing; updated when the background job finishes. Videos exceeding 3600 seconds (1 hour) are rejected and deleted.Total view count. Defaults to
0 on creation.Controls public visibility. The schema default is
true, but publishVideoDraft explicitly sets this to false on creation so the video remains hidden until background processing succeeds. Can be toggled manually by the owner via the toggle endpoint.MongoDB ObjectId referencing the
User document of the channel that uploaded the video.ISO 8601 timestamp added automatically by Mongoose’s
timestamps option.ISO 8601 timestamp updated automatically by Mongoose on every document save.