Complete backend API documentation for the resume optimization platform
AI-powered resume optimization with authentication, payments, and credit management
All authentication endpoints now use a secure token rotation system with short-lived access tokens (30 minutes) and long-lived refresh tokens (7 days). The frontend automatically handles token refresh to provide seamless user experience while maintaining security.
Tests Firebase API key validity and configuration
No parameters required
{ "success": true, "message": "API key is valid", "projectId": "tailor-my-resume-c90bb" }
Creates a new user account with email verification
Parameter | Type | Required | Description |
---|---|---|---|
string | Required | User's email address | |
password | string | Required | User's password (min 6 characters) |
displayName | string | Optional | User's display name |
marketingConsent | boolean | Optional | Marketing email consent (default: false) |
{ "success": true, "user": { "email": "user@example.com", "displayName": "John Doe", "emailVerified": false }, "accessToken": "short_lived_access_token_30min", "refreshToken": "long_lived_refresh_token_7days", "expiresIn": 1800, "message": "Account created successfully! Please check your email..." }
Token Rotation & User ID Protection:
Authenticates user with email and password
Parameter | Type | Required | Description |
---|---|---|---|
string | Required | User's email address | |
password | string | Required | User's password |
{ "success": true, "user": { "email": "user@example.com", "displayName": "John Doe" }, "accessToken": "short_lived_access_token_30min", "refreshToken": "long_lived_refresh_token_7days", "expiresIn": 1800 }
Token Rotation & User ID Protection:
Sends password reset email to user
Parameter | Type | Required | Description |
---|---|---|---|
string | Required | User's email address |
{ "success": true, "message": "Password reset email sent. Please check your inbox." }
Verifies user email using verification code from email link
Parameter | Type | Required | Description |
---|---|---|---|
oobCode | string | Required | Verification code from email link |
{ "success": true, "message": "Email verified successfully! You can now sign in.", "user": { "email": "user@example.com", "emailVerified": true } }
User ID Protection:
Resends email verification to user
Parameter | Type | Required | Description |
---|---|---|---|
string | Required | User's email address |
{ "success": true, "message": "Verification email sent! Please check your inbox..." }
Checks email verification status for a user
Parameter | Type | Required | Description |
---|---|---|---|
string | Required | User's email address (URL encoded) |
{ "success": true, "emailVerified": true }
This endpoint has been hardened for security:
Retrieves user data from Firebase Auth and Firestore
Bearer Token: Must include valid Firebase ID token in Authorization header
Authorization: Users can only access their own data
Header | Type | Required | Description |
---|---|---|---|
Authorization | string | Required | Bearer {access_token} |
Parameter | Type | Required | Description |
---|---|---|---|
userId | string | Required | Firebase user ID (must match authenticated user) |
{ "success": true, "user": { "email": "user@example.com", "displayName": "John Doe", "emailVerified": true, "subscription": { "status": "free", "creditsPurchased": 360, "stripeCustomerId": "cus_123" }, "usage": { "creditsUsed": 30, "lastOptimization": "2024-01-15T10:30:00Z" } } }
Access Token & User ID Protection:
Refresh access token using a valid refresh token
Parameter | Type | Required | Description |
---|---|---|---|
refreshToken | string | Required | Valid refresh token (7-day expiry) |
userAgent | string | Optional | Browser user agent for security tracking |
{ "success": true, "accessToken": "new_short_lived_access_token", "refreshToken": "new_refresh_token", "expiresIn": 1800 }
Logout user and invalidate refresh token
Parameter | Type | Required | Description |
---|---|---|---|
refreshToken | string | Required | Refresh token to invalidate |
{ "success": true, "message": "Logged out successfully" }
Revoke all refresh tokens for a user (sign out from all devices)
Bearer Token: Must include valid access token in Authorization header
Header | Type | Required | Description |
---|---|---|---|
Authorization | string | Required | Bearer {access_token} |
{ "success": true, "message": "Signed out from 3 devices", "revokedTokens": 3 }
Retrieves current credit balance for a user
Parameter | Type | Required | Description |
---|---|---|---|
userId | string | Required | Firebase user ID |
{ "userId": "user123", "credits": 330, "timestamp": "2024-01-15T10:30:00.123Z" }
Creates Stripe checkout session for credit purchase
Parameter | Type | Required | Description |
---|---|---|---|
packageType | string | Required | Package type: "starter", "professional", or "premium" |
userId | string | Required | Firebase user ID |
userEmail | string | Required | User's email address |
{ "sessionId": "cs_test_123...", "url": "https://checkout.stripe.com/pay/cs_test_123..." }
Verifies payment success status for a checkout session
Parameter | Type | Required | Description |
---|---|---|---|
sessionId | string | Required | Stripe checkout session ID |
{ "success": true, "status": "paid", "userId": "user123", "credits": 360, "packageType": "starter" }
Creates Stripe customer portal session for billing management
Parameter | Type | Required | Description |
---|---|---|---|
userEmail | string | Required | User's email address |
{ "url": "https://billing.stripe.com/p/session/..." }
Stripe webhook endpoint for payment events (checkout completion, payment failures)
Header | Type | Required | Description |
---|---|---|---|
stripe-signature | string | Required | Stripe webhook signature for verification |
{ "received": true }
Retrieves available credit packages and pricing
No parameters required
{ "starter": { "name": "Quick Glow", "credits": 360, "price": 499, "description": "Perfect for landing that dream job (Apply 1-20 jobs)" }, "professional": { "name": "Job Hunter Pack", "credits": 1200, "price": 999, "description": "Dominate your job search (Apply 20-40 jobs)" }, "premium": { "name": "Enterprise Pack", "credits": 0, "price": 0, "description": "Custom volume for your organization (Contact for pricing)" } }
Retrieves Stripe publishable key for client-side integration
No parameters required
{ "publishableKey": "pk_test_..." }
Health check endpoint that tests AI provider availability (DeepSeek API or Claude CLI)
No parameters required
{ "status": "healthy", "provider": "deepseek", "message": "DeepSeek API is available", "timestamp": "2024-01-15T10:30:00.123Z" }
{ "status": "healthy", "provider": "claude-cli", "message": "Claude CLI is available", "timestamp": "2024-01-15T10:30:00.123Z" }
Main AI optimization endpoint - processes resume optimization requests using DeepSeek API or Claude CLI
Bearer Token: Must include valid Firebase ID token in Authorization header
User ID: Extracted automatically from authenticated token
Header | Type | Required | Description |
---|---|---|---|
Authorization | string | Required | Bearer {access_token} |
Parameter | Type | Required | Description |
---|---|---|---|
prompt | string | Required | Resume and job description text for optimization |
{ "prompt": "System prompt + user input", "response": "{\"optimizedResume\": \"# John Doe\\n\\n## Professional Summary\\n...\", \"matchScore\": 85, \"keywordsAdded\": [\"Python\", \"React\"], \"missingSkills\": [\"Docker\"], \"atsTips\": [\"Use standard headings\"], \"recommendations\": [\"Add Docker experience\"], \"changes\": [{\"original\": \"Developed apps\", \"optimized\": \"Developed Python applications\", \"reason\": \"Added keyword specificity\"}]}", "provider": "deepseek" }
// Missing Bearer token { "success": false, "error": "Access token required. Please provide Bearer token in Authorization header." } // Invalid/expired token { "success": false, "error": "Token has expired. Please sign in again." } // Insufficient credits { "error": "Insufficient credits", "required": 30, "available": 15 } // API configuration error { "error": "Configuration error: DeepSeek API key not set", "response": "Execution error", "provider": "deepseek" } // User not found { "error": "User not found" }
The AI response is a JSON string containing:
This API has been hardened against common security vulnerabilities including user enumeration attacks, brute force attempts, and abuse. All authentication endpoints are protected with rate limiting.
All authentication and user management endpoints are protected by IP-based rate limiting to prevent abuse and attacks.
Endpoint | Limit | Window | Protection Level |
---|---|---|---|
POST /auth/signup | 5 requests | 15 minutes | Strict - Anti-spam |
POST /auth/signin | 10 requests | 15 minutes | Strict - Anti-brute force |
POST /auth/reset-password | 3 requests | 15 minutes | Very Strict - Anti-flooding |
POST /auth/resend-verification | 5 requests | 15 minutes | Strict - Anti-flooding |
POST /auth/verify-email | 10 requests | 5 minutes | Moderate - Short window |
GET /auth/verify-status/:email | 20 requests | 15 minutes | Moderate - Anti-enumeration |
GET /auth/user/:userId | 30 requests | 15 minutes | Light - User data access |
GET /api/user/:userId/credits | 30 requests | 15 minutes | Light - Credit balance |
POST /api/verify-payment | 20 requests | 15 minutes | Moderate - Payment verification |
GET /auth/test-api-key | 10 requests | 15 minutes | Light - API testing |
When rate limiting is active, the following headers are included in responses:
Security-related error responses you may encounter when rate limits are exceeded or security violations are detected.
{ "success": false, "error": "Too many authentication attempts. Please try again in 15 minutes.", "retryAfter": 900 }
The /auth/verify-status/:email
endpoint has been hardened to prevent user enumeration attacks:
// Secure response (current implementation) { "success": true, "emailVerified": true } // ❌ Previous vulnerable response (removed) { "success": true, "emailVerified": true, "uid": "user123", // REMOVED - security risk "email": "user@..." // REMOVED - security risk }
Status Code | Error Type | Description | Action Required |
---|---|---|---|
429 | Rate Limited | Too many requests in time window | Wait for window to reset |
400 | Bad Request | Invalid or missing parameters | Check request format |
404 | Not Found | User/resource not found (minimal info) | Verify user exists |
401 | Unauthorized | Authentication required or failed | Provide valid credentials |
Default Port: 5000 (configurable via PORT environment variable)
AI Provider: DeepSeek API (fallback to Claude CLI)
Authentication: Firebase Auth with custom REST API integration
Database: Firestore for user data and credit management
Payments: Stripe Checkout with webhook processing
Logging: JSON lines format to claude_logs.jsonl