Railway CLI: RAILWAY_API_TOKEN ignored by "railway link" — "Unauthorized. Please login with railway login"

After CLI v3.14.0, running railway link -p ... with RAILWAYAPITOKEN set always failed with "Unauthorized. Please login with railway login", breaking CI pipelines that relied on token auth. Part of the confusion in the thread was the two token types: RAILWAYAPITOKEN is an account token, while RAILWAY_TOKEN is a project token scoped to a single environment.

This was a CLI regression fixed in a later release — upgrade to the latest railway CLI and railway link works with RAILWAYAPITOKEN again (a maintainer verified the fix with a screenshot). Also use the right token for the job: RAILWAYAPITOKEN is an account token and is what railway link needs; RAILWAY_TOKEN is a project token scoped to one environment and is intended for railway up / railway run, not for linking. If you are on the latest CLI and link still fails, double-check you are exporting an account token, not a project token. Source: https://github.com/railwayapp/cli/issues/575

Source: https://github.com/railwayapp/cli/issues/575