> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lala.ist/llms.txt
> Use this file to discover all available pages before exploring further.

# Conversation history

> GET /api/chat/history returns the last 60 messages, oldest first.

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

```bash theme={null}
curl https://client-api.lala.ist/api/chat/history \
  -H "Authorization: Bearer $LALA_TOKEN"
```

```json theme={null}
{
  "messages": [
    {
      "role": "user",
      "content": "Bugün 4 saat çalıştım",
      "timestamp": "2026-08-01T18:03:11.000Z"
    },
    {
      "role": "assistant",
      "content": "Güzel. Hangi derse ne kadar verdin?",
      "timestamp": "2026-08-01T18:03:19.000Z"
    }
  ]
}
```

## 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.

<Note>
  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](/concepts/api-contract).
</Note>

## Message fields

| Field       | Type                  | Notes                                                            |
| ----------- | --------------------- | ---------------------------------------------------------------- |
| `id`        | string                | Optional. Not present on every message. Do not key the UI on it. |
| `role`      | `user` or `assistant` | Required.                                                        |
| `content`   | string                | Required. Turkish text.                                          |
| `mediaUrl`  | string                | Optional. Present when the message carries an image.             |
| `timestamp` | date-time             | Required. UTC, ISO 8601. Convert to Europe/Istanbul for display. |

## 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](/guides/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.
