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

# facet login

> Sign in to the facet registry

## Usage

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
facet login
```

Signs in to the registry by pasting a personal access token (PAT). Requires an interactive terminal.

## Exit codes

| Code | Meaning                                                          |
| ---- | ---------------------------------------------------------------- |
| `0`  | Signed in successfully.                                          |
| `1`  | Failed (non-interactive terminal, invalid token, network error). |

## What it does

<Steps>
  <Step title="Prompt for token">
    Presents an interactive menu. Select "Paste a token" and paste the PAT from your account at [agentfacets.io](https://agentfacets.io).
  </Step>

  <Step title="Verify token">
    Calls `GET /v0/auth/me` to confirm the token is valid. A typo or expired token fails immediately with the registry's own error message, and you are reprompted.
  </Step>

  <Step title="Persist credential">
    Writes the verified token to `$FACET_DIR/credentials` (default `~/.facet/credentials`) in INI format with mode `0600`.
  </Step>
</Steps>

## Credential file format

```ini theme={"theme":{"light":"github-light","dark":"github-dark"}}
[default]
token = fct_pub_xxxxxxxxxxxxx
```

The file is created with `0600` permissions so only the current user can read it.

## Token precedence

When both `FACET_TOKEN` and the credentials file are present, `FACET_TOKEN` takes precedence. The `login` command notes this so the environment variable does not silently shadow the file.

## See also

* [`facet whoami`](/cli/whoami) -- verify the signed-in identity.
* [`facet logout`](/cli/logout) -- remove saved credentials.
* [`facet publish`](/cli/authoring/publish) -- publish a facet (requires authentication).
