Verify Email
Authentication
Verify Email
Verify email address with OTP code
POST
Verify Email
Endpoint
http://localhost:3000/api/v1
This endpoint is public and does not require authentication.
Request Body
string
required
The email address to verify (must match the registered email).
string
required
The 6-digit OTP code sent to the email. Must be exactly 6 numeric digits.
Request Shape
Response
Success Response (200 OK)
TypeScript Types
For Job Seeker
For Company
boolean
Indicates if the verification was successful.
object
Contains the complete user/company data and access token.
string
Success message: “Email verified successfully. You are now logged in.”
object
Request metadata from global response interceptor.
Important: Refresh Token Cookie
The server sets a cookie with these properties:- Name:
refreshToken - HttpOnly:
true(cannot be accessed via JavaScript) - Secure:
true(in production, requires HTTPS) - SameSite:
Strict - Max-Age: 86400 seconds (24 hours)
credentials: 'include'.
What Happens on Verification
1
OTP Validation
System verifies the OTP code against the stored value in Redis.
2
User Type Detection
System determines if the user is a Job Seeker or Company based on stored OTP data.
3
Email Status Update
User’s
isVerified field is set to true in the database.4
Login Timestamp Update
For job seekers,
lastLoginAt is updated to current timestamp.5
OTP Deletion
Used OTP is immediately deleted from Redis.
6
Token Generation
New JWT access and refresh tokens are generated.
7
Refresh Token Storage
Refresh token is stored in Redis with 24-hour expiration and set as HTTP-only cookie.
8
User Logged In
User is now authenticated and can access protected endpoints.
Error Responses
400 Bad Request - Validation Error
Returned when request validation fails.Invalid email format- Email is not in valid formatOTP must be exactly 6 digits- Code is not exactly 6 charactersOTP must contain only numbers- Code contains non-numeric characters
401 Unauthorized - Invalid OTP
Returned when OTP is incorrect or expired.- OTP code is incorrect
- OTP has expired (10 minutes validity)
- OTP was already used
- Email doesn’t match registration email
- OTP was never generated for this email
401 Unauthorized - User Not Found
Returned when no user exists with the provided email.401 Unauthorized - Verification Failed
Generic error for other verification issues.Error responses follow the global API envelope:
success: false and an error object containing
message, statusCode, timestamp, path, method, and details.Validation Rules
OTP Behavior
OTP Validity: Each OTP is valid for 10 minutes from generation. After expiration, users need
to request a new code (feature in development).
After Verification
Once email is verified, the user:- ✅ Is automatically logged in
- ✅ Receives access token (1 hour validity)
- ✅ Has refresh token stored in HTTP-only cookie (24 hours validity)
- ✅ Can access all protected endpoints
- ✅ Can login normally without re-verification
- ✅ Has
isVerified: truein their account
Related Endpoints
- Register Job Seeker - Create job seeker account
- Register Company - Create company account
- Login - Login after verification
- Refresh Token - Get new access token
