Base URL: http://localhost:3001/api
All endpoints require authentication. Include the session cookie in requests after signing in.
POST /auth/sign-up/email
Creates a new user account.
Request Body:
{
"name": "John Doe",
"email": "john@example.com",
"password": "password123"
}Response (200):
{
"user": {
"id": "user_id",
"name": "John Doe",
"email": "john@example.com"
},
"session": {
"token": "session_token",
"expiresAt": "2025-11-28T23:00:00.000Z"
}
}POST /auth/sign-in/email
Authenticates an existing user.
Request Body:
{
"email": "john@example.com",
"password": "password123"
}Response (200):
{
"user": {
"id": "user_id",
"name": "John Doe",
"email": "john@example.com"
},
"session": {
"token": "session_token",
"expiresAt": "2025-11-28T23:00:00.000Z"
}
}POST /auth/sign-out
Signs out the current user.
Response (200):
{
"success": true
}POST /device
Registers a new device or updates an existing one. If a device with the same deviceToken exists for the user, it will be updated instead of creating a new one.
Request Body:
{
"deviceName": "Samsung Galaxy S23",
"deviceToken": "fcm_token_here",
"deviceModel": "SM-S911B",
"osVersion": "Android 14",
"appVersion": "1.0.0"
}Response (200):
{
"device": {
"id": "device_id",
"userId": "user_id",
"deviceName": "Samsung Galaxy S23",
"deviceToken": "fcm_token_here",
"deviceModel": "SM-S911B",
"osVersion": "Android 14",
"appVersion": "1.0.0",
"lastActiveAt": "2025-10-29T00:00:00.000Z",
"createdAt": "2025-10-29T00:00:00.000Z",
"updatedAt": "2025-10-29T00:00:00.000Z"
},
"message": "Device registered successfully"
}GET /device?deviceToken=fcm_token_here
Checks if a specific device is registered for the current user.
Query Parameters:
deviceToken(required): The device token to check
Response (200):
{
"exists": true,
"device": {
"id": "device_id",
"userId": "user_id",
"deviceName": "Samsung Galaxy S23",
"deviceToken": "fcm_token_here",
"deviceModel": "SM-S911B",
"osVersion": "Android 14",
"appVersion": "1.0.0",
"lastActiveAt": "2025-10-29T00:00:00.000Z",
"createdAt": "2025-10-29T00:00:00.000Z",
"updatedAt": "2025-10-29T00:00:00.000Z"
}
}GET /device
Gets all devices registered for the current user.
Response (200):
{
"devices": [
{
"id": "device_id",
"userId": "user_id",
"deviceName": "Samsung Galaxy S23",
"deviceToken": "fcm_token_here",
"deviceModel": "SM-S911B",
"osVersion": "Android 14",
"appVersion": "1.0.0",
"lastActiveAt": "2025-10-29T00:00:00.000Z",
"createdAt": "2025-10-29T00:00:00.000Z",
"updatedAt": "2025-10-29T00:00:00.000Z"
}
]
}PATCH /device
Updates device information.
Request Body:
{
"deviceId": "device_id",
"deviceName": "Samsung Galaxy S23 Ultra",
"appVersion": "1.0.1"
}Response (200):
{
"device": {
"id": "device_id",
"userId": "user_id",
"deviceName": "Samsung Galaxy S23 Ultra",
"deviceToken": "fcm_token_here",
"deviceModel": "SM-S911B",
"osVersion": "Android 14",
"appVersion": "1.0.1",
"lastActiveAt": "2025-10-29T00:00:00.000Z",
"createdAt": "2025-10-29T00:00:00.000Z",
"updatedAt": "2025-10-29T00:00:00.000Z"
},
"message": "Device updated successfully"
}GET /medicine
Gets all medicines for the current user.
Query Parameters:
activeOnly(optional): Set totrueto only get active medicines
Response (200):
{
"medicines": [
{
"id": "medicine_id",
"userId": "user_id",
"name": "Aspirin",
"dosage": "100mg",
"frequency": "daily",
"time": "08:00,20:00",
"startDate": "2025-10-29T00:00:00.000Z",
"endDate": "2025-11-29T00:00:00.000Z",
"notes": "Take with food",
"isActive": "true",
"reminderEnabled": "true",
"createdAt": "2025-10-29T00:00:00.000Z",
"updatedAt": "2025-10-29T00:00:00.000Z"
}
]
}POST /medicine
Creates a new medicine reminder.
Request Body:
{
"name": "Aspirin",
"dosage": "100mg",
"frequency": "daily",
"time": "08:00,20:00",
"startDate": "2025-10-29",
"endDate": "2025-11-29",
"notes": "Take with food",
"reminderEnabled": true
}Field Descriptions:
name(required): Medicine namedosage(required): Dosage amount (e.g., "100mg", "2 tablets")frequency(required): How often to take (e.g., "daily", "twice daily", "weekly")time(required): Time(s) to take medicine. Use comma-separated for multiple times (e.g., "08:00" or "08:00,14:00,20:00")startDate(required): When to start taking the medicine (ISO date string)endDate(optional): When to stop taking the medicine (ISO date string)notes(optional): Additional notesreminderEnabled(optional): Enable/disable reminders (default: true)
Response (200):
{
"medicine": {
"id": "medicine_id",
"userId": "user_id",
"name": "Aspirin",
"dosage": "100mg",
"frequency": "daily",
"time": "08:00,20:00",
"startDate": "2025-10-29T00:00:00.000Z",
"endDate": "2025-11-29T00:00:00.000Z",
"notes": "Take with food",
"isActive": "true",
"reminderEnabled": "true",
"createdAt": "2025-10-29T00:00:00.000Z",
"updatedAt": "2025-10-29T00:00:00.000Z"
},
"message": "Medicine created successfully"
}GET /medicine/:id
Gets a specific medicine by ID.
Response (200):
{
"medicine": {
"id": "medicine_id",
"userId": "user_id",
"name": "Aspirin",
"dosage": "100mg",
"frequency": "daily",
"time": "08:00,20:00",
"startDate": "2025-10-29T00:00:00.000Z",
"endDate": "2025-11-29T00:00:00.000Z",
"notes": "Take with food",
"isActive": "true",
"reminderEnabled": "true",
"createdAt": "2025-10-29T00:00:00.000Z",
"updatedAt": "2025-10-29T00:00:00.000Z"
}
}PATCH /medicine/:id
Updates a medicine. All fields are optional.
Request Body:
{
"name": "Aspirin 100mg",
"dosage": "150mg",
"frequency": "twice daily",
"time": "08:00,20:00",
"notes": "Take with water",
"isActive": true,
"reminderEnabled": false
}Response (200):
{
"medicine": {
"id": "medicine_id",
"userId": "user_id",
"name": "Aspirin 100mg",
"dosage": "150mg",
"frequency": "twice daily",
"time": "08:00,20:00",
"startDate": "2025-10-29T00:00:00.000Z",
"endDate": "2025-11-29T00:00:00.000Z",
"notes": "Take with water",
"isActive": "true",
"reminderEnabled": "false",
"createdAt": "2025-10-29T00:00:00.000Z",
"updatedAt": "2025-10-29T00:00:00.000Z"
},
"message": "Medicine updated successfully"
}DELETE /medicine/:id
Deletes a medicine.
Response (200):
{
"message": "Medicine deleted successfully"
}Emergency actions are triggered when a medicine reminder is missed or requires immediate attention.
GET /emergency-action
Gets all emergency actions for the current user, ordered by priority (1 is highest).
Response (200):
{
"actions": [
{
"id": "action_id",
"userId": "user_id",
"actionType": "call",
"actionData": "+1234567890",
"priority": 1,
"isEnabled": "true",
"createdAt": "2025-10-29T00:00:00.000Z",
"updatedAt": "2025-10-29T00:00:00.000Z"
},
{
"id": "action_id_2",
"userId": "user_id",
"actionType": "alarm",
"actionData": "emergency_alarm.mp3",
"priority": 2,
"isEnabled": "true",
"createdAt": "2025-10-29T00:00:00.000Z",
"updatedAt": "2025-10-29T00:00:00.000Z"
}
]
}POST /emergency-action
Creates a new emergency action.
Request Body:
{
"actionType": "call",
"actionData": "+1234567890",
"priority": 1,
"isEnabled": true
}Action Types and Data:
call:actionDatashould be a phone number (e.g., "+1234567890")message:actionDatashould be a phone number to send SMS to (e.g., "+1234567890")alarm:actionDatashould be the alarm sound identifier or file path (e.g., "emergency_alarm.mp3")
Field Descriptions:
actionType(required): Type of action - "call", "message", or "alarm"actionData(required): Data for the action (phone number or alarm sound)priority(optional): Priority level (1 is highest, default: 1)isEnabled(optional): Enable/disable this action (default: true)
Response (200):
{
"action": {
"id": "action_id",
"userId": "user_id",
"actionType": "call",
"actionData": "+1234567890",
"priority": 1,
"isEnabled": "true",
"createdAt": "2025-10-29T00:00:00.000Z",
"updatedAt": "2025-10-29T00:00:00.000Z"
},
"message": "Emergency action created successfully"
}GET /emergency-action/:id
Gets a specific emergency action by ID.
Response (200):
{
"action": {
"id": "action_id",
"userId": "user_id",
"actionType": "call",
"actionData": "+1234567890",
"priority": 1,
"isEnabled": "true",
"createdAt": "2025-10-29T00:00:00.000Z",
"updatedAt": "2025-10-29T00:00:00.000Z"
}
}PATCH /emergency-action/:id
Updates an emergency action. All fields are optional.
Request Body:
{
"actionType": "message",
"actionData": "+0987654321",
"priority": 2,
"isEnabled": false
}Response (200):
{
"action": {
"id": "action_id",
"userId": "user_id",
"actionType": "message",
"actionData": "+0987654321",
"priority": 2,
"isEnabled": "false",
"createdAt": "2025-10-29T00:00:00.000Z",
"updatedAt": "2025-10-29T00:00:00.000Z"
},
"message": "Emergency action updated successfully"
}DELETE /emergency-action/:id
Deletes an emergency action.
Response (200):
{
"message": "Emergency action deleted successfully"
}All endpoints may return the following error responses:
{
"error": "Unauthorized"
}{
"error": "Error message describing what's wrong"
}{
"error": "Resource not found"
}{
"error": "Error message"
}- User signs up or signs in
- Register the device with FCM token
- Set up emergency actions (at least one recommended)
- User creates medicine reminders with dosage, frequency, and times
- App schedules local notifications based on medicine times
- When medicine is taken, log it (you can implement a medicine log endpoint if needed)
- Set up emergency actions in priority order
- When a medicine reminder is missed or critical, trigger emergency actions
- Execute actions based on priority (call, message, or alarm)
- Periodically sync medicine list and emergency actions
- Update device
lastActiveAttimestamp - Handle offline scenarios with local caching
id: Unique identifieruserId: Owner user IDdeviceName: Device name (e.g., "Samsung Galaxy S23")deviceToken: FCM/push notification tokendeviceModel: Device modelosVersion: OS versionappVersion: App versionlastActiveAt: Last time device was activecreatedAt,updatedAt: Timestamps
id: Unique identifieruserId: Owner user IDname: Medicine namedosage: Dosage amountfrequency: How often to taketime: Time(s) to take (comma-separated for multiple)startDate: Start dateendDate: End date (optional)notes: Additional notesisActive: Whether medicine is currently activereminderEnabled: Whether reminders are enabledcreatedAt,updatedAt: Timestamps
id: Unique identifieruserId: Owner user IDactionType: "call", "message", or "alarm"actionData: Phone number or alarm soundpriority: Priority level (1 is highest)isEnabled: Whether action is enabledcreatedAt,updatedAt: Timestamps