---
title: luna tenants
description: Add, list and delete the tenants of an environment, and the host names a tenant answers on.
related:
  - /platforms/add-tenants
  - /platforms/manage-tenants-from-code
---

`luna tenants` adds tenants to an environment. Each runs the environment's code with data of its own.

```bash
luna tenants create acme
```

## Reference

```bash
luna tenants <COMMAND>
```

Every subcommand acts on one environment, and takes these options.

| Option | Type | Default | Does |
| --- | --- | --- | --- |
| `--dir <DIR>` | path | `.` | The app's folder. Its env file names the project and environment. |
| `--env <ENV>` | text | `LUNA_ENV`, then `production` | The environment, by name. |
| `--project <PROJECT>` | text | `LUNA_PROJECT` | The project, by name or as `organisation/project`. |
| `--token <TOKEN>` | text | `LUNA_TOKEN`, then your login | An API token or account key to act with. |

### luna tenants list

Lists the environment's tenants: its own, named `default`, and every one added. Each row has its version, URL and labels.

```bash
luna tenants list [OPTIONS]
```

| Option | Type | Default | Does |
| --- | --- | --- | --- |
| `--json` | flag | Off | Prints the answer as JSON. |

### luna tenants create

Adds a tenant to the environment, and prints its URL.

```bash
luna tenants create [OPTIONS] <NAME>
```

| Option | Type | Default | Does |
| --- | --- | --- | --- |
| `<NAME>` | text | Required | The tenant's name: lowercase letters, digits and single dashes. |
| `--label <KEY=VALUE>` | text | None | A label to find the tenant by. Repeat it for more labels. |

### luna tenants delete

Deletes a tenant added to the environment, with all its data.

```bash
luna tenants delete [OPTIONS] <NAME>
```

| Option | Type | Default | Does |
| --- | --- | --- | --- |
| `<NAME>` | text | Required | The tenant, by name. Never `default`, which is deleted with its environment. |
| `--yes` | flag | Off | Deletes it without asking first. |

:::warning
Deleting a tenant cannot be undone. Its lunas and their data are gone for good.
:::

### luna tenants hosts

Lists, adds or removes the host names a tenant answers on besides its own URL. With no `--add` or `--remove`, it lists them.

```bash
luna tenants hosts [OPTIONS]
```

| Option | Type | Default | Does |
| --- | --- | --- | --- |
| `--tenant <TENANT>` | text | The environment's own | The tenant, by name. |
| `--add <HOST>` | text | None | Answers on this host name too. Repeat it for more. |
| `--remove <HOST>` | text | None | Stops answering on this host name. Repeat it for more. |
| `--json` | flag | Off | Prints the answer as JSON. |

A host name is kept in lowercase, without a scheme, port or trailing slash. To serve a domain of your own with a certificate, use [`luna domains`](/cli/domains) instead.

## Good to know

- Every environment has a default tenant, where your app runs. Most apps never add another.
- Other commands act on an added tenant when you pass `--tenant <NAME>`, such as `luna secrets set` and `luna logs`.

## Examples

### Add a tenant with labels

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

### List the tenants of production

```bash
luna tenants list --env production
```

### Delete a tenant from a script

```bash
luna tenants delete acme --yes
```
