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

# Lala Client API

> The HTTP API behind Lala, the AI study companion for Turkish YKS and LGS students.

Lala is an AI study companion for students who prepare for the Turkish YKS and LGS exams. This API
is the interface between a client application and Lala. It is a plain HTTP and JSON service, so
any client can use it.

The API does five things:

* It authenticates a student with a Supabase access token.
* It creates and updates the student profile.
* It streams a chat answer over Server-Sent Events (SSE).
* It returns the recent conversation history.
* It reports service health.

<Card title="Base URL" icon="server" horizontal>
  `https://client-api.lala.ist`
</Card>

## Endpoints

| Method  | Path                | Purpose                                                          |
| ------- | ------------------- | ---------------------------------------------------------------- |
| `GET`   | `/health`           | Service health. No token.                                        |
| `GET`   | `/api/me`           | Identity and profile. Creates the student row on the first call. |
| `PATCH` | `/api/profile`      | Partial profile update. Onboarding writes here.                  |
| `POST`  | `/api/chat/send`    | Send a message. The answer streams as SSE.                       |
| `GET`   | `/api/chat/history` | The last 60 messages, oldest first.                              |

Every path under `/api` needs a Supabase access token. Read [Authentication](/authentication).

## Start here

<CardGroup cols={2}>
  <Card title="Quickstart" icon="rocket" href="/quickstart">
    Get a token and stream your first answer.
  </Card>

  <Card title="Authentication" icon="key" href="/authentication">
    How the server verifies a Supabase token.
  </Card>

  <Card title="Stream a chat answer" icon="bolt" href="/guides/chat-streaming">
    The SSE event contract, with client code.
  </Card>

  <Card title="Notes for AI agents" icon="robot" href="/agents">
    A dense fact sheet for a coding agent.
  </Card>
</CardGroup>

## What the API does not do

The API is small on purpose. These items are out of scope for version 1:

* No pagination. The history endpoint returns a fixed window of 60 messages.
* No WebSocket transport. The only stream is the SSE response of `POST /api/chat/send`.
* No message identifiers for outgoing messages. The client cannot edit or delete a message.
* No file upload endpoint. An image goes inline in the chat request body as base64.
* No admin surface, no voice, and no WhatsApp or Telegram transport.

## Language

The API is bilingual by design:

* All content that a student reads is Turkish. The chat text is Turkish.
* Everything a developer reads is English. Field names, event names, error strings, and the whole
  OpenAPI document are English.

An error body is always the same shape, and the `error` value is a short English string:

```json theme={null}
{ "error": "unauthorized" }
```
