The API uses JWT (JSON Web Token) bearer authentication. Obtain a token by registering or logging in, then include it in theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Danielsl4/TFG_DAM_2526_Consulta/llms.txt
Use this file to discover all available pages before exploring further.
Authorization header on every request to a protected endpoint.
Authentication flow
Create an account or log in
Call
POST /register to create a new account, or POST /login if you already have one. Both endpoints return a JWT on success.Verify your email
After registering, check your inbox and click the verification link. Your account must be verified before you can log in.
Token expiry
Token lifetime depends on the account role:| Role | Expiry |
|---|---|
admin | 6 hours |
referee | 6 hours |
user | 7 days |
/login again to obtain a fresh one.
Authorization middleware
| Middleware | Behaviour |
|---|---|
verifyToken | Required on protected routes. Returns 401 if no token is provided or the token is invalid/expired. |
optionalVerifyToken | Used on public routes that behave differently when a user is authenticated. Proceeds even if no token is supplied. |
verifyAdmin | Requires role: admin. Returns 403 otherwise. |
verifyReferee | Requires role: referee or role: admin. Returns 403 otherwise. |
verifyMatchLock | Requires that the caller holds the lock on a match, or that the lock is expired. Returns 409 if another user holds an active lock. |
Endpoints
POST /register
Create a new user account. A verification email is sent automatically. The account must be verified before the user can log in.Request body
Unique username. Checked case- and accent-insensitively.
Unique email address. Checked case-insensitively.
Plain-text password. Stored as a bcrypt hash (cost 10).
Responses
Confirmation that the account was created and that a verification email has been sent.
| Status | Cause |
|---|---|
201 | Account created |
400 | Missing username, email, or password |
409 | Username or email already taken |
500 | Server error |
POST /login
Authenticate with a username (or email) and password. Returns a signed JWT on success.The
username field accepts either a username or an email address.Request body
The account’s username or email address. Matched case- and accent-insensitively.
The account password.
Responses
A signed JWT. Include this value as
Authorization: Bearer <token> on subsequent requests.| Status | Cause |
|---|---|
200 | Login successful |
400 | Missing username or password |
401 | Wrong credentials |
403 | Account is inactive or email is not yet verified |
500 | Server error |
Example
login
use the token
POST /forgot-password
Request a password-reset link by email. For security, the response is always a success message regardless of whether the email is registered.The reset link sent to the user’s inbox expires after 15 minutes.
Request body
The email address associated with the account.
Responses
A generic confirmation message. Returned even if the email is not found.
| Status | Cause |
|---|---|
200 | Request processed (email may or may not have been sent) |
400 | Missing email |
500 | Server error or mail delivery failure |
POST /reset-password
Set a new password using the token from the password-reset email.Request body
The reset token from the emailed link. Valid for 15 minutes.
The new plain-text password to set.
Responses
Confirmation that the password was updated.
| Status | Cause |
|---|---|
200 | Password updated — { "message": "Contraseña actualizada correctamente." } |
400 | Missing fields, or the token is invalid or has expired |
500 | Server error |
POST /resend-verification
Resend the account verification email. Provide eitheremail or username.
Request body
Email address of the unverified account.
Username of the unverified account.
At least one of
email or username is required.Responses
Confirmation that the verification email was resent.
| Status | Cause |
|---|---|
200 | Verification email sent |
400 | Neither email nor username provided, or account is already verified |
404 | No account found for the given email or username |
500 | Server error or mail delivery failure |
GET /verify-email/:token
Verify an account using the token from the verification email. On success, the account is activated and a JWT is returned for automatic login.Path parameters
The verification token from the emailed link.
Responses
Confirmation that the account was verified.
A signed JWT — the same format returned by
/login. Use it to authenticate subsequent requests without requiring a separate login step.| Status | Cause |
|---|---|
200 | Account verified and JWT returned |
400 | Token is invalid or account is already verified |
500 | Account verified but JWT generation failed |