Skip to main content
POST
Login

Endpoint

Base URL: http://localhost:3000/api/v1
This endpoint is public and does not require authentication.

Request Body

string
required
User’s registered email address (works for both job seekers and companies).
string
required
User’s password. Minimum 6 characters.

Request Shape

Response

Success Response (200 OK)

TypeScript Types

For Job Seeker

For Company

boolean
Indicates if the login was successful.
object
Contains the user/company data and access token.
string
Human-readable success message.
object
Request metadata from global response interceptor.
The refresh token is automatically set as an HTTP-only cookie named refreshToken. You must use credentials: 'include' in your fetch requests to enable cookie handling.
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: 24 hours (86400 seconds)

What Happens on Login

1

User Lookup

System searches for user in both JobSeeker and Company tables
2

Email Verification Check

Verifies that the user’s email has been verified
3

Password Validation

Compares provided password with hashed password using bcrypt
4

Token Generation

Generates new JWT access and refresh tokens
5

Refresh Token Storage

Stores refresh token in Redis and sets HTTP-only cookie
6

Response

Returns user data with access token

Error Responses

400 Bad Request - Validation Error

Returned when request validation fails.

401 Unauthorized - Invalid Credentials

Returned when email or password is incorrect.
Possible causes:
  • Email doesn’t exist
  • Password is incorrect
  • Typo in email or password

401 Unauthorized - Email Not Verified

Returned when user hasn’t verified their email yet.
Solution: Verify email using the OTP sent during registration with the Verify Email endpoint.

500 Internal Server Error

Returned when an unexpected error occurs.

Validation Rules

Security Notes

Automatic User Type Detection: The API automatically detects whether you’re logging in as a job seeker or company based on the email. You don’t need to specify the user type.
Cookie Credentials: Always use credentials: 'include' in your fetch requests to enable cookie handling for the refresh token.

Response Types