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

# Web API

> HTTP routes exposed by the Qredence web app and the events they emit.

The web app's HTTP routes (`web/app/src/routes/api/`) are how the browser talks to the agent runtime. Only the web server adapter (`web/server/src/event-mapper.ts`) imports agent packages; browser code consumes the wire format.

## Routes

| Route                 | Purpose                                                                           |
| --------------------- | --------------------------------------------------------------------------------- |
| `POST /api/post-chat` | Submit a new turn; receives `ChatStreamEvent` NDJSON on the response body.        |
| `POST /api/attach`    | Attach to an existing session; receives out-of-turn `AgentSessionEvent` over SSE. |
| `GET /api/health`     | Kernel readiness probe (`useKernelHealth`).                                       |

Additional routes exist for session listing, provider metadata, and session actions — see `web/app/src/routes/api/` for the current surface.

## Event shapes

* **NDJSON `ChatStreamEvent`** on chat responses. See [Streaming protocol](/fleet-prime-agent/concepts/streaming-protocol) for the event catalogue.
* **SSE `AgentSessionEvent`** on `/api/attach` for out-of-turn state changes (compaction ran, another client sent a turn, etc.).

## Contracts

Wire contracts live in `web/protocol`:

* `chat-protocol.ts` — event catalogue and payload shapes.
* `fleet-contract.ts` — `ChatAttachment`, `ProjectId`, and zod schemas for the OpenUI wire contract.
* `openui-prompt.ts` — UI wire contract.

Any change to these contracts is released with a matching change to the adapter.

## Related

* [Web app](/fleet-prime-agent/interfaces/web) — how to run the server.
* [Streaming protocol](/fleet-prime-agent/concepts/streaming-protocol) — the wire format explained.
