# Account commands

> List, add, change and remove the test accounts Re:agent signs in with.

Source: https://rehearsal.dev/docs/reference/cli-accounts

These commands manage a project's [test accounts](https://rehearsal.dev/docs/reagent/test-accounts.md), the accounts Re:agent, explorations and tests sign in with. Each one asks for what it still needs, so `rehearsal accounts add` alone walks you through a new account.

No flag takes a password. At a terminal you type it where nobody sees it. A script or a coding agent says where it is with `--password-from`, and `--secret-key-from` does the same for an authenticator's key. No line the CLI prints, no error and no JSON answer holds either.

- `env:NAME` reads the environment variable NAME.
- `file:<path>` reads the whole file, without its last line break. If others on the computer can read the file, the CLI says so and still reads it.
- `stdin` reads what is piped in, such as from a password manager. Only one flag of a command can read it.

```sh
# Answer each question
rehearsal accounts add

# From a script, with the password already in TEST_PASSWORD
rehearsal accounts add --label Owner --username owner@parcel.example --password-from env:TEST_PASSWORD --json

# From a password manager
op read op://Testing/Owner/password | rehearsal accounts add --label Owner --username owner@parcel.example --password-from stdin --json
```

Add `--dry-run` to see what a command would save. It asks its questions and reads the password, then saves nothing. Its answer never holds the password.

Reading accounts needs a sign-in with the `testing:read` scope and **View projects**. Adding, changing and removing them needs the `testing:run` scope and **Manage projects**, as the dashboard's form does.

## rehearsal accounts list

List the test accounts Re:agent signs in with.

Each account shows how it signs in, which environments have it, and whether it has a mailbox where Rehearsal reads the codes and links your app sends. No password or secret key is ever shown.

```sh
rehearsal accounts list [flags]
```

| Flag | Description |
| --- | --- |
| `--workspace <workspace-id>` | Workspace ID. Defaults to `REHEARSAL_WORKSPACE_ID` or `rehearsal.config.json`, then to your only workspace or the one you pick. |
| `--project <project>` | Project ID, slug or name. Defaults to `REHEARSAL_PROJECT_ID` or `rehearsal.config.json`, then to the workspace's only project or the one you pick. |
| `--limit <count>` | How many to return, 1 to 50. The default is 20. |
| `--cursor <cursor>` | Continue from the cursor the last page returned. |

Needs a sign-in with the `testing:read` scope and permission to read projects.

```sh
# List the accounts
rehearsal accounts list

# Read them in a script
rehearsal accounts list --json
```

## rehearsal accounts show

Show one test account.

Shows how it signs in, any code it needs, its mailbox and its environments. No password or secret key is ever shown.

```sh
rehearsal accounts show <account> [flags]
```

| Argument | Description |
| --- | --- |
| `<account>` | The account's name or ID, as `rehearsal accounts list` shows it. |

| Flag | Description |
| --- | --- |
| `--workspace <workspace-id>` | Workspace ID. Defaults to `REHEARSAL_WORKSPACE_ID` or `rehearsal.config.json`, then to your only workspace or the one you pick. |
| `--project <project>` | Project ID, slug or name. Defaults to `REHEARSAL_PROJECT_ID` or `rehearsal.config.json`, then to the workspace's only project or the one you pick. |

Needs a sign-in with the `testing:read` scope and permission to read projects.

```sh
# Show an account
rehearsal accounts show Owner

# Read it in a script
rehearsal accounts show <account-id> --json
```

## rehearsal accounts add

Add a test account for Re:agent to sign in with.

It asks for what it still needs: a name, how the account signs in, its username and password, and which environments have it. Type the password when asked, where nobody sees it. In a script, say where it is with `--password-from`: env:NAME for an environment variable, file:`<path>` for a file, or stdin for what is piped in. A passwordless account gets a mailbox. Sign up in your app with that address, and Rehearsal reads the codes and links sent there.

```sh
rehearsal accounts add [flags]
```

| Flag | Description |
| --- | --- |
| `--workspace <workspace-id>` | Workspace ID. Defaults to `REHEARSAL_WORKSPACE_ID` or `rehearsal.config.json`, then to your only workspace or the one you pick. |
| `--project <project>` | Project ID, slug or name. Defaults to `REHEARSAL_PROJECT_ID` or `rehearsal.config.json`, then to the workspace's only project or the one you pick. |
| `--label <name>` | What the account is called, such as Owner. |
| `--role [<role>]` | What kind of user it is in your app, such as admin. The flag alone leaves the role out. |
| `--sign-in <password\|passwordless>` | How it signs in: with a password, or with a code or link sent by email. The default is password. |
| `--username <username>` | The username or email it signs in with. |
| `--password-from <place>` | Where its password is: env:NAME, file:`<path>` or stdin. The password itself is never a flag. Left out, a terminal asks for it unseen. |
| `--code <none\|authenticator\|email>` | Where the code after the password comes from, if your app asks for one. The default is none. |
| `--secret-key-from <place>` | With `--code authenticator`, where the secret key is: env:NAME, file:`<path>` or stdin. Left out, a terminal asks for it unseen. |
| `--environment <environment>` | An environment that has this account: its ID, kind, host or computer name. Pass every, or leave it out, for every environment, those added later too. Repeat it for more than one. |
| `--dry-run` | Ask and check everything, then stop before anything starts or changes, and say what would happen. Off by default. |

Needs a sign-in with the `testing:run` scope and permission to manage projects.

```sh
# Add an account, answering each question
rehearsal accounts add

# Add one from a script, with the password in TEST_PASSWORD
rehearsal accounts add --label Owner --username owner@example.com --password-from env:TEST_PASSWORD --json

# Read the password from a password manager
rehearsal accounts add --label Owner --username owner@example.com --password-from stdin --json

# Add a passwordless account for staging only
rehearsal accounts add --label Member --sign-in passwordless --environment staging

# See what it would add, and add nothing
rehearsal accounts add --label Member --sign-in passwordless --dry-run
```

## rehearsal accounts change

Change a test account.

Only what you name changes. With no flags, it asks what to change, then asks for only that. The password changes only when you ask for it: type the new one when asked, or pass `--password-from`. How an account signs in never changes. To switch, remove the account and add another.

```sh
rehearsal accounts change <account> [flags]
```

| Argument | Description |
| --- | --- |
| `<account>` | The account's name or ID, as `rehearsal accounts list` shows it. |

| Flag | Description |
| --- | --- |
| `--workspace <workspace-id>` | Workspace ID. Defaults to `REHEARSAL_WORKSPACE_ID` or `rehearsal.config.json`, then to your only workspace or the one you pick. |
| `--project <project>` | Project ID, slug or name. Defaults to `REHEARSAL_PROJECT_ID` or `rehearsal.config.json`, then to the workspace's only project or the one you pick. |
| `--label <name>` | What the account is called, such as Owner. |
| `--role [<role>]` | What kind of user it is in your app, such as admin. The flag alone leaves the role out. |
| `--username <username>` | The username or email it signs in with. |
| `--password-from <place>` | Where its password is: env:NAME, file:`<path>` or stdin. The password itself is never a flag. Left out, a terminal asks for it unseen. |
| `--code <none\|authenticator\|email>` | Where the code after the password comes from now: none, authenticator or email. |
| `--secret-key-from <place>` | With `--code authenticator`, where the secret key is: env:NAME, file:`<path>` or stdin. Left out, a terminal asks for it unseen. |
| `--environment <environment>` | An environment that should have this account: its ID, kind, host or computer name. Pass every for every environment, those added later too. Repeat it for more than one. |
| `--dry-run` | Ask and check everything, then stop before anything starts or changes, and say what would happen. Off by default. |

Needs a sign-in with the `testing:run` scope and permission to manage projects.

```sh
# Pick what to change
rehearsal accounts change Owner

# Replace the password from a file
rehearsal accounts change Owner --password-from file:owner-password.txt --json

# Check a new secret key, and change nothing
rehearsal accounts change Owner --code authenticator --secret-key-from env:OWNER_TOTP_KEY --dry-run

# Keep it to two environments
rehearsal accounts change Owner --environment production --environment staging
```

## rehearsal accounts remove

Remove a test account.

Re:agent can no longer sign in as it, and runs still waiting to sign in as it are cancelled. A mailbox it has stops receiving mail.

```sh
rehearsal accounts remove <account> [flags]
```

| Argument | Description |
| --- | --- |
| `<account>` | The account's name or ID, as `rehearsal accounts list` shows it. |

| Flag | Description |
| --- | --- |
| `--workspace <workspace-id>` | Workspace ID. Defaults to `REHEARSAL_WORKSPACE_ID` or `rehearsal.config.json`, then to your only workspace or the one you pick. |
| `--project <project>` | Project ID, slug or name. Defaults to `REHEARSAL_PROJECT_ID` or `rehearsal.config.json`, then to the workspace's only project or the one you pick. |
| `--yes` | Remove it without asking first. |
| `--dry-run` | Ask and check everything, then stop before anything starts or changes, and say what would happen. Off by default. |

Needs a sign-in with the `testing:run` scope and permission to manage projects.

```sh
# Remove an account
rehearsal accounts remove Owner

# Remove it from a script
rehearsal accounts remove <account-id> --yes --json

# See which account it would remove
rehearsal accounts remove Owner --yes --dry-run
```
