# Billing

Manage your team's plan, upgrade, and understand usage limits.

Source: https://keyenv.dev/docs/web-app/billing/

KeyEnv offers three plan tiers. Each team has its own plan and billing. Only team admins can view and manage billing.

## Plan Tiers

### Free

The default plan for every new team. Includes:

| Resource | Limit |
|---|---|
| Team members | 1 |
| Projects | 3 |
| Secrets per environment | 100 |
| Environments per project | 3 |

The Free plan is suitable for personal projects and solo developers. All core features (encryption, CLI, environment permissions, audit trail) are included.

### Team

For teams that need collaboration and higher limits. Includes:

| Resource | Limit |
|---|---|
| Team members | Unlimited |
| Projects | Unlimited |
| Secrets per environment | Unlimited |
| Environments per project | Unlimited |

**Pricing**: $4/user/month or $40/user/year ($3.33/month, save 17%). Billed per active team member -- the seat count adjusts automatically when members join or leave.

### Enterprise

For organizations with advanced requirements. Includes everything in Team plus:

- Priority support
- Custom integrations
- SLA guarantees

Contact us at [support@keyenv.dev](mailto:support@keyenv.dev) for Enterprise pricing.

## Free Trial

New teams receive a **14-day free trial** of Team plan features when they first sign up. During the trial:

- All Team plan limits are available (unlimited projects, secrets, members, and environments)
- No payment method is required
- An email notification is sent **3 days before the trial ends**
- When the trial expires, the team automatically downgrades to the Free plan

> **Note**
>
> You can upgrade to a paid Team plan at any time during the trial. If you upgrade, the trial ends immediately and billing begins.

## Upgrading to Team

Only team admins can upgrade the plan.

1. Go to **Team** in the sidebar
2. Click **Billing** or **Upgrade**
3. Choose monthly or annual billing
4. Complete payment through the Stripe checkout page
5. Your plan upgrades immediately after payment

The upgrade takes effect instantly. All limits are lifted and you can invite members, create projects, and add secrets without restrictions.

## Subscription States

Your subscription can be in one of the following states:

| State | Description |
|---|---|
| `active` | Subscription is current and fully paid. All Team plan features are available. |
| `trialing` | Team is in the 14-day free trial period. All Team plan features are available. |
| `past_due` | A payment has failed. The system will retry automatically. Features remain available while retries are in progress. |
| `canceled` | Subscription has been canceled. The team reverts to the Free plan at the end of the current billing period. |

## Managing Your Subscription

After upgrading, team admins can manage the subscription through the Stripe billing portal:

1. Go to **Team** in the sidebar
2. Click **Billing**
3. Click **Manage Subscription**

From the billing portal you can:

- Update your payment method
- View invoices and payment history
- Switch between monthly and annual billing
- Cancel your subscription

## Downgrading

When you cancel your Team subscription, the following happens:

- Your plan reverts to Free at the end of the current billing period
- **Existing resources are kept** -- your projects, secrets, members, and environments remain intact
- **New creation is blocked** -- if your usage exceeds Free plan limits, you cannot create new resources of that type until you reduce usage or re-upgrade
- Team admins receive a notification about the over-limit state

> **Note**
>
> KeyEnv never deletes your data on downgrade. Your existing secrets and projects remain accessible. You just cannot create new ones beyond Free plan limits.

## Over-Limit State

If your team's usage exceeds the plan limits (typically after a downgrade from Team to Free), you enter an over-limit state:

- A warning banner appears in the web app
- The API returns a `402 Payment Required` error when attempting to create resources that are over the limit
- Existing resources continue to work normally (read, update, delete)

### Resolving Over-Limit

To resolve an over-limit state, you can either:

1. **Reduce usage** -- Delete projects, secrets, or environments to bring usage within Free plan limits
2. **Remove members** -- Remove team members to get within the 1-member Free limit
3. **Upgrade** -- Re-upgrade to Team to remove all limits

## Sponsored Teams

In some cases, a KeyEnv administrator may sponsor a team, granting it Team features at no cost. Sponsored teams:

- Have all Team plan limits (unlimited everything)
- Do not need a Stripe subscription
- Cannot be charged through the checkout flow (checkout is blocked for sponsored teams)
- May include an optional note from the administrator explaining the sponsorship

## Email Notifications

KeyEnv sends email notifications for the following billing events:

- **Subscription created** -- when a team upgrades to the Team plan
- **Trial ending** -- sent 3 days before the free trial expires
- **Payment failed** -- when a payment attempt is unsuccessful (includes the next retry date)
- **Subscription renewed** -- when a subscription is successfully renewed at the start of a new billing period

## Viewing Usage

Any team member can view the team's current resource usage:

1. Go to **Team** in the sidebar
2. The usage section shows current counts and limits for:
   - Projects
   - Team members
   - Secrets (highest count across all environments)
   - Environments (highest count across all projects)

Usage warnings appear when you reach 80% of a limit. At-limit indicators appear when you have reached the maximum.
