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

# Billing

> How the subscription model and session limits work.

## Model overview

Aiybiz uses a **per-seat subscription** model. Companies pay a monthly or annual fee per user seat. Sessions run freely within the plan's concurrent session limit — no per-hour charges, no wallet top-ups.

| Who     | What                                        |
| ------- | ------------------------------------------- |
| Company | Pays a monthly/annual subscription per seat |
| Plan    | Defines `maxActiveSessions` per seat        |
| Session | Free to run — no per-session billing        |

## Plans

Each plan defines:

* **Price per seat** — monthly or annual
* **maxActiveSessions** — how many sessions can run simultaneously per seat

## Subscription lifecycle

<Steps>
  <Step title="Company subscribes">
    `POST /stripe/subscriptions/create { planId, quantity }` → Stripe Subscription created
  </Step>

  <Step title="Stripe confirms payment">
    Stripe fires `invoice.paid` → Aiybiz activates the subscription and sets the seat count
  </Step>

  <Step title="Ongoing renewals">
    Stripe fires `invoice.paid` on each renewal → Aiybiz keeps the subscription active
  </Step>

  <Step title="Cancellation or failure">
    `customer.subscription.deleted` or `invoice.payment_failed` → Aiybiz marks the subscription inactive
  </Step>
</Steps>

## Concurrent session guard

When a session is requested, the platform checks:

```
activeSessions < plan.maxActiveSessions × seats
```

<Warning>
  If the limit is reached, the API returns `429 Too Many Requests`. End an active session to start a new one.
</Warning>

## Auto-end cron

An internal, service-authenticated scheduled job (not reachable from the public
internet) periodically:

* Detects stale sessions (e.g. no heartbeat for too long)
* Force-ends them and notifies the client

## Seat management

Company admins can add or remove seats from **Settings → Subscription**. Changes are prorated by Stripe automatically.
