Playlists belong to a user and hold an ordered list of video references. All 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. Only the playlist owner can modify, add videos to, remove videos from, or delete a playlist — operations on playlists owned by other users return an error. Duplicate video entries within a single playlist are prevented at the API level.
POST /api/v1/playlist
Creates a new playlist for the authenticated user. Playlist names must be unique per user — you cannot have two playlists with the same name in your account.Body parameters
The name of the new playlist. Must be non-empty. Returns
400 if missing.An optional description for the playlist.
Response
Returns200 with the newly created playlist document.
Unique identifier of the created playlist.
Name of the playlist.
Description of the playlist (may be absent if not provided).
Empty array on creation — no videos are added at this stage.
ObjectId of the authenticated user who owns the playlist.
ISO 8601 creation timestamp.
ISO 8601 last-updated timestamp.
Errors
| Status | Message |
|---|---|
409 | "Playlist with the same name already exists in your account" — the user already has a playlist with this exact name. |
400 | "Playlist name is required" — the name field was missing from the request body. |
Example
GET /api/v1/playlist/:playlistId
Fetches the full details of a single playlist including the owner’s public profile, expanded video documents (each with their own owner details), and a computedtotalVideos count.
Path parameters
The MongoDB ObjectId of the playlist to retrieve. Returns
400 if missing or invalid; 404 if no playlist exists with that ID.Response
Returns an array containing a single enriched playlist object (the aggregation pipeline result).Unique identifier of the playlist.
Name of the playlist.
Description of the playlist.
ObjectId of the playlist owner.
Resolved public profile of the playlist owner.
Array of expanded video documents in the playlist. Each entry includes the video’s own
ownerDetails.Total number of videos currently in the playlist. Computed dynamically via
$size.ISO 8601 creation timestamp.
ISO 8601 last-updated timestamp.
Example
PATCH /api/v1/playlist/:playlistId
Updates thename and/or description of an existing playlist. At least one of the two fields must be included in the request body. Only the playlist owner can perform this operation. Ownership is enforced inside the findOneAndUpdate query — a non-owner update returns 404. The response contains only the fields that were actually updated, not the full playlist document.
Path parameters
The MongoDB ObjectId of the playlist to update. Returns
400 if missing or invalid; 404 if not found or the authenticated user is not the owner.Body parameters
New name for the playlist. Must be non-empty after trimming whitespace if provided.
New description for the playlist.
Response
Returns200 with an object containing only the fields that were updated.
The updated playlist name. Present only if
name was included in the request.The updated playlist description. Present only if
description was included in the request.Errors
| Status | Message |
|---|---|
400 | "Please provide a name or description to update" — neither name nor description was provided. |
400 | "Playlist name cannot be empty" — name was provided but was blank after trimming. |
404 | "Playlist not found or you don't have permission to update it" — playlist doesn’t exist or the requester is not the owner. |
Example
DELETE /api/v1/playlist/:playlistId
Permanently deletes a playlist and its video reference list. The underlying video documents are not affected — only the playlist record is removed. Ownership is enforced atomically viafindOneAndDelete({ _id: playlistId, owner: req.user._id }) — only the playlist owner can delete it.
Path parameters
The MongoDB ObjectId of the playlist to delete. Returns
400 if missing or invalid; 404 if not found or the requester is not the owner.Response
Returns200 with the full deleted playlist document as it existed before deletion.
ObjectId of the deleted playlist.
Name of the deleted playlist.
Description of the deleted playlist.
Array of video ObjectIds that were in the playlist.
ObjectId of the playlist owner.
ISO 8601 creation timestamp.
ISO 8601 last-updated timestamp.
Errors
| Status | Message |
|---|---|
404 | "Playlist not found or you don't have permission to delete it" — playlist doesn’t exist or the requester is not the owner. |
Example
PATCH /api/v1/playlist/add/:videoId/:playlistId
Adds a video to a playlist. The endpoint first verifies ownership of the playlist, then checks whether the video is already present in thevideos array. If the video is a duplicate a 400 error is returned immediately and no database write occurs. Otherwise the video ObjectId is appended using $push.
Path parameters
The MongoDB ObjectId of the video to add. Returns
400 if missing or invalid.The MongoDB ObjectId of the target playlist. Returns
400 if missing or invalid.Response
Returns200 with the updated playlist document after the video has been added.
ObjectId of the playlist.
Name of the playlist.
Description of the playlist.
Updated array of video ObjectIds now including the newly added video.
ObjectId of the playlist owner.
ISO 8601 creation timestamp.
ISO 8601 last-updated timestamp.
Errors
| Status | Message |
|---|---|
400 | "This video is already in the playlist" — the video ObjectId already exists in the videos array. |
403 | "You do not have permission to modify this playlist" — authenticated user is not the playlist owner. |
400 | "Playlist not found" — no playlist exists with the given playlistId. |
Example
PATCH /api/v1/playlist/remove/:videoId/:playlistId
Removes a video from a playlist using MongoDB’s$pull operator. The endpoint first verifies ownership, then performs the update. If the video is not in the playlist the $pull is a no-op and the updated playlist is still returned successfully.
Path parameters
The MongoDB ObjectId of the video to remove. Returns
400 if missing or invalid.The MongoDB ObjectId of the playlist to remove the video from. Returns
400 if missing or invalid.Response
Returns200 with the updated playlist document after the video has been removed.
ObjectId of the playlist.
Name of the playlist.
Description of the playlist.
Updated array of video ObjectIds with the specified video removed.
ObjectId of the playlist owner.
ISO 8601 creation timestamp.
ISO 8601 last-updated timestamp.
Errors
| Status | Message |
|---|---|
403 | "You do not have permission to modify this playlist" — authenticated user is not the playlist owner. |
400 | "Playlist not found" — no playlist exists with the given playlistId. |
Example
GET /api/v1/playlist/user/:userId
Returns all playlists owned by the specified user via a simplePlaylist.find({ owner: userId }) — no aggregation is performed. This is useful for rendering a user’s playlist library on their profile page. Use GET /api/v1/playlist/:playlistId to fetch a specific playlist with full expanded video data.
Path parameters
The MongoDB ObjectId of the user whose playlists you want to list. Returns
400 if missing or not a valid ObjectId.Response
Returns an array of playlist documents. An empty array is returned if the user has no playlists.ObjectId of the playlist.
Name of the playlist.
Description of the playlist.
Array of video ObjectIds in the playlist (not expanded).
ObjectId of the playlist owner.
ISO 8601 creation timestamp.
ISO 8601 last-updated timestamp.
Example
Playlist object schema
MongoDB-generated unique identifier for the playlist.
Required. The display name of the playlist. Must be unique per owner. This is the only field with a
required constraint in the schema.Optional free-text description of the playlist.
Ordered array of references to
Video documents. Entries are appended with $push (add) and removed with $pull (remove). Duplicates are rejected at the application layer before any database write.Reference to the
User document who owns this playlist. Always set by application logic when a playlist is created.Automatically set by Mongoose
timestamps on document creation.Automatically updated by Mongoose
timestamps on every save.