Quizmaster uses JSON Web Tokens (JWT) for API authentication. After logging in, you receive a token that you include in theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/geeky-hamster/Quizmaster/llms.txt
Use this file to discover all available pages before exploring further.
Authorization header of subsequent requests. Tokens are valid for 7 days. Public endpoints (such as browsing subjects or logging in) do not require a token.
Obtaining a token
Send aPOST request to /api/auth/login with your credentials in the request body.
user object and a signed JWT:
role field is either "user" or "admin". Store the token value — you will need it for all authenticated requests.
Token format and validity
The token is a signed JWT containing the payload{ id, role }. It is signed with the server’s JWT_SECRET environment variable and expires after 7 days.
Making authenticated requests
Include the token in theAuthorization header as a Bearer token on every request that requires authentication:
Authorization: Bearer <token>. The server extracts the token from the second segment after splitting on a space.
Error responses
Missing or invalid token — 401
If noAuthorization header is present, or the token cannot be verified, the server returns 401:
Insufficient role — 403
If you send a valid token but your account does not have theadmin role, and you attempt to access an admin-only endpoint, the server returns 403:
GET /api/users, DELETE /api/users/:id), all score reporting across users, and all POST, PUT, and DELETE operations on subjects, chapters, quizzes, and questions.
User not found — 404
If the token is valid but the user record has been deleted from the database since the token was issued, the server returns404:
Summary
Log in to get a token
Send your credentials to
POST /api/auth/login and copy the token from the response.Attach the token to requests
Add
Authorization: Bearer <token> to the headers of any authenticated request.