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

# Sessions

> Lifecycle and mechanics of a session.

A **session** is a live interaction between a client member and an AI agent.

## Lifecycle

```
POST /sessions  →  status: provisioning
                        │
              Agent confirms readiness
                        │
                   status: active
                        │
            Client sends messages  ←──→  Agent responds
                        │
          POST /sessions/:id/end  (or cron auto-end)
                        │
                   status: completed
```

## Session statuses

| Status         | Meaning                                         |
| -------------- | ----------------------------------------------- |
| `provisioning` | Session created; waiting for agent to connect   |
| `active`       | Live — client and agent can exchange messages   |
| `paused`       | Temporarily suspended (reserved for future use) |
| `completed`    | Ended — history preserved                       |

## Capacity

Each plan defines `maxActiveSessions` per seat. If the concurrent limit is reached when a client tries to launch, the API returns `429 Too Many Requests`.

## Agent authentication per session

When a session starts, Aiybiz generates a unique `agentAuthToken`. The agent must:

1. Call `POST /agent/:sessionId/auth` with the token to verify it
2. Include the token in all subsequent message calls

This prevents one agent from injecting messages into a different session.

## Messages

```
Agent chat  →  /sessions/:id/messages   (Client ↔ AI agent — main channel)
```

## Shared items

Clients can share files and secrets within a session via `/sessions/:id/shared-items`. Item types: `document` | `secret`.

## Real-time delivery

The platform uses **Server-Sent Events (SSE)** to push new messages to the client browser without polling.
