## Using Stripe API keys

The recommended way to connect the Stripe CLI to your account is the browser-based login flow provided by [stripe login](https://docs.stripe.com/cli/login.md). The CLI stores your credentials in your operating system's secure credential store (when available) and refreshes the session automatically.

To authenticate with an [API key](https://docs.stripe.com/keys.md) instead, use one of these options:

1. [stripe login --interactive](https://docs.stripe.com/cli/login.md)
1. [stripe config](https://docs.stripe.com/cli/config.md)
1. The `--api-key` flag
1. Environment variables

Use `stripe login --interactive` to enter an API key manually.

Using `stripe config` allows you to set persistent keys manually:
- `stripe config --set test_mode_api_key sk_test_123`

`--api-key` is a global flag that overrides your local configuration if you need to run one-off commands with a specific API key.

You can set two environment variables, which take precedence over all other values:

- `STRIPE_API_KEY`: the API key to use for the CLI.
- `STRIPE_DEVICE_NAME`: the device name for the CLI, visible in the Dashboard.
