Complete API documentation for FocusMaster backend endpoints.
Base URL: http://localhost:5000/api (development)
Production URL: https://your-production-url.vercel.app/api
All protected endpoints require a JWT token in cookies or Authorization header.
POST /api/auth/registerRequest Body:
{
"name": "John Doe",
"email": "john@example.com",
"password": "securePassword123"
}Response: 201 Created
{
"_id": "507f1f77bcf86cd799439011",
"name": "John Doe",
"email": "john@example.com",
"role": "user",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}POST /api/auth/loginRequest Body:
{
"email": "john@example.com",
"password": "securePassword123"
}Response: 200 OK
POST /api/auth/googleRequest Body:
{
"credential": "google_id_token_here"
}GET /api/auth/me
Authorization: Bearer <token>Response: 200 OK
{
"_id": "507f1f77bcf86cd799439011",
"name": "John Doe",
"email": "john@example.com",
"picture": "https://example.com/avatar.jpg",
"points": 150,
"settings": {
"theme": "dark",
"focusDuration": 25,
"shortBreakDuration": 5
}
}Manage Pomodoro sessions for tracking work and breaks.
POST /api/sessions
Authorization: Bearer <token>Request Body:
{
"type": "focus",
"startTime": "2026-02-02T10:00:00Z",
"endTime": "2026-02-02T10:25:00Z",
"duration": 1500,
"task": "507f1f77bcf86cd799439011",
"mood": "focused"
}Response: 201 Created
GET /api/sessions?range=week
Authorization: Bearer <token>Query Parameters:
range(optional):today|week|month
Response: 200 OK
[
{
"_id": "507f1f77bcf86cd799439011",
"type": "focus",
"startTime": "2026-02-02T10:00:00Z",
"endTime": "2026-02-02T10:25:00Z",
"duration": 1500,
"task": {
"_id": "507f1f77bcf86cd799439012",
"title": "Write documentation"
},
"mood": "focused",
"completed": true
}
]GET /api/sessions/:id
Authorization: Bearer <token>Response: 200 OK
PATCH /api/sessions/:id
Authorization: Bearer <token>Request Body:
{
"mood": "happy",
"duration": 1800
}Response: 200 OK
DELETE /api/sessions/:id
Authorization: Bearer <token>Response: 200 OK
{
"message": "Session deleted successfully"
}GET /api/sessions/stats
Authorization: Bearer <token>Response: 200 OK
{
"totalFocusTime": 18000,
"totalSessions": 12
}Manage tasks in the Kanban board.
POST /api/tasks
Authorization: Bearer <token>Request Body:
{
"title": "Implement feature X",
"description": "Add new authentication flow",
"status": "todo",
"priority": "high",
"tags": ["backend", "auth"],
"estimatedPomodoros": 4
}GET /api/tasks
Authorization: Bearer <token>Response: 200 OK
PUT /api/tasks/:id
Authorization: Bearer <token>DELETE /api/tasks/:id
Authorization: Bearer <token>Clock in/out for time tracking.
POST /api/clock/start
Authorization: Bearer <token>Response: 201 Created
{
"_id": "507f1f77bcf86cd799439011",
"startTime": "2026-02-02T09:00:00Z",
"user": "507f1f77bcf86cd799439010"
}POST /api/clock/stop
Authorization: Bearer <token>Request Body:
{
"breakTime": 300,
"notes": "Productive day"
}GET /api/clock/logs
Authorization: Bearer <token>Get productivity analytics and statistics.
GET /api/analytics/productivity?range=week
Authorization: Bearer <token>Query Parameters:
range:today|week|month
Response: 200 OK
{
"totalFocusTime": 18000,
"totalSessions": 12,
"averageSessionDuration": 1500,
"dailyBreakdown": [
{
"date": "2026-02-02",
"focusTime": 3600,
"sessions": 3
}
]
}Spotify integration for music control.
GET /api/spotify/auth-url
Authorization: Bearer <token>GET /api/spotify/callback?code=<code>GET /api/spotify/now-playing
Authorization: Bearer <token>POST /api/spotify/play
POST /api/spotify/pause
POST /api/spotify/next
POST /api/spotify/previous
Authorization: Bearer <token>Admin panel endpoints (requires admin role).
GET /api/admin/users
Authorization: Bearer <admin_token>PATCH /api/admin/users/:id/role
Authorization: Bearer <admin_token>Request Body:
{
"role": "admin"
}PATCH /api/admin/users/:id/ban
Authorization: Bearer <admin_token>Request Body:
{
"reason": "Violation of terms"
}GET /api/admin/audit-logs
Authorization: Bearer <admin_token>User feedback submission.
POST /api/feedback
Authorization: Bearer <token>Request Body:
{
"type": "bug",
"message": "Found an issue with the timer",
"category": "timer"
}All endpoints may return the following error responses:
{
"message": "Invalid input data"
}{
"message": "Not authorized, token failed"
}{
"message": "Access denied"
}{
"message": "Resource not found"
}{
"message": "Server error"
}API endpoints are rate-limited to prevent abuse:
- Guest users: 100 requests/hour
- Authenticated users: 1000 requests/hour
- Admin users: 5000 requests/hour