> ## Documentation Index
> Fetch the complete documentation index at: https://vetta.sh/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# naive auth

> Sign in, inspect the active credential, and sign out.

`naive auth` manages the **credential**, not a session. It is the only group that runs without one.

Both sign-in paths end at `GET /v1/me`, which resolves the organization from the credential alone — so nothing here asks you for an `org_` id.

## Commands

| Command | Description |
| - | - |
| `naive auth login` | Store a credential for this profile. Aliased as `naive login`. |
| `naive auth register` | Create a user account from `--email`. A 6-digit code is mailed to it. |
| `naive auth resend-confirmation` | Mail a new 6-digit sign-in code to an address. |
| `naive auth whoami` | Show the active principal, organization, and scopes. Aliased as `naive whoami`. |
| `naive auth logout` | Delete this profile's stored credential. Aliased as `naive logout`. |

> [!NOTE]
>
> `login`, `logout`, and `whoami` are also top-level aliases, which is the spelling most examples use. `naive login` and `naive auth login` are the same handler.

## login

Two ways in: an **API key**, **or** `--email` with the 6-digit code mailed to it (`--code`) or the account's password (`--password`).

```bash theme={"system"}
read -rs KEY && printf '%s\n' "$KEY" | naive login  # an API key, piped on stdin (recommended)
naive login < ~/.secrets/naive-key                 # …or from a file you keep 0600
NAIVE_API_KEY=sk_live_... naive login              # CI: the key from the environment
naive login --email you@acme.com --code 123456     # person path: the mailed code, exchanged for a session token
naive login --email you@acme.com --password ...    # …or the password, if the account has one
```

The key is read from `--api-key`, then `NAIVE_API_KEY`, then stdin when it is piped. Any of these replaces the key the profile already holds, so piping a new key to `naive login` is how you rotate it. With none of them, `login` re-checks the key the profile holds. Prefer stdin or the environment: a key typed after `--api-key` is saved in your shell history.

| Flag | Description |
| - | - |
| `--email` | Email address. Must be passed with `--code` or `--password`. |
| `--code` | The 6-digit code that `register` or `resend-confirmation` mailed. |
| `--password` | Password, for an account that set one in Settings. |

`--api-key` is a [global flag](https://vetta.sh/docs/cli/overview.md#global-flags), which is why it is not in the table above.

The credential is proved and the organization learned in one call **before** anything is written, so a bad credential leaves no profile behind. The profile file is written `0600` and the credential is never printed back — only its 12-character display prefix.

> [!WARNING]
>
> The `--email` path stores a **session token**, which expires. Run `naive login` again when it does. For CI, use an API key: it does not expire until you revoke it.

## whoami

```bash theme={"system"}
naive whoami
```

```json theme={"system"}
{
  "profile": "prod",
  "base_url": "https://api.vetta.sh",
  "key_prefix": "sk_test_arhf",
  "principal": { "type": "key", "id": "key_66nnedy98yfx3ygzssfv99p7tf" },
  "organization": {
    "id": "org_gj9xg0gx6bpvdaysqvz68vr7b5",
    "name": "acme-staging",
    "mode": "test"
  },
  "scopes": ["admin"],
  "user": null
}
```

`user` is `null` when the principal is an API key rather than a person. `mode` is `test` for an `sk_test_…` credential and `live` for `sk_live_…`.

## register

```bash theme={"system"}
naive auth register --email you@acme.com
naive login --email you@acme.com --code 123456
```

| Flag | Description |
| - | - |
| `--email` | Email address for the new account. |

Creates the user with no password and mails a 6-digit code to the address. Sign in with that code to store a credential. A password is optional: set one later in the studio's Settings, once the address is proved.

Registering is not the last step: a new organization holds **no plan**, and every command outside billing is refused with `subscription_required` until it has one. Start it with [`naive plan subscribe`](https://vetta.sh/docs/cli/billing#the-plan) — Standard with a 7-day free trial when eligible, or `--plan pro` — complete the checkout page it prints, then `naive plan show` to confirm.

## resend-confirmation

The way out of a dead end: a code that never arrived, or a forgotten password. It is an **open** route — it runs without a credential, which is the point. It mails a new 6-digit sign-in code:

```bash theme={"system"}
naive auth resend-confirmation --email you@acme.com
```

```json theme={"system"}
{ "object": "auth_confirmation", "delivery": "sent" }
```

The reply is the same **whether or not that address has an account**. There is nothing here to branch on, deliberately: an endpoint that answered differently would be an account-enumeration oracle.

There is no password reset by mailed link. Sign in with the code (`naive login --email … --code …`), then set a new password in the studio's Settings.

The same operation is `client.auth.resendConfirmation` in the [SDK](https://vetta.sh/docs/sdk/typescript.md#method-index), and is described under [Authentication](https://vetta.sh/docs/api/authentication.md) in the API reference.

## logout

```bash theme={"system"}
naive logout
```

```json theme={"system"}
{ "profile": "prod", "logged_out": true }
```

Removes the credential for the **active profile** only. Other profiles are untouched. Use `--profile <name>` to sign a different one out.

## Profiles

Every `auth` command acts on the profile named by `--profile` (default: the last profile you logged into). This is what stops the next command silently aiming at production:

```bash theme={"system"}
printf '%s\n' "$WORK_KEY" | naive login --profile work
naive whoami --profile work
```

`login` on a new profile points it at the production API (`https://api.vetta.sh`). To use another deployment, pass `--api-base-url <url>` once on `login`; the profile remembers it. Every other command refuses a profile that was never logged into (`unknown profile`), so a mistyped `--profile` never runs against production.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.