Introduction
The MoodSync API is a robust platform for developing mental health applications that empower users to track emotional well-being and enable professionals to detect and respond to potential crises. Built on Laravel with Sanctum authentication, it provides endpoints for user registration (POST /api/register
), login (POST /api/login
), mood tracking (POST /api/mood-entries
), and admin crisis management (GET /api/admin/crises
). A sophisticated crisis detection system identifies risks by analyzing user inactivity (e.g., sudden cessation of logging after consistent use) and crisis-related keywords in notes (e.g., "hopeless," "want to die"), triggering alerts for professional intervention.
Real-World Impact
- Proactive Crisis Detection: Automatically flags high-risk situations when users stop logging moods after consistent activity or include alarming keywords in notes, enabling timely intervention to prevent escalation.
- Emotional Self-Awareness: Users log daily moods (e.g., happy, sad) with intensity and notes, gaining insights into emotional patterns to manage mental health.
- Professional Intervention: Admins and clinicians access HIPAA-compliant dashboards to monitor crisis alerts and patient progress, ensuring effective care delivery.
- Scalable Mental Health Solutions: Developers integrate secure mood tracking, AI-driven analytics, and personalized recommendations, addressing global mental health challenges.
This API serves:
- Users: Individuals monitoring their mental health.
- Admins/Professionals: Mental health experts responding to crises.
- Developers: Teams building innovative mental health apps.
Developed by Abdallah Khattab.
See the Getting Started section below for usage instructions.
Getting Started
The MoodSync API enables developers to create mental health applications with secure mood tracking and advanced crisis detection. Built with Laravel and Sanctum, it offers endpoints for user authentication, mood logging, and admin crisis management. The crisis detection system monitors user inactivity (e.g., no mood entries after consistent logging) and scans notes for keywords like "hopeless" or "want to die," triggering alerts for professionals. Most endpoints require a Bearer token, and admin-only endpoints (e.g., http://localhost/api/admin/crises
) require an admin
role. This API addresses real-world mental health challenges by promoting self-awareness, enabling early crisis intervention, and supporting professional care.
Authentication
Authenticate using Laravel Sanctum to access protected endpoints:
-
Register or Log In:
- Use
POST http://localhost/api/register
to create a user account and receive a Bearer token. - Use
POST http://localhost/api/login
to authenticate and obtain a token. - Example login request:
curl -X POST http://localhost/api/login \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{"email": "[email protected]", "password": "password123"}'
- The response includes a token (e.g.,
1|abcdef1234567890
).
- Use
-
Use the Token:
- Include the token in the
Authorization
header:Authorization: Bearer 1|abcdef1234567890
- Example authenticated request:
curl -X POST http://localhost/api/mood-entries \ -H "Authorization: Bearer 1|abcdef1234567890" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{"mood": "sad", "intensity": 8, "notes": "Feeling hopeless today"}'
- Include the token in the
-
Admin Access:
- Admin endpoints (e.g.,
GET http://localhost/api/admin/crises
) require anadmin
role. - admin credentials email:[email protected] password:password
- Admin endpoints (e.g.,
Real-World Applications
- Crisis Detection: Alerts are triggered when users stop logging after consistent activity (2+ days of inactivity after 5+ entries in 14 days) or include crisis keywords in notes, enabling rapid professional response.
- Mood Tracking: Users log daily emotions, fostering self-awareness and identifying patterns to improve mental health.
- Professional Tools: Clinicians use secure dashboards to monitor alerts and patient moods, enhancing care delivery.
- Analytics & Recommendations: Developers integrate AI-driven insights and personalized wellness suggestions, increasing user engagement.
Testing Endpoints
- Use the "Try It Out" feature to test endpoints interactively.
- Enter your Bearer token for authenticated endpoints.
- Ensure CORS is enabled for origins like
http://127.0.0.1:8000
orhttp://localhost:8000
. Check server configuration if CORS errors occur.
Warning
Explore the endpoint sections below for detailed usage.
Authenticating requests
This API is not authenticated.
Admin Management
APIs for managing users and their mood data, accessible only by admin users. to access these endpoints login in with these credentials email:"[email protected]" password:"password"
Get users overview
requires authentication
Retrieves an overview of all users with their recent mood entries (up to 5 per user) and mood entry counts.
Example request:
curl --request GET \
--get "https://nawasrah.site/moodsync/api/admin/users" \
--header "Authorization: Bearer {token} Example: Bearer 1|abcdef1234567890" \
--header "Content-Type: application/json" \
--header "Accept: application/json"
const url = new URL(
"https://nawasrah.site/moodsync/api/admin/users"
);
const headers = {
"Authorization": "Bearer {token} Example: Bearer 1|abcdef1234567890",
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "GET",
headers,
}).then(response => response.json());
Example response (200):
{
"success": true,
"data": {
"data": [
{
"id": 1,
"name": "John Doe",
"email": "[email protected]",
"mood_entries_count": 10,
"recent_mood_entries": [
{
"id": 1,
"mood": "happy",
"intensity": 7,
"notes": "Feeling great today!",
"date": "2025-06-12"
}
]
}
]
},
"message": "Users overview fetched successfully"
}
Example response (401):
{
"success": false,
"data": [],
"message": "Unauthenticated",
"status": 401
}
Example response (403):
{
"success": false,
"data": [],
"message": "Unauthorized: Admin role required",
"status": 403
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Get user details
requires authentication
Retrieves detailed information about a specific user, including their mood entries and admin notes, filtered by month and year if provided.
Example request:
curl --request GET \
--get "https://nawasrah.site/moodsync/api/admin/users/1?month=6&year=2025" \
--header "Authorization: Bearer {token} Example: Bearer 1|abcdef1234567890" \
--header "Content-Type: application/json" \
--header "Accept: application/json"
const url = new URL(
"https://nawasrah.site/moodsync/api/admin/users/1"
);
const params = {
"month": "6",
"year": "2025",
};
Object.keys(params)
.forEach(key => url.searchParams.append(key, params[key]));
const headers = {
"Authorization": "Bearer {token} Example: Bearer 1|abcdef1234567890",
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "GET",
headers,
}).then(response => response.json());
Example response (200):
{
"success": true,
"data": {
"user": {
"id": 1,
"name": "John Doe",
"email": "[email protected]",
"role": "user",
"mood_entries": [
{
"id": 1,
"mood": "sad",
"intensity": 8,
"notes": "Feeling hopeless",
"date": "2025-06-12"
}
],
"admin_notes": [
{
"id": 1,
"note": "User reported low mood.",
"user_id": 1,
"admin_id": 2,
"created_at": "2025-06-12 17:16:00"
}
]
},
"stats": {
"total_entries": 5,
"mood_distribution": {
"sad": 3,
"happy": 2
},
"average_intensity": 7.2,
"most_common_mood": "sad",
"recommendations": [
"🌷 It's okay to feel sad sometimes. Consider reaching out to loved ones or doing something comforting."
]
}
},
"message": "User details fetched successfully"
}
Example response (401):
{
"success": false,
"data": [],
"message": "Unauthenticated",
"status": 401
}
Example response (403):
{
"success": false,
"data": [],
"message": "Unauthorized: Admin role required",
"status": 403
}
Example response (404):
{
"success": false,
"data": [],
"message": "No data found for the selected month/year.",
"status": 404
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Add a note for a user
requires authentication
Allows an admin to add a note for a specific user.
Example request:
curl --request POST \
"https://nawasrah.site/moodsync/api/admin/users/architecto/notes" \
--header "Authorization: Bearer {token} Example: Bearer 1|abcdef1234567890" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{
\"note\": \"User reported low mood.\"
}"
const url = new URL(
"https://nawasrah.site/moodsync/api/admin/users/architecto/notes"
);
const headers = {
"Authorization": "Bearer {token} Example: Bearer 1|abcdef1234567890",
"Content-Type": "application/json",
"Accept": "application/json",
};
let body = {
"note": "User reported low mood."
};
fetch(url, {
method: "POST",
headers,
body: JSON.stringify(body),
}).then(response => response.json());
Example response (200):
{
"success": true,
"data": {
"data": {
"id": 1,
"note": "User reported low mood.",
"user_id": 1,
"admin_id": 2,
"created_at": "2025-06-12 17:16:00",
"admin": {
"id": 2,
"name": "Admin User",
"email": "[email protected]"
}
}
},
"message": "Note added successfully"
}
Example response (401):
{
"success": false,
"data": [],
"message": "Unauthenticated",
"status": 401
}
Example response (403):
{
"success": false,
"data": [],
"message": "Unauthorized: Admin role required",
"status": 403
}
Example response (422):
{
"success": false,
"data": {
"errors": {
"note": [
"The note field is required."
]
}
},
"message": "Validation failed",
"status": 422
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Authentication
APIs for user authentication and token management.
Register a new user
Creates a new user account and returns a Sanctum token.
Example request:
curl --request POST \
"https://nawasrah.site/moodsync/api/register" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{
\"name\": \"John Doe\",
\"email\": \"[email protected]\",
\"password\": \"Password123\",
\"password_confirmation\": \"Password123\"
}"
const url = new URL(
"https://nawasrah.site/moodsync/api/register"
);
const headers = {
"Content-Type": "application/json",
"Accept": "application/json",
};
let body = {
"name": "John Doe",
"email": "[email protected]",
"password": "Password123",
"password_confirmation": "Password123"
};
fetch(url, {
method: "POST",
headers,
body: JSON.stringify(body),
}).then(response => response.json());
Example response (201):
{
"success": true,
"data": {
"user": {
"id": 1,
"name": "John Doe",
"email": "[email protected]",
"created_at": "2025-06-12T17:16:00.000000Z",
"updated_at": "2025-06-12T17:16:00.000000Z"
},
"token": "1|abcdef1234567890",
"token_type": "Bearer"
},
"message": "User Registered successfully"
}
Example response (422):
{
"success": false,
"data": {
"errors": {
"email": [
"The email field is required."
]
}
},
"message": "Validation failed",
"status": 422
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Log in a user if you want login as admin use these credintials => email = "[email protected]" => password = "password" Authenticates a user and returns a Sanctum token.
Example request:
curl --request POST \
"https://nawasrah.site/moodsync/api/login" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{
\"email\": \"[email protected]\",
\"password\": \"Password123\"
}"
const url = new URL(
"https://nawasrah.site/moodsync/api/login"
);
const headers = {
"Content-Type": "application/json",
"Accept": "application/json",
};
let body = {
"email": "[email protected]",
"password": "Password123"
};
fetch(url, {
method: "POST",
headers,
body: JSON.stringify(body),
}).then(response => response.json());
Example response (200):
{
"success": true,
"data": {
"user": {
"id": 1,
"name": "John Doe",
"email": "[email protected]",
"created_at": "2025-06-12T17:16:00.000000Z",
"updated_at": "2025-06-12T17:16:00.000000Z"
},
"token": "2|xyz1234567890",
"token_type": "Bearer"
},
"message": "Login successful"
}
Example response (401):
{
"success": false,
"data": [],
"message": "Invalid credentials",
"status": 401
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Log out the current session
requires authentication
Revokes the current access token, logging out the user from the current session.
Example request:
curl --request POST \
"https://nawasrah.site/moodsync/api/logout" \
--header "Authorization: Bearer {token} Example: Bearer 1|abcdef1234567890" \
--header "Content-Type: application/json" \
--header "Accept: application/json"
const url = new URL(
"https://nawasrah.site/moodsync/api/logout"
);
const headers = {
"Authorization": "Bearer {token} Example: Bearer 1|abcdef1234567890",
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "POST",
headers,
}).then(response => response.json());
Example response (200):
{
"success": true,
"data": [],
"message": "Successfully logged out"
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Log out from all devices
requires authentication
Revokes all access tokens for the authenticated user, logging them out from all devices.
Example request:
curl --request POST \
"https://nawasrah.site/moodsync/api/logout-all" \
--header "Authorization: Bearer {token} Example: Bearer 1|abcdef1234567890" \
--header "Content-Type: application/json" \
--header "Accept: application/json"
const url = new URL(
"https://nawasrah.site/moodsync/api/logout-all"
);
const headers = {
"Authorization": "Bearer {token} Example: Bearer 1|abcdef1234567890",
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "POST",
headers,
}).then(response => response.json());
Example response (200):
{
"success": true,
"data": [],
"message": "Successfully logged out from all devices"
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Get user tokens
requires authentication
Returns a list of active tokens for the authenticated user.
Example request:
curl --request GET \
--get "https://nawasrah.site/moodsync/api/tokens" \
--header "Authorization: Bearer {token} Example: Bearer 1|abcdef1234567890" \
--header "Content-Type: application/json" \
--header "Accept: application/json"
const url = new URL(
"https://nawasrah.site/moodsync/api/tokens"
);
const headers = {
"Authorization": "Bearer {token} Example: Bearer 1|abcdef1234567890",
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "GET",
headers,
}).then(response => response.json());
Example response (200):
{
"success": true,
"data": {
"tokens": [
{
"id": 1,
"name": "auth_token",
"created_at": "2025-06-12T17:16:00.000000Z"
},
{
"id": 2,
"name": "auth_token",
"created_at": "2025-06-12T17:17:00.000000Z"
}
]
},
"message": ""
}
Example response (401):
{
"success": false,
"data": [],
"message": "Unauthenticated",
"status": 401
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Revoke a specific token
requires authentication
Revokes a specific token by its ID for the authenticated user.
Example request:
curl --request DELETE \
"https://nawasrah.site/moodsync/api/tokens/architecto" \
--header "Authorization: Bearer {token} Example: Bearer 1|abcdef1234567890" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{
\"token_id\": 1
}"
const url = new URL(
"https://nawasrah.site/moodsync/api/tokens/architecto"
);
const headers = {
"Authorization": "Bearer {token} Example: Bearer 1|abcdef1234567890",
"Content-Type": "application/json",
"Accept": "application/json",
};
let body = {
"token_id": 1
};
fetch(url, {
method: "DELETE",
headers,
body: JSON.stringify(body),
}).then(response => response.json());
Example response (200):
{
"success": true,
"data": [],
"message": "Token revoked successfully"
}
Example response (404):
{
"success": false,
"data": {
"message": "Token not found"
},
"message": "Token not found",
"status": 404
}
Example response (422):
{
"success": false,
"data": {
"errors": {
"token_id": [
"The token_id field is required."
]
}
},
"message": "Validation failed",
"status": 422
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Crisis Management
APIs for managing crisis alerts. These endpoints are restricted to admin users.
Get active crisis alerts
requires authentication
Retrieves all active crisis alerts, sorted by crisis level and triggered date.
Example request:
curl --request GET \
--get "https://nawasrah.site/moodsync/api/admin/crises" \
--header "Authorization: Bearer {token} Example: Bearer 1|abcdef1234567890" \
--header "Content-Type: application/json" \
--header "Accept: application/json"
const url = new URL(
"https://nawasrah.site/moodsync/api/admin/crises"
);
const headers = {
"Authorization": "Bearer {token} Example: Bearer 1|abcdef1234567890",
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "GET",
headers,
}).then(response => response.json());
Example response (200):
{
"success": true,
"data": {
"data": [
{
"id": 1,
"user_id": 1,
"mood_entry_id": 1,
"crisis_level": 5,
"status": "active",
"triggered_at": "2025-06-12T17:16:00.000000Z",
"keywords_found": [
"hopeless",
"want to die"
],
"context": {
"consecutive_negative_days": 3,
"mood_decline": true,
"recent_entries": []
},
"user": {
"id": 1,
"name": "John Doe",
"email": "[email protected]"
},
"mood_entry": {
"id": 1,
"mood": "sad",
"intensity": 8,
"notes": "Feeling hopeless and want to die",
"date": "2025-06-12"
}
}
]
},
"message": "Crises retrieved successfully"
}
Example response (401):
{
"success": false,
"data": [],
"message": "Unauthenticated",
"status": 401
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Get responded crisis alerts
requires authentication
Retrieves all crisis alerts that have been responded to, sorted by crisis level and triggered date.
Example request:
curl --request GET \
--get "https://nawasrah.site/moodsync/api/admin/crises/responded" \
--header "Authorization: Bearer {token} Example: Bearer 1|abcdef1234567890" \
--header "Content-Type: application/json" \
--header "Accept: application/json"
const url = new URL(
"https://nawasrah.site/moodsync/api/admin/crises/responded"
);
const headers = {
"Authorization": "Bearer {token} Example: Bearer 1|abcdef1234567890",
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "GET",
headers,
}).then(response => response.json());
Example response (200):
{
"success": true,
"data": {
"data": [
{
"id": 2,
"user_id": 1,
"mood_entry_id": 2,
"crisis_level": 4,
"status": "responded",
"triggered_at": "2025-06-11T14:00:00.000000Z",
"keywords_found": [
"I’m alone"
],
"context": {
"consecutive_negative_days": 2,
"mood_decline": false,
"recent_entries": []
},
"user": {
"id": 1,
"name": "John Doe",
"email": "[email protected]"
},
"mood_entry": {
"id": 2,
"mood": "anxious",
"intensity": 7,
"notes": "I’m alone and overwhelmed",
"date": "2025-06-11"
}
}
]
},
"message": "Crises retrieved successfully"
}
Example response (401):
{
"success": false,
"data": [],
"message": "Unauthenticated",
"status": 401
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Get resolved crisis alerts
requires authentication
Retrieves all resolved crisis alerts, sorted by crisis level and triggered date.
Example request:
curl --request GET \
--get "https://nawasrah.site/moodsync/api/admin/crises/resolved" \
--header "Authorization: Bearer {token} Example: Bearer 1|abcdef1234567890" \
--header "Content-Type: application/json" \
--header "Accept: application/json"
const url = new URL(
"https://nawasrah.site/moodsync/api/admin/crises/resolved"
);
const headers = {
"Authorization": "Bearer {token} Example: Bearer 1|abcdef1234567890",
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "GET",
headers,
}).then(response => response.json());
Example response (200):
{
"success": true,
"data": {
"data": [
{
"id": 4,
"user_id": 1,
"mood_entry_id": 4,
"crisis_level": 4,
"status": "resolved",
"triggered_at": "2025-06-09T08:00:00.000000Z",
"keywords_found": [
"hopeless"
],
"context": {
"consecutive_negative_days": 2,
"mood_decline": true,
"recent_entries": []
},
"user": {
"id": 1,
"name": "John Doe",
"email": "[email protected]"
},
"mood_entry": {
"id": 4,
"mood": "sad",
"intensity": 9,
"notes": "Feeling hopeless",
"date": "2025-06-09"
}
}
]
},
"message": "Crises retrieved successfully"
}
Example response (401):
{
"success": false,
"data": [],
"message": "Unauthenticated",
"status": 401
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Respond to a crisis alert
requires authentication
Records a response to a specific crisis alert, updating its status to 'responded' and logging the response time.
Example request:
curl --request POST \
"https://nawasrah.site/moodsync/api/admin/crises/1/respond" \
--header "Authorization: Bearer {token} Example: Bearer 1|abcdef1234567890" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{
\"response\": \"Contacted user and provided support.\",
\"action_taken\": \"Referred to counselor.\"
}"
const url = new URL(
"https://nawasrah.site/moodsync/api/admin/crises/1/respond"
);
const headers = {
"Authorization": "Bearer {token} Example: Bearer 1|abcdef1234567890",
"Content-Type": "application/json",
"Accept": "application/json",
};
let body = {
"response": "Contacted user and provided support.",
"action_taken": "Referred to counselor."
};
fetch(url, {
method: "POST",
headers,
body: JSON.stringify(body),
}).then(response => response.json());
Example response (200):
{
"success": true,
"data": {
"data": 30
},
"message": "Crisis response recorded"
}
Example response (401):
{
"success": false,
"data": [],
"message": "Unauthenticated",
"status": 401
}
Example response (404):
{
"success": false,
"data": [],
"message": "Crisis alert not found",
"status": 404
}
Example response (422):
{
"success": false,
"data": {
"errors": {
"response": [
"The response field is required."
],
"action_taken": [
"The action taken field is required."
]
}
},
"message": "Validation failed",
"status": 422
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Endpoints
POST api/forgot-password
Example request:
curl --request POST \
"https://nawasrah.site/moodsync/api/forgot-password" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{
\"email\": \"[email protected]\"
}"
const url = new URL(
"https://nawasrah.site/moodsync/api/forgot-password"
);
const headers = {
"Content-Type": "application/json",
"Accept": "application/json",
};
let body = {
"email": "[email protected]"
};
fetch(url, {
method: "POST",
headers,
body: JSON.stringify(body),
}).then(response => response.json());
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
POST api/reset-password
Example request:
curl --request POST \
"https://nawasrah.site/moodsync/api/reset-password" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{
\"token\": \"architecto\",
\"email\": \"[email protected]\",
\"password\": \"-0pBNvYgxw\"
}"
const url = new URL(
"https://nawasrah.site/moodsync/api/reset-password"
);
const headers = {
"Content-Type": "application/json",
"Accept": "application/json",
};
let body = {
"token": "architecto",
"email": "[email protected]",
"password": "-0pBNvYgxw"
};
fetch(url, {
method: "POST",
headers,
body: JSON.stringify(body),
}).then(response => response.json());
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
GET api/user
Example request:
curl --request GET \
--get "https://nawasrah.site/moodsync/api/user" \
--header "Content-Type: application/json" \
--header "Accept: application/json"
const url = new URL(
"https://nawasrah.site/moodsync/api/user"
);
const headers = {
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "GET",
headers,
}).then(response => response.json());
Example response (404):
Show headers
cache-control: no-cache, private
content-type: application/json
{
"message": "The route moodsync/api/user could not be found."
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Mood Entries
APIs for managing user mood entries and retrieving mood statistics.
Create a mood entry
requires authentication
Stores a new mood entry for the authenticated user. If a mood entry already exists for the given date, an error is returned.
Example request:
curl --request POST \
"https://nawasrah.site/moodsync/api/mood-entries" \
--header "Authorization: Bearer {token} Example: Bearer 1|abcdef1234567890" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{
\"mood\": \"happy\",
\"intensity\": 5,
\"notes\": \"Feeling optimistic today.\",
\"date\": \"2025-06-12\"
}"
const url = new URL(
"https://nawasrah.site/moodsync/api/mood-entries"
);
const headers = {
"Authorization": "Bearer {token} Example: Bearer 1|abcdef1234567890",
"Content-Type": "application/json",
"Accept": "application/json",
};
let body = {
"mood": "happy",
"intensity": 5,
"notes": "Feeling optimistic today.",
"date": "2025-06-12"
};
fetch(url, {
method: "POST",
headers,
body: JSON.stringify(body),
}).then(response => response.json());
Example response (201):
{
"success": true,
"data": {
"data": {
"id": 1,
"mood": "happy",
"note": "Feeling optimistic today.",
"date": "2025-06-12",
"created_at": "2025-06-12T17:16:00.000000Z"
}
},
"message": "Mood entry created successfully"
}
Example response (400):
{
"success": false,
"data": [],
"message": "You have already logged your mood for this date",
"status": 400
}
Example response (401):
{
"success": false,
"data": [],
"message": "Unauthenticated",
"status": 401
}
Example response (422):
{
"success": false,
"data": {
"errors": {
"mood": [
"The mood field is required."
],
"intensity": [
"The intensity must be between 1 and 10."
]
}
},
"message": "Validation failed",
"status": 422
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Get monthly mood statistics
requires authentication
Retrieves mood statistics for the authenticated user for a specific month and year.
Example request:
curl --request GET \
--get "https://nawasrah.site/moodsync/api/mood-entries/monthly-stats?month=6&year=2025" \
--header "Authorization: Bearer {token} Example: Bearer 1|abcdef1234567890" \
--header "Content-Type: application/json" \
--header "Accept: application/json"
const url = new URL(
"https://nawasrah.site/moodsync/api/mood-entries/monthly-stats"
);
const params = {
"month": "6",
"year": "2025",
};
Object.keys(params)
.forEach(key => url.searchParams.append(key, params[key]));
const headers = {
"Authorization": "Bearer {token} Example: Bearer 1|abcdef1234567890",
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "GET",
headers,
}).then(response => response.json());
Example response (200):
{
"success": true,
"data": {
"data": {
"total_entries": 10,
"mood_counts": {
"happy": 4,
"sad": 2,
"neutral": 3,
"calm": 1
},
"average_intensity": 4.5
}
},
"message": "Monthly stats retrieved successfully"
}
Example response (401):
{
"success": false,
"data": [],
"message": "Unauthenticated",
"status": 401
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.