Complete API documentation for the FL Auth Service.
- Production:
https://your-production-api-gateway-url/auth - Development:
https://your-development-api-gateway-url/auth
All endpoints are prefixed with /auth.
Most endpoints require a valid JWT access token in the request body or header.
Token Types:
- Access Token: 30-minute lifetime, used for authentication
- Refresh Token: 7-day lifetime, used to obtain new access tokens
{
"message": "Operation successful",
"statusCode": 200,
"requestId": "unique-request-id-for-tracing",
"data": { ... }
}{
"error": "Human-readable error message",
"statusCode": 400,
"requestId": "unique-request-id-for-tracing",
"additionalField": "optional context"
}| Code | Meaning | When Used |
|---|---|---|
200 |
OK | Request successful |
201 |
Created | Resource created (signup) |
400 |
Bad Request | Invalid input data |
401 |
Unauthorized | Invalid credentials, expired token, or password not set |
404 |
Not Found | Resource doesn't exist |
409 |
Conflict | Resource already exists (email taken) |
500 |
Server Error | Internal error |
Create a new user account.
Endpoint: POST /auth/signup
Request:
{
"email": "user@example.com",
"password": "SecurePass123!",
"firstName": "John",
"lastName": "Doe"
}Validation Rules:
email: Valid email format, unique (not already registered)password: Minimum 8 charactersfirstName: Required, stringlastName: Optional, string
Success Response (201):
{
"message": "Signup successful",
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"email": "user@example.com",
"firstName": "John",
"lastName": "Doe"
}
}Error Responses:
-
400 Bad Request: Missing or invalid fields{ "error": "Invalid email address", "statusCode": 400 } -
409 Conflict: Email already registered{ "error": "Email already registered", "statusCode": 409 }
Side Effects:
- Creates
Member:Usernode in Neo4j - Updates
createdAttimestamp - Sends welcome email (async)
Authenticate user and obtain tokens.
Endpoint: POST /auth/login
Request:
{
"email": "user@example.com",
"password": "SecurePass123!"
}Success Response (200):
{
"message": "Login successful",
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"email": "user@example.com",
"firstName": "John"
}
}Error Responses:
-
400 Bad Request: Missing fields{ "error": "Email is required", "statusCode": 400 } -
401 Unauthorized: Invalid credentials{ "error": "Invalid email or password", "statusCode": 401 } -
401 Unauthorized: Password not set (migrated user){ "error": "Password not set. Please use 'Forgot Password' to set up your password.", "statusCode": 401, "requiresPasswordSetup": true }
Side Effects:
- Updates
lastLoginAttimestamp - Returns tokens valid for future requests
Verify that an access token is still valid.
Endpoint: POST /auth/verify
Request:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}Success Response (200):
{
"message": "Token is valid",
"user": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"email": "user@example.com",
"firstName": "John"
},
"expiresAt": 1234567890
}Error Responses:
401 Unauthorized: Invalid or expired token{ "error": "Invalid or expired token", "statusCode": 401 }
Obtain a new access token using refresh token.
Endpoint: POST /auth/refresh-token
Request:
{
"refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}Success Response (200):
{
"message": "Token refreshed",
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}Error Responses:
401 Unauthorized: Invalid or expired refresh token{ "error": "Invalid or expired refresh token", "statusCode": 401 }
Set password for users who haven't set one yet (migrated users).
Endpoint: POST /auth/setup-password
Request:
{
"email": "user@example.com",
"token": "setup-token-received",
"password": "NewSecurePass123!"
}Validation:
email: Must match registered emailpassword: Minimum 8 characters
Success Response (200):
{
"message": "Password set successfully"
}Error Responses:
-
400 Bad Request: Missing fields{ "error": "Email is required", "statusCode": 400 } -
404 Not Found: User not found or password already set{ "error": "User not found or password already set", "statusCode": 404 }
Side Effects:
- Updates
passwordfield (was NULL) - Updates
updatedAttimestamp - Sends password setup confirmation email
Change an existing password (requires current password verification).
Endpoint: POST /auth/reset-password
Request:
{
"email": "user@example.com",
"currentPassword": "CurrentPass123!",
"newPassword": "NewSecurePass123!"
}Validation:
email: Must match registered emailcurrentPassword: Must be correctnewPassword: Minimum 8 characters, must differ from current
Success Response (200):
{
"message": "Password changed successfully"
}Error Responses:
-
401 Unauthorized: Wrong current password{ "error": "Current password is incorrect", "statusCode": 401 } -
404 Not Found: User not found{ "error": "User not found", "statusCode": 404 }
Side Effects:
- Updates
passwordfield - Updates
updatedAttimestamp - Sends password reset confirmation email
- Doesn't invalidate existing tokens
Permanently delete a user account (requires password verification).
Endpoint: DELETE /auth/account
Request:
{
"email": "user@example.com",
"password": "CurrentPass123!"
}Success Response (200):
{
"message": "Account deleted successfully"
}Error Responses:
-
401 Unauthorized: Wrong password{ "error": "Password is incorrect", "statusCode": 401 } -
404 Not Found: User not found{ "error": "User not found", "statusCode": 404 }
Side Effects:
- Permanently deletes user node from database
- Sends account deletion confirmation email
- Invalidates all tokens
- Irreversible - data cannot be recovered
Signup:
curl -X POST https://api-url/auth/signup \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "SecurePass123!",
"firstName": "John"
}'Login:
curl -X POST https://api-url/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "SecurePass123!"
}'Verify Token:
curl -X POST https://api-url/auth/verify \
-H "Content-Type: application/json" \
-d '{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}'// Signup
const response = await fetch('https://api-url/auth/signup', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
email: 'user@example.com',
password: 'SecurePass123!',
firstName: 'John'
})
})
const data = await response.json()
console.log(data.accessToken) // Store this
console.log(data.refreshToken) // Store this (secure)- Expires in: 30 minutes
- Use for: Authenticating API requests
- Refresh with: Refresh token
- Expires in: 7 days
- Use for: Getting new access tokens
- Cannot refresh: Refresh tokens (expired ones can't be renewed)
Secure practices:
// ✅ Access token: Can be in localStorage or sessionStorage
localStorage.setItem('accessToken', data.accessToken)
// ✅ Refresh token: Should be in httpOnly cookie (most secure)
// Server sets via Set-Cookie header
// httpOnly: true // Can't be accessed by JavaScript
// Or in secure sessionStorage if localStorage not available
sessionStorage.setItem('refreshToken', data.refreshToken)In JSON body:
{
"token": "access-token-here",
"data": { ... }
}In Authorization header:
Authorization: Bearer access-token-here
401 Unauthorized (Invalid Token):
- Token signature invalid
- Token expired
- Token format incorrect
Handling in client:
try {
const response = await api.call()
} catch (error) {
if (error.status === 401) {
// Try to refresh token
const newToken = await refreshAccessToken(refreshToken)
// Retry request with new token
}
}409 Conflict (Email Exists):
- User tries to signup with registered email
- Should check email availability first
Handling in client:
if (error.status === 409) {
alert('Email already registered. Try logging in instead.')
}No explicit rate limiting is configured, but AWS Lambda has:
- Default concurrency: 1,000 concurrent executions
- Default throttling: Returns 429 if exceeded
For production, consider adding rate limiting middleware.
CORS is enabled for:
- Origin:
*(all origins) - Methods: GET, POST, PUT, DELETE
- Headers: Content-Type, Authorization
- Getting Started - Local development
- Architecture Overview - System design
- Deployment Guide - Deploy to AWS
See Also:
- JWT.io - Token format
- HTTP Status Codes