---
title: stx login
description: Authenticate the CLI with your Syntext account via browser or API token.
icon: key
---

# stx login

Authenticate with Syntext. Credentials are stored locally and used by commands that talk to the Syntext API (`stx deploy`, `stx build`, `stx projects`, `stx connect`).

## Usage

```bash
stx login [options]
```

## Options

| Flag | Type | Default | Description |
|------|------|---------|-------------|
| `--token <token>` | string | | API token (skips interactive login) |
| `--api-url <url>` | string | `https://api.syntext.dev` | Custom API URL (self-hosted) |

## Interactive Login (Recommended)

```bash
stx login
```

Starts a device flow: your browser opens to a verification page, you approve the request, and the CLI picks up the session automatically.

```
  Syntext CLI Login

  Opening browser to complete login...

  If the browser doesn't open, visit:
  https://syntext.dev/device?code=XXXX-XXXX

✔ Authenticated as Jane Doe (jane@example.com)
```

## Token-Based Login (CI / Headless)

For CI pipelines or machines without a browser:

1. Go to [syntext.dev/settings/tokens](https://syntext.dev/settings/tokens)
2. Create a new CLI token
3. Authenticate non-interactively:

```bash
stx login --token stx_xxxxxxxxxxxx
```

The token is validated against the API before it's saved.

<Note>
In CI you can also skip `stx login` entirely and set the `SYNTEXT_API_KEY` environment variable — see [CI/CD guide](/guides/ci-cd).
</Note>

## Logging Out

Remove stored credentials at any time:

```bash
stx logout
```

## Related

- [stx connect](/cli/connect) — link local docs to a project
- [stx projects](/cli/projects) — manage projects from the CLI
- [CI/CD](/guides/ci-cd) — deploying from pipelines
