The Sessions API drives MindFlow’s core adaptive loop. A student starts an EMA (Ecological Momentary Assessment) session, which opens a window for submitting a self-reported fatigue score on the 1–5 scale. If the submitted score is 4 or higher, the backend automatically triggers the AI task decomposer to break the student’s active tasks into bite-sized micro-objectives of no more than 25 minutes each. All three endpoints require JWT authentication, and every response follows the standardDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/J0S3-LEON/pf_pruebasAseguramientoCalid_SDD/llms.txt
Use this file to discover all available pages before exploring further.
{ data, error, status } envelope.
Starting a new session with
POST /api/v1/sessions automatically closes any previously active session for the same student by setting its is_active = false and recording an endedAt timestamp.POST /api/v1/sessions
Starts a new EMA session for the authenticated student. The response contains the server-assignedsessionId (which is required for the subsequent fatigue submission) and the EMA bot’s opening prompt.
Authentication: JWT Bearer
Request Body: None
Response — 201 Created
UUID of the newly created session. Pass this value to
POST /api/v1/sessions/:sessionId/fatigue.The EMA bot’s opening question presented to the student.
Always
null on success.201Example Response
Errors
| Status | Condition |
|---|---|
401 Unauthorized | JWT is missing or expired. |
POST /api/v1/sessions/:sessionId/fatigue
Submits the student’s self-reported fatigue score for an active session. The score is validated strictly at the DTO level before any database write is attempted. On a valid submission the server persists aFatigueRecord, closes the session (is_active = false), and — if the score is >= 4 — invokes the AI task decomposer for the student’s active tasks.
Authentication: JWT Bearer
Path Parameters
UUID of the active session returned by
POST /api/v1/sessions.Request Body
Self-reported fatigue score. Must be a whole integer in the range
[1, 5]. Decimals, strings, booleans, and null are all rejected with 422.Optional UUID of a specific task to decompose when
score >= 4. If omitted and the score triggers decomposition, the service selects the task with the earliest deadline.Example Request
Example Request with taskId
Response — 201 Created
UUID of the persisted
FatigueRecord.UUID of the session this record belongs to.
The fatigue score as stored — always a whole integer in
[1, 5].ISO 8601 UTC timestamp of when the record was persisted.
Human-readable status message indicating the next step in the EMA flow.
Array of AI-generated
MicroObjective objects. Populated only when score >= 4 and the AI decomposer succeeds; empty array otherwise.The original Task object. Returned when no micro-objectives were generated — either because
score <= 3 or as a fallback when AI decomposition fails. null when micro-objectives were successfully generated.true if decomposition was attempted (score >= 4) but the AI service failed. The original task is surfaced as a fallback in this case.Always
null on success.201Example Response — score 4, AI decomposition successful
Example Response — score 2, no decomposition
Errors
| Status | Condition |
|---|---|
422 Unprocessable Entity | score is not a whole integer, is out of the [1, 5] range, is a decimal, a string, a boolean, or null. |
400 Bad Request | The session does not exist, belongs to a different student, or has already been completed. |
401 Unauthorized | JWT is missing or expired. |
Score validation is strict. The DTO uses
@IsInt() — only whole integer values pass validation. The @Type(() => Number) transformer coerces incoming values to a number first, so a JSON body value of 5.0 (which coerces to 5) is accepted, but 4.5 (a non-integer), "4" (a string that does not coerce cleanly), or null are all rejected with 422.GET /api/v1/sessions
Returns the authenticated student’s session history — up to the last 30 sessions, ordered bystartedAt descending (most recent first).
Authentication: JWT Bearer
Request Body: None
Response — 200 OK
Array of up to 30 session objects sorted by
startedAt descending.Always
null on success.200data array has the following fields:
UUID of the session.
UUID of the owning student.
ISO 8601 UTC timestamp when the session was created.
ISO 8601 UTC timestamp when the session was closed, or
null if the session is still active.true if the session has not yet received a fatigue score submission.Example Response
Errors
| Status | Condition |
|---|---|
401 Unauthorized | JWT is missing or expired. |