Authenticate with an API key for scripts
getting started
// what it does
For CI and scripts, generate a user API key from the Cursor dashboard and expose it as the CURSOR_API_KEY environment variable — the CLI picks it up automatically with no login step. Alternatively pass --api-key <key> on the command line. The env var is preferred so the key never lands in shell history or process listings.
// shell
$ export CURSOR_API_KEY=key_your_token_here$ cursor-agent -p "run the test suite and report failures"// gotcha
Browser login and API-key auth are separate; in CI there is no browser, so a missing or wrong CURSOR_API_KEY surfaces as "Not authenticated" errors rather than a login prompt.