How authentication works
When you log in, the system issues two tokens:- Access token: A short-lived JWT token used to authenticate API requests
- Refresh token: A longer-lived token stored in the database that you can use to obtain new access tokens
Access tokens are stateless and contain user claims. The system automatically cleans up expired refresh tokens to maintain database health.
Register a new account
You can create a new user account by sending your details to the registration endpoint.Send registration request
Make a POST request to
/api/auth/register with your account details:Your password must be at least 8 characters long. Names must be between 2 and 50 characters and can contain letters, spaces, periods, hyphens, and apostrophes.
Registration requirements
- Email: Must be a valid email address format
- Password: Minimum 8 characters
- First name: 2-50 characters, letters and common name characters only
- Last name: 2-50 characters, letters and common name characters only
Log in to your account
Authenticate with your credentials to receive access and refresh tokens.Make authenticated requests
Once you have an access token, include it in the Authorization header of your API requests.Refresh your access token
When your access token expires, use your refresh token to obtain a new one without logging in again.Your refresh token remains valid and doesn’t change during the refresh operation. Only the access token is renewed.
Log out
When you’re done with your session, log out to invalidate your refresh token.Token invalidation
The system removes your refresh token from the database, preventing it from being used to generate new access tokens.
Common authentication errors
You may encounter these errors when working with authentication:- Invalid credentials: Your email or password is incorrect
- Expired access token: Use your refresh token to obtain a new access token
- Invalid refresh token: The refresh token doesn’t exist or has been revoked—log in again
- Email already exists: This email is already registered—use a different email or log in instead
The system includes automatic cleanup of expired refresh tokens to maintain optimal performance.