Skip to main content

Water Intake API

Water Intake provides water logging and daily goal tracking for authenticated users.

Authentication

Use a Firebase user token in the Authorization: Bearer <firebase_jwt> header.

note

The Water Intake module must be enabled for your client. Contact your administrator if you receive a module-disabled error.

Logs

POST /api/water-intake/logs

Log a water intake entry.

Request Body:

FieldTypeRequiredDescription
amountMlnumberYesAmount in millilitres (1–5000)
datestringNoDate in YYYY-MM-DD format (defaults to today)
Request
{
"amountMl": 250,
"date": "2026-03-17"
}
Response (201)
{
"logId": "log-001",
"clientId": "gofa",
"userId": "user-001",
"amountMl": 250,
"date": "2026-03-17",
"createdAt": "2026-03-17T10:30:00Z"
}

GET /api/water-intake/logs

Get water intake logs for a specific date, including a daily summary.

Query Parameters:

ParameterTypeDefaultDescription
datestringTodayDate in YYYY-MM-DD format
Response
{
"date": "2026-03-17",
"totalMl": 1250,
"goalMl": 2000,
"logs": [
{
"id": "log-001",
"amountMl": 250,
"timestamp": "2026-03-17T10:30:00Z"
},
{
"id": "log-002",
"amountMl": 500,
"timestamp": "2026-03-17T08:15:00Z"
},
{
"id": "log-003",
"amountMl": 500,
"timestamp": "2026-03-17T07:00:00Z"
}
]
}

DELETE /api/water-intake/logs/[logId]

Remove a water intake log entry. Users can only delete their own logs.

Response
{
"success": true
}

Error Responses:

StatusDescription
403User does not own this log
404Log not found

Settings

GET /api/water-intake/settings

Get the user's water intake settings.

Response
{
"dailyGoalMl": 2000
}

PATCH /api/water-intake/settings

Update the user's daily water intake goal.

Request Body:

FieldTypeRequiredDescription
dailyGoalMlnumberYesDaily goal in millilitres (500–10 000)
Request
{
"dailyGoalMl": 2500
}
Response
{
"dailyGoalMl": 2500
}

Admin Records

GET /api/water-intake/records

Admin-only endpoint to list water intake log records for a client. Requires admin authentication.

Query Parameters:

ParameterTypeDefaultDescription
clientIdstringTarget client ID (admin can query other clients)
limitnumber50Max results (1–500)
Response
{
"data": [
{
"id": "log-001",
"clientId": "gofa",
"userId": "user-001",
"amountMl": 250,
"date": "2026-03-17",
"createdAt": "2026-03-17T10:30:00.000Z",
"timestamp": "2026-03-17T10:30:00.000Z"
}
],
"count": 1
}

Error Responses:

StatusDescription
401Unauthorized — admin authentication required
403Water Intake module not enabled for this client
500Internal server error
note

Results are ordered by createdAt descending. The Water Intake module must be enabled for the target client.