a month ago
How can I generate a project token for a PR deployment, given that these environments are dynamically created and torn down? Is this even possible?
My objective here is to be able to use the token to query railway deployment and extract the status of the PR deployments on a per-PR basis.
While using an account token technically would work, I'd prefer a more granular and more centralized approach.
Additionally, the account token is even less favourable as it doesn't work with the railway CLI (see here), and there's no way to create a project token that applies to all the environments in the project.
1 Replies
a month ago
Hi,
First, you can find our up to date documentation on the CLI at https://docs.railway.com/guides/cli#tokens -- we do support account tokens.
For working with PR environments programmatically, you'll want to use an account-level token instead of a project token. Project tokens are tied to a specific environment within a project, which doesn't work well when you're dealing with dynamically created PR environments. We do not offer more granular permissioning.
Generate your token from Account Settings and make sure it's scoped to whichever workspace your project is in.
Once you have your account token, you can use the Railway CLI or Public API to query deployment status for any PR environment. With the Public API, just set the Authorization header to Bearer <your-account-token> and you'll be able to fetch deployment information for your PR environments (they're typically named pr-<number>).
From the CLI, you can just do railway link --project ***** -- ENVIRONMENTNAME -- service SERVICENAME
Let us know if you have other questions.
Kind regards,
Sam
Status changed to Awaiting User Response Railway • 27 days ago
20 days ago
This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!
Status changed to Solved Railway • 20 days ago