---
title: Add tenants
description: Give a customer a tenant of their own, with its own code, data, keys and URL, and manage tenants with luna tenants.
related:
  - /platforms/manage-tenants-from-code
  - /concepts/organisations-projects-and-environments
  - /cli/tenants
---

Every environment has one tenant, its default tenant, and `luna deploy` puts your app there. Most apps never add another, because one luna for each customer already keeps each customer's data apart.

## Choose between a tenant and a luna key

A tenant is a part of an environment with its own code, lunas, keys and secrets. A luna key is one more luna of a type your app already has, such as a `User` for each person.

| Your app | Use |
| --- | --- |
| Customers sign in and use your app, each with data of their own | A luna for each customer |
| Customers write code that you run for them | A tenant for each customer |
| A customer needs keys, secrets or a URL of their own | A tenant for each customer |
| You cap what one customer can use, such as requests a second | A tenant for each customer |

Rule of thumb: add a tenant when a customer brings code or credentials of their own. Otherwise, add a luna.

## Add a tenant

[`luna tenants create`](/cli/tenants) adds a tenant to the environment the folder uses, and prints the tenant's URL.

```bash
luna tenants create acme
```

The name is lower-case letters, digits and single dashes, and it cannot be `default`. The environment needs a deploy before it can take a tenant.

A new tenant has no code yet. Deploy to it from a luna with [Manage tenants from code](/platforms/manage-tenants-from-code), since `luna deploy` deploys to the default tenant only.

## Know what a tenant has of its own

Each tenant is apart from every other tenant of the environment.

- **Code**: the version deployed to it, which starts at 0.
- **Lunas**: their tables, files, streams and schedules.
- **Keys**: a publishable key and a secret token, made with the tenant.
- **Secrets**: the values `ctx.env` reads.
- **URL**: an address of its own, which never changes.
- **Settings**: its quotas, labels and the services it may call.

A luna cannot read another tenant's data. Calls between tenants go only the two ways that [Call across tenants](/platforms/call-across-tenants) shows.

## Label a tenant

Labels are your own `key=value` tags, for finding tenants later. Repeat `--label` to add several.

```bash
luna tenants create acme --label plan=pro --label region=eu
```

## List the tenants

[`luna tenants list`](/cli/tenants) shows the environment's default tenant and every tenant added to it, with each one's version, URL and labels.

```bash
luna tenants list
```

Add `--json` for the full names, which the API and `ctx.tenant` use.

## Run other commands on a tenant

Commands that act on an environment take `--tenant` with the name of an added tenant. Without it, they act on the default tenant.

```bash
luna keys list --tenant acme
```

```bash
luna secrets set STRIPE_KEY --tenant acme
```

`luna logs`, `luna status`, `luna data`, `luna restore`, `luna export` and `luna domains` take `--tenant` too. To compare what each tenant uses, run `luna usage --by tenant`.

In the Console, the project page shows an environment's added tenants under **Tenants**.

## Answer on another host name

A tenant answers at its own URL. [`luna tenants hosts`](/cli/tenants) adds host names it answers on as well, or lists them when you pass no flags.

```bash
luna tenants hosts --tenant acme --add shop.acme.example
```

Two tenants cannot share a host name. Luna gets a certificate only for a domain added with `luna domains add`, so for a domain of your own, follow [Use your own domain](/http/use-your-own-domain).

## Delete a tenant

[`luna tenants delete`](/cli/tenants) deletes an added tenant with its lunas, data, versions, keys and secrets. It asks first, unless you pass `--yes`.

```bash
luna tenants delete acme
```

:::warning
A deleted tenant cannot be restored. Run `luna export --tenant acme` first if you may need its data again.
:::

The default tenant is deleted only with its environment, by `luna env delete`.

## Next steps

- [Manage tenants from code](/platforms/manage-tenants-from-code) creates and deploys tenants as customers sign up.
- [Call across tenants](/platforms/call-across-tenants) lets your lunas and a tenant's lunas call each other.
- [Automate with API tokens](/platforms/automate-with-api-tokens) gives a program the `tenants:write` scope it needs.
