# License keys

Source: https://agenta.ai/docs/self-host/reference/license-keys

A license key sets the plan of a self-hosted Agenta instance. The plan decides how many projects and organizations the instance can have, and which enterprise features every organization on the instance can use. Every Agenta image reads license keys.

## What a license key is

A license key is a line of text that starts with `agenta_license_v1.`. It holds the plan, the customer name, an optional number of seats and an optional expiry date. Agenta signs it with a private key, and the instance checks the signature with the public keys that are built into the image.

The check runs offline. The instance does not call Agenta to check a key, and a key works on an instance that has no internet access.

## Add a license key

Use one of these two ways. A key in `AGENTA_LICENSE_KEY` takes priority over a key added in the app.

### In the app

1. Sign in as the instance admin.
2. Open **Settings > License**.
3. Select **Add a license key**, paste the key in **License key**, and select **Add key**.

The new plan applies to every organization on the instance. The **License** tab is visible only to the instance admin. The instance admin is a user whose email is in `AGENTA_ACCESS_ALLOWED_OWNER_EMAILS`. When that list is unset, it is the owner of the oldest organization.

### With an environment variable

Set `AGENTA_LICENSE_KEY` on the `api`, `worker-queues` and `worker-streams` containers, then restart them.

- Docker Compose: add the key to your `.env` file.

  ```bash
  AGENTA_LICENSE_KEY=agenta_license_v1.eyJrZXlfaWQiOi...
  ```

  Then run your `docker compose ... up -d` command again. It recreates the containers with the new value. `docker compose restart` keeps the old value.

- Helm: the chart has no value for the key. Add it with `extraEnv`, for example from a Kubernetes secret:

  ```yaml
  api:
    extraEnv:
      - name: AGENTA_LICENSE_KEY
        valueFrom:
          secretKeyRef:
            name: agenta-license
            key: key
  ```

  Add the same entry under `workerQueues.extraEnv` and `workerStreams.extraEnv`.

When the key comes from the environment, the **License** tab shows it with the message "This key is set in the server settings and cannot be changed here."

Do not confuse `AGENTA_LICENSE_KEY` with `AGENTA_LICENSE`, which picks the default database names, not the plan. See [`AGENTA_LICENSE`](https://agenta.ai/docs/self-host/reference/configuration.md#agenta-core).

## Get a free registration key

The free registration key puts the instance on the Registered plan (`self_hosted_registered`). The Registered plan removes the limit of 1 project per organization. It has the same features as the Community plan, which an instance without a key gets, and keeps the limit of 1 organization per instance.

To request a free key:

1. Sign in as the instance admin.
2. Open **Settings > License**. With no key on the instance, the tab shows **Register this instance for free**.
3. Enter an email and select **Send me a free key**. The box "Send me security and product updates (about once a month)." starts selected. You can clear it. The key does not need it.

Agenta sends an email to that address with the key and a link to your instance. Open the link while signed in as the instance admin, and confirm **Add this license key?** to add the key. You can also select **Add a license key** on the License tab and paste the key.

You keep what your key unlocks. The free key does not expire and has no seat count. It does not change the telemetry switch.

## Limits by plan

| Plan | Key | Projects per organization | Organizations per instance |
|---|---|---|---|
| Community (`self_hosted_community`) | No key, an expired key, or a key that is not valid | 1 | 1 |
| Registered (`self_hosted_registered`) | The free registration key | No limit | 1 |
| Enterprise | A paid key | No limit | No limit |

The limits refuse only a new project or a new organization. Projects and organizations that already exist stay, even when there are more than the limit allows.

- A second project in an organization on the Community plan is refused. The API answers `403` with `detail.code` set to `project_limit_reached`.
- A second organization on an instance without a paid key is refused. The API answers `403` with `detail.code` set to `instance_organization_limit_reached`.
- A person who signs up on an instance that is at its organization limit is signed up with no organization. They join an existing organization by invitation. See [Restrict sign-ups and organization creation](https://agenta.ai/docs/self-host/access-control/restrict-organization-creation.md#one-organization-without-a-paid-key).

## When a key expires

Starting 30 days before the expiry date, the **License** tab shows "This license expires on" with the date. After the expiry date, the instance runs on the Community plan, and the tab shows "This license expired on" with the date. Enterprise features stop working and the Community plan limits apply to new projects and organizations, but no data is deleted. Add a new key to turn them on again.

A key with seats shows the number of users against the seats on the **License** tab, and a notice when the instance has more users than the key allows. The instance does not block users above the seat count.

## An instance without a key

An instance with no key, or with a key that is not valid, runs every organization on the Community plan (`self_hosted_community`). It has the [limits](#limits-by-plan) of 1 project per organization and 1 organization per instance. The Community plan, and the Registered plan of the free key, have no enterprise features:

- SSO providers per organization, set up in the app
- Sign-in method enforcement per organization
- Domain verification
- Roles beyond owner, admin and member in invitations and role changes
- The audit log

Everything else works, with no limit on users. SSO login that you configure with environment variables works without a key. See [Configure SSO](https://agenta.ai/docs/self-host/access-control/configure-sso.md).

`AGENTA_ACCESS_DEFAULT_PLAN`, `AGENTA_ACCESS_PLANS` and `AGENTA_ACCESS_DEFAULT_PLAN_OVERLAY` cannot turn on enterprise features without a key. See [Dynamic access controls](https://agenta.ai/docs/self-host/access-control/dynamic-access-controls.md).

## Upgrade an open source instance

Before v0.131.1, the open source images did not read license keys and had no limits. From v0.131.1, every install runs the same images. When you upgrade an instance that ran the open source images and you do not add a key:

- The first start migrates the database to the full schema. Every member keeps access to the projects they could open before. See [Upgrading to 0.131.1](https://agenta.ai/docs/self-host/upgrade-and-migrate/upgrading.md#upgrading-to-0131-1) for the steps.
- The instance runs on the Community plan. All existing projects and organizations stay, and the [limits](#limits-by-plan) apply to new ones. The free key removes the project limit. A paid key removes both limits.
- The **Access & Security** and **Audit Log** settings show the enterprise features as locked, with **Add a license key** and **Talk to us**.

## Upgrade an existing Enterprise instance

Before v0.131.1, an instance that ran the Enterprise images without a key gave every organization the enterprise plan. After the upgrade, an instance without a key runs on the Community plan. If you upgrade such an instance and do not add a key:

- Every organization moves to the Community plan. Adding a key later turns the enterprise features back on.
- The [limits](#limits-by-plan) apply to new projects and organizations. Existing ones stay.
- The **Access & Security** and **Audit Log** settings show the enterprise features as locked, with **Add a license key** and **Talk to us**.
- Invitations and role changes offer only admin and member. Members who already have another role keep it.
- SSO providers, verified domains and sign-in settings that organizations saved before the upgrade stay in the database. Owners cannot change them until you add a key.
- `AGENTA_ACCESS_DEFAULT_PLAN` no longer sets the plan. The API logs a warning at startup when it is set.

If your instance sets `STRIPE_API_KEY`, remove it before you upgrade. Stripe is for Agenta Cloud billing. The API and the workers do not start when `STRIPE_API_KEY` is set and `AGENTA_LICENSE_KEY` is not a cloud license key.

To keep the enterprise features without a gap, set `AGENTA_LICENSE_KEY` when you deploy the upgrade. To get a key, [talk to us](https://agenta.ai/contact).

## Reference

All license settings are in [Configuration](https://agenta.ai/docs/self-host/reference/configuration.md#license).
