CV Optimizer KE exposes a set of REST API endpoints for CV analysis, authentication, and M-Pesa payment processing.
All endpoints are relative to this base URL. All requests and responses use JSON.
All protected endpoints require an active Supabase session cookie. Authentication is handled via Supabase Auth โ users must be signed in through the app before making API requests.
โ ๏ธ Requests without a valid session will return 401 Unauthorized
/api/analyze๐ Requires authAnalyzes a CV against a job description using Groq AI (Llama 3.3 70B). Returns ATS score, match score, missing keywords, rewritten summary, and interview tips. First analysis is free. Subsequent analyses require payment.
{
"cvBase64": "string", // Base64-encoded PDF file (required)
"jobDescription": "string", // Full job description text (required)
"jobTitle": "string", // Job title for history (optional)
"paid": "boolean" // true if user has paid (default: false)
}{
"result": {
"ats_score": 84,
"match_score": 91,
"readability_score": 78,
"missing_keywords": ["React.js", "Docker", "Agile"],
"found_keywords": ["Python", "SQL", "Git"],
"rewritten_summary": "Experienced software developer...",
"weak_sections": "Work experience section lacks quantifiable achievements...",
"interview_tips": "Prepare to discuss your Python projects..."
}
}/api/mpesa/initiate๐ Requires authInitiates an M-Pesa STK Push payment request to the user's phone via Safaricom Daraja API. The user receives a payment prompt on their phone and enters their M-Pesa PIN to complete the transaction.
{
"phone": "0712345678", // Kenyan phone number (required)
"amount": 200 // Amount in KES (required)
}{
"success": true,
"data": {
"MerchantRequestID": "29115-34620561-1",
"CheckoutRequestID": "ws_CO_271012022...",
"ResponseCode": "0",
"ResponseDescription": "Success. Request accepted for processing",
"CustomerMessage": "Success. Request accepted for processing"
}
}/api/mpesa/callback๐ Public โ Safaricom onlyWebhook endpoint called by Safaricom after payment is completed or failed. Updates the payment status in the database and credits the user with a paid analysis. This endpoint is public and called automatically by Safaricom.
{
"Body": {
"stkCallback": {
"ResultCode": 0,
"ResultDesc": "The service request is processed successfully.",
"CallbackMetadata": {
"Item": [
{ "Name": "Amount", "Value": 200 },
{ "Name": "MpesaReceiptNumber", "Value": "NLJ7RT61SV" },
{ "Name": "PhoneNumber", "Value": 254712345678 }
]
}
}
}
}โน๏ธ ResultCode 0 = success. Any other code = payment failed or cancelled.
/api/admin/stats๐ Admin onlyReturns platform-wide statistics including total users, analyses, payments, and revenue. Also returns recent users, analyses, and payments. Only accessible by users with is_admin = true.
{
"stats": {
"total_users": 42,
"total_analyses": 128,
"total_payments": 35,
"total_revenue": 7000
},
"recentUsers": [...],
"recentAnalyses": [...],
"recentPayments": [...],
"dailyAnalyses": [...]
}CV Optimizer KE ยท Built in Kenya ๐ฐ๐ช ยท 2026