/api/auth prefix. None of the endpoints in this group require an existing valid session — they are the entry points for establishing one.
The
refreshToken is stored as an HttpOnly cookie after a successful login. The accessToken returned in the JSON body should be stored in memory (not localStorage) and passed as a Bearer token on subsequent requests.POST /api/auth/register
Begin the registration flow. Sends a one-time password to the provided email address. The user record is not created until OTP verification succeeds. Auth required: NoRequest body
Full display name for the new account.
Email address. Must be unique across all accounts.
Plain-text password. Hashed before storage. Not required when using Google login.
Account role. One of
freelancer or client. The admin role cannot be self-registered.Optional phone number.
Response
Confirmation that the OTP was sent to the provided email.
cURL
POST /api/auth/verify-otp
Verify the OTP and create the user account. Call this immediately after/register.
Auth required: No
Request body
The email address used during registration.
The six-digit code sent to the email address.
The same registration payload originally submitted to
/register.Response
Confirmation that the account was created successfully.
cURL
POST /api/auth/resend-otp
Request a new OTP for the given email address. Use this when the original code expires or is not received. Auth required: NoRequest body
Email address that was used during registration.
Response
Confirmation that a new OTP was dispatched.
cURL
POST /api/auth/login
Authenticate with email and password. On success, sets anHttpOnly refreshToken cookie and returns a short-lived accessToken in the response body.
Auth required: No
Request body
Registered email address.
Account password.
Response
Human-readable status message.
Short-lived JWT. Pass this in the
Authorization: Bearer header on protected requests.Role of the authenticated user:
freelancer, client, or admin.cURL
POST /api/auth/logout
Clear therefreshToken cookie, ending the session.
Auth required: No (cookie is cleared regardless)
Response
Confirmation of successful logout.
cURL
POST /api/auth/refresh-token
Issue a newaccessToken using the refreshToken cookie. Call this when the current access token expires (after 2 hours).
Auth required: No (uses the refreshToken cookie)
Request
No request body. The server reads therefreshToken from the HttpOnly cookie automatically.
Response
A new short-lived JWT access token.
The browser must include credentials (cookies) for this request. In
fetch, set credentials: "include". In axios, set withCredentials: true.cURL
POST /api/auth/google-login
Authenticate or register using a Google OAuth ID token. If the email is not yet registered, a new account is created automatically. Auth required: NoRequest body
Google OAuth ID token obtained from the Google Sign-In SDK.
Role to assign if a new account is being created. One of
freelancer or client. Ignored for returning users.Response
Same shape as POST /api/auth/login:message, accessToken, role, and user. The refreshToken cookie is also set.
cURL
POST /api/auth/forgot-password
Send a password-reset link to the registered email address. The link contains a short-lived signed token. Auth required: NoRequest body
Email address associated with the account.
Response
Confirmation that the reset email was dispatched.
cURL
POST /api/auth/update-new-password
Complete the forgot-password flow by submitting the reset token and a new password. The token is extracted from the link sent by/forgot-password.
Auth required: No
Request body
The signed reset token from the password-reset email link.
The new plain-text password to set.
Must match
newPassword. The server validates equality before updating.Response
Confirmation that the password was updated.
cURL
POST /api/auth/reset-password
Change the password for a logged-in user who knows their current password. Use this for in-app password changes, not forgotten passwords. Auth required: No (validated by supplying the correctcurrentPassword)
Request body
Email address of the account.
The user’s existing password. Must match the stored hash.
The replacement password.
Must match
newPassword.Response
Confirmation that the password was changed.
cURL
