Authenticate with the Fastly CLI
Quick start
Pick whichever method suits your workflow:
fastly auth login # paste an API token interactivelyfastly auth login --sso --token <name> # authenticate via browser-based SSOBoth store a default token so subsequent commands authenticate automatically.
Token sources and precedence
The CLI resolves a token in this order (first match wins):
--tokenflag (a raw token string, or the name of a stored auth token). Not available whenFASTLY_DISABLE_AUTH_COMMANDis set.FASTLY_API_TOKENenvironment variableprofilefield in your project'sfastly.toml- Default auth token from the CLI config file
Stored tokens
You can store multiple named tokens and switch between them:
fastly auth add staging --api-token $STAGING_TOKENfastly auth listfastly auth use stagingfastly auth show stagingfastly auth delete stagingNon-interactive usage
In CI/CD or scripts where interactive prompts are not available, supply a token via the flag or environment variable:
fastly service list --token $MY_TOKENFASTLY_API_TOKEN=... fastly service listManaged environments
If FASTLY_DISABLE_AUTH_COMMAND is set, both the fastly auth command tree and the --token global flag are disabled. Authentication is expected to be handled externally via FASTLY_API_TOKEN or pre-configured stored tokens. Background SSO refresh flows are unaffected.
Generating a token
Create an API token at: https://manage.fastly.com/account/personal/tokens