---
title: "staffctl"
description: "Create the first support-console account, reset a staff password, list staff accounts, and provision a customer organization with its first owner."
---

The operator's command for the two things no HTTP route will do: create the
first [support-console](/deployment/staff-console) account, and create a
customer organization with its first owner.

```text
backend/cmd/staffctl
```

Both are deliberately commands rather than endpoints. A route that mints
administrators or organizations would be the most valuable thing on the
deployment to reach. A command that needs `DATABASE_URL` and a shell on the
host is already authenticated by both.

## Synopsis

```bash
staffctl bootstrap <email> [name]
staffctl reset <email>
staffctl list
staffctl org create <owner-email> <organization name>
staffctl backup-env <stack>
staffctl alert-webhook
staffctl demo-estate <email>
staffctl --version
```

There are no flags. With no arguments, or a subcommand given the wrong number
of them, it prints the usage and exits non-zero. Email addresses are normalised
before use, so `Owner@Acme.Example` and `owner@acme.example` are the same
account.

## Subcommands

| Command | Effect |
|---|---|
| `bootstrap <email> [name]` | Creates the first staff account, with the `platform_admin` role and a generated password |
| `reset <email>` | Sets a new generated password on an existing staff account and ends its sessions |
| `list` | Prints every staff account: email, role, `active` or `disabled`, and whether a second factor is enrolled |
| `org create <owner-email> <organization name>` | Creates a customer organization, its owner account and its subscription |
| `backup-env <stack>` | Prints the off-host backup target stored in the console's [platform setup](/deployment/platform-setup#off-host-backups) page as `KEY=VALUE` lines (`BACKUP_PUBLIC_KEY`, `BACKUP_REMOTE` and an rclone remote in `RCLONE_CONFIG_OFFSITE_*`), for `infra/scripts/backup.sh`. Prints nothing when no bucket is stored. The output includes the S3 secret: it is for the backup script, not a terminal someone else can read. The test email that `mail-test` used to send is now **Send test email** on the setup page |
| `alert-webhook` | Prints the production alert Slack webhook stored on the [platform setup](/deployment/platform-setup#production-alerts) page, one line, or nothing when none is set. For the host's `trustivan-alert-webhook-sync.timer` only: the URL is the credential. Exits non-zero when the setting cannot be read, so the host keeps the URL it has |
| `demo-estate <email>` | For a demo stack only: gives the account's organization a sample Kubernetes cluster that runs its four most vulnerable scanned images, and builds its [attack paths](/concepts/attack-paths) |

### `bootstrap`

```bash
staffctl bootstrap ops@example.com "Operations"
```

Creates the first `platform_admin`, and only the first. It refuses once any
staff account exists, with a message ending:

```text
1 staff account(s) already exist; create further accounts in the console, where the act is audited
```

There is no default password and no way to choose one. The command generates a
password that satisfies the staff policy and prints it once:

```text
Staff account: ops@example.com

  password: <generated>

This is printed once and is not recoverable. Give it to the person over a
channel you would use for any other credential, and have them sign in at
/staff/login — the first sign-in enrols the second factor, which is required.
```

Only the bcrypt hash is stored. The account cannot hold a session until its
first sign-in enrols a TOTP second factor, so the printed password protects
the console alone for exactly one login.

<Warning>
Set `STAFF_ALLOWED_CIDRS` before you run `bootstrap`. Until a staff account
exists the console has no credential that resolves, and while the variable is
empty the console refuses every address, so the account you bootstrap cannot
sign in until you list the networks it signs in from. See
[Staff console](/deployment/staff-console#restrict-where-the-console-is-reachable).
</Warning>

### `reset`

```bash
staffctl reset ops@example.com
```

Generates a new password for an existing account, revokes every live session
of that account, and prints the password once in the same form as `bootstrap`.
It is the only password recovery there is: the console has no self-service
reset.

`reset` changes the password only. It does not remove or replace the account's
second factor, and no other command does either.

### `list`

```bash
staffctl list
```

```text
ops@example.com                          platform_admin     active     enrolled
support@example.com                      support_engineer   active     no second factor
```

With no accounts it prints `no staff accounts; run: staffctl bootstrap <email>`.

### `org create`

The staff console's **Add customer** does the same and records who did it and why, so prefer it
where you can reach the console. See [Staff console](/deployment/staff-console).

```bash
staffctl org create owner@acme.example "Acme Corp"
```

Creates a user for the address, an organization with that user as its
**owner**, and the organization's subscription, then prints the organization
id and a generated password once:

```text
Organization: Acme Corp
  id:       <uuid>
  owner:    owner@acme.example
  password: <generated>
```

Everything after the email is the organization name, so the quotes are a
convenience rather than a requirement.

This is how a new customer gets its first account on a deployment that does
not allow open sign-up. With `SIGNUP_MODE=invite_only`, an account can only be
created against a pending invitation, an invitation needs an organization to
invite into, and an invitation cannot confer the owner role. The first owner
therefore cannot arrive through either door, and `org create` is the one that
opens. See [Sign-up and sign-in](/configuration/sign-up-and-sign-in).

Details worth knowing before you run it:

- **It refuses an address that already has an account.** That person may
  already belong to another organization. Invite them from inside the
  organization instead.
- **The address is marked verified.** You vouched for it by typing it. That is
  what later lets the owner link a GitHub, GitLab or Google sign-in to the
  same account.
- **The owner's display name is the organization name followed by `owner`.**
  They can change it after signing in.
- **Nothing forces a password change.** Ask the owner to change it at first
  sign-in.

The owner then invites colleagues from **Settings → Members**. Each invitation
shows its link once, which works with no mail relay configured.

### `demo-estate`

A demo organization holds real scans of public images and no connected
cluster, so nothing in it is exposed and it has no attack path to show. This
records one cluster inventory, `sample-cluster (demo data)`, through the same
path a cluster collection writes: two namespaces of workloads that run the
organization's four scanned images with the most open critical and high
vulnerabilities (by their scanned digest), a public LoadBalancer and an
Ingress in front of two of them, a service account bound to cluster-admin, a
privileged container and a credential written into a manifest. Its posture
findings come from the real check corpus, and the security graph and risk pass
then run as they do after any collection.

The cluster and its workloads are sample data and say so in their names; every
vulnerability on a path is a finding from a real scan. Running it again
updates the same cluster. It refuses an organization with no scanned image
that has an open critical or high vulnerability.

## Environment it reads

| Variable | Effect |
|---|---|
| `DATABASE_URL` | Required. The process exits with `DATABASE_URL is not set` without it |

Nothing else, except `backup-env` and `alert-webhook`, which load the worker configuration for
`TOKEN_ENCRYPTION_KEY`, the key the stored settings are sealed with: run it in
the API container, which has it. The other subcommands do not load the API
configuration, so they need no `JWT_SECRET` or `TOKEN_ENCRYPTION_KEY`. It loads `../.env` if present.

The application's own login role is sufficient: `staffctl` writes through the
same repositories the API uses, and the migrations grant that role the staff
tables. You do not need the schema owner.

## Running it

<Tabs>
  <Tab title="Production Compose">
    The backend image ships the binary at `/app/staffctl`, and the `api`
    container already has `DATABASE_URL`:

    ```bash
    docker compose -f infra/docker/docker-compose.prod.yml --env-file infra/docker/.env \
      exec api /app/staffctl list
    docker compose -f infra/docker/docker-compose.prod.yml --env-file infra/docker/.env \
      exec api /app/staffctl org create owner@acme.example "Acme Corp"
    ```
  </Tab>
  <Tab title="Published image">
    ```bash
    docker run --rm -e DATABASE_URL --entrypoint /app/staffctl \
      ghcr.io/trustivan/trustivan-backend:v1.0.0 list
    ```
  </Tab>
  <Tab title="From source">
    ```bash
    cd backend
    GOEXPERIMENT=jsonv2 go run ./cmd/staffctl list
    ```
  </Tab>
</Tabs>

Run `bootstrap`, `reset` and `org create` from an interactive terminal you
trust. Each prints a credential to standard output, and a pipeline that
captures output keeps it.

## Related

- [Staff console](/deployment/staff-console): what the accounts this command
  creates can do.
- [Sign-up and sign-in](/configuration/sign-up-and-sign-in): the sign-up modes
  that make `org create` necessary.
- [Support access](/security/support-access): the customer's side of a support
  session.
