Skip to main content
GET /api/chat/history returns the recent conversation. It is the only read path for chat content.

The window

The endpoint returns the last 60 messages, oldest first. It is not paginated, and there is no query parameter. Older messages exist in the database, but the API does not expose them. The model sees the same 60-message window, plus rolling summaries of what came before.
The fixed window is a decision, not a gap. An unpaged read of a growing table was the most common source of silent data loss in the previous backend. Read The API contract.

Message fields

When to call it

Call the endpoint at these four moments:
  1. When the chat screen opens.
  2. When the application returns to the foreground.
  3. After the student opens a push notification. Lala writes messages on its own.
  4. After an SSE error event, to resynchronize the local list.
Do not poll. The only messages that arrive without a student action are scheduled messages, and each one is announced by a push notification. Read Push notifications.

Local state

Treat the server list as the source of truth. Keep the optimistic local copy of a message that is in flight, then replace the whole list with the server response after the turn ends. Messages have no stable identifier, so a merge by id is not possible.