VidTube uses JSON Web Tokens (JWT) for authentication. When you log in, the API issues two tokens: a short-lived access token (default expiry: 1 hour) and a longer-lived refresh token (default expiry: 10 days). You pass the access token on every request to a protected endpoint; when it expires, you use the refresh token to get a new one without logging in again.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Pragyat-Nikunj/VidTube/llms.txt
Use this file to discover all available pages before exploring further.
How to get tokens
CallPOST /users/login with your credentials. All three fields are required.
httpOnly cookies simultaneously:
How to pass tokens
You have two options. Use whichever fits your client.Option 1: Authorization header (recommended for API clients)
Include the access token as aBearer token in the Authorization header on every request to a protected endpoint:
Option 2: Cookies (recommended for browser clients)
When you log in, the API automatically sets twohttpOnly cookies — accessToken and refreshToken — with the secure flag enabled in production. Browsers send these cookies automatically on subsequent requests to the same origin, so no extra headers are required.
Both authentication methods work in parallel. The middleware checks
req.cookies.accessToken first, then falls back to the Authorization header. You can use either or both in the same application.Protected endpoints
The following endpoints require a valid access token: UsersPOST /users/logoutPOST /users/change-passwordGET /users/current-userPATCH /users/update-accountPATCH /users/update-avatarPATCH /users/update-coverGET /users/c/:usernameGET /users/history
POST /videos/publishVideoPATCH /videos/updateVideo/:videoIdDELETE /videos/deleteVideo/:videoIdPATCH /videos/togglePublish/:videoId
POST /comments/addComment/:videoIdPATCH /comments/updateComment/:commentIdDELETE /comments/deleteComment/:commentId
POST /likes/video/:videoIdPOST /likes/comment/:commentIdPOST /likes/tweet/:tweetIdGET /likes/videos
POST /playlist/createPlaylistPUT /playlist/:playlistId/videos/:videoIdDELETE /playlist/:playlistId/videos/:videoIdDELETE /playlist/:playlistIdPATCH /playlist/:playlistId
POST /tweets/createTweetPATCH /tweets/updateTweet/:tweetIdDELETE /tweets/deleteTweet/:tweetId
POST /subscription/subscribe/:channelIdGET /subscription/subscribedChannels/:subscriberIdGET /subscription/channelSubscribers/:channelId
GET /dashboard/channelStats/:channelIdGET /dashboard/channel/videos/:channelId
GET /healthcheck, GET /videos/getAllVideos, GET /videos/getVideoById/:videoId, GET /comments/videoComments/:videoId, GET /tweets/getUserTweets/:userId, GET /playlist/user/:userId, GET /playlist/:playlistId, and GET /subscription/channelSubscriberCount/:channelId.
How to refresh tokens
When your access token expires, callPOST /users/refresh-Token. You can send the refresh token either as a cookie (set automatically during login) or in the request body.
How to log out
CallingPOST /users/logout invalidates the refresh token stored on the server and clears both cookies. This endpoint requires a valid access token.
Common authentication errors
| Status | Cause | Resolution |
|---|---|---|
401 Unauthorized | No token provided | Add Authorization: Bearer <token> header or ensure cookies are sent |
401 Invalid Access Token | Token is malformed or signed with a different secret | Re-authenticate with POST /users/login |
401 on token refresh | Access token expired | Call POST /users/refresh-Token with a valid refresh token |
401 Invalid refresh token | Refresh token is expired or has already been rotated | Log in again with POST /users/login |
404 User not found | Token is valid but the associated user no longer exists | Log in again with a different account |