Authentication API
Manage user authentication, including sign-up, login, password recovery, and token management.
Sign Up
Create a new user account with email and password.
Endpoint: POST /auth/signup
Authentication: None (Public)
Request Body:
{
"email": "user@example.com",
"password": "securePassword123",
"firstName": "John",
"lastName": "Doe"
}
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | Yes | User's email address | |
| password | string | Yes | Password (must be at least 8 characters) |
| firstName | string | Yes | User's first name |
| lastName | string | Yes | User's last name |
Response:
{
"success": true,
"statusCode": 200,
"data": {
"uid": "user_id_123",
"email": "user@example.com",
"token": "jwt_token_here"
},
"error": null
}
Error Responses:
400- Invalid email format or password too weak409- Email already exists
Login
Authenticate a user and retrieve JWT token.
Endpoint: POST /auth/login
Authentication: None (Public)
Request Body:
{
"email": "user@example.com",
"password": "securePassword123"
}
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | Yes | User's email address | |
| password | string | Yes | User's password |
Response:
{
"success": true,
"statusCode": 200,
"data": {
"uid": "user_id_123",
"email": "user@example.com",
"token": "jwt_token_here"
},
"error": null
}
Error Responses:
400- Missing email or password401- Invalid credentials
Send Password Reset Email
Request a password reset email for a user account.
Endpoint: POST /auth/forgotPassword
Authentication: None (Public)
Request Body:
{
"email": "user@example.com"
}
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | Yes | Email address associated with account |
Response:
{
"success": true,
"statusCode": 200,
"data": null,
"error": null
}
Error Responses:
400- Invalid email format404- User not found
Verify Email
Verify user's email address with OTP or token.
Endpoint: POST /auth/verifyEmail
Authentication: Firebase Auth
Request Body:
{
"code": "123456"
}
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| code | string | Yes | OTP code sent to email |
Response:
{
"success": true,
"statusCode": 200,
"data": {
"verified": true
},
"error": null
}
Error Responses:
400- Invalid or expired code401- Unauthorized
Change Password
Change the password for authenticated user.
Endpoint: POST /auth/changePassword
Authentication: Firebase Auth
Request Body:
{
"oldPassword": "currentPassword123",
"newPassword": "newPassword456"
}
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| oldPassword | string | Yes | Current password |
| newPassword | string | Yes | New password (must be different from old) |
Response:
{
"success": true,
"statusCode": 200,
"data": {
"message": "Password updated successfully"
},
"error": null
}
Error Responses:
400- Password validation failed401- Incorrect current password
Verify Phone Number
Verify user's phone number with OTP.
Endpoint: POST /auth/verifyPhone
Authentication: Firebase Auth
Request Body:
{
"phone": "+14155552671",
"code": "123456"
}
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| phone | string | Yes | Phone number in E.164 format |
| code | string | Yes | OTP code sent to phone |
Response:
{
"success": true,
"statusCode": 200,
"data": {
"verified": true
},
"error": null
}
Error Responses:
400- Invalid phone format or OTP401- Unauthorized
Request Phone Verification
Send OTP to user's phone number.
Endpoint: POST /auth/requestPhoneVerification
Authentication: Firebase Auth
Request Body:
{
"phone": "+14155552671"
}
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| phone | string | Yes | Phone number in E.164 format |
Response:
{
"success": true,
"statusCode": 200,
"data": {
"message": "OTP sent to phone"
},
"error": null
}
Error Responses:
400- Invalid phone format429- Too many requests
Refresh Token
Get a new JWT token using current authentication.
Endpoint: POST /auth/refreshToken
Authentication: Firebase Auth
Request Body:
{}
Response:
{
"success": true,
"statusCode": 200,
"data": {
"token": "new_jwt_token_here"
},
"error": null
}
Error Responses:
401- Unauthorized
Logout
Invalidate the current session/token.
Endpoint: POST /auth/logout
Authentication: Firebase Auth
Request Body:
{}
Response:
{
"success": true,
"statusCode": 200,
"data": {
"message": "Logged out successfully"
},
"error": null
}
Error Responses:
401- Unauthorized