Skip to content
Can a project token commit staged changes in its own environment?
wraithon
OP

7 hours ago

Can an environment-scoped project token authenticated with Project-Access-Token call environmentPatchCommitStaged with skipDeploys: false in its own environment? If so, is a matching projectToken { projectId environmentId } response sufficient under Railway’s authorization policy, or can another permission or restriction block that mutation? What documented rule or read-only check can we use before committing any changes?

Awaiting User Response

5 Replies

Railway
BOT

7 hours ago

A matching projectToken { projectId environmentId } response only confirms which project and environment the token is scoped to. It doesn't confirm the token is allowed to run any particular mutation. Project tokens can only authenticate requests for their own environment, and they're intended for deployment-related actions such as railway up, redeploys and viewing logs.

Other rules can still block environmentPatchCommitStaged. Committing staged changes that are destructive, such as deleting a service, requires Admin access to the project and environment. Having permission to stage a change doesn't mean you have permission to apply it. Whether a project token can commit a particular changeset in its own environment depends on what that changeset contains, and skipDeploys doesn't change those permission requirements.

Apart from projectToken, there's no read-only query that checks this permission ahead of time. If the commit is refused, the API returns HTTP 200 with an errors entry whose message is Not Authorized, so check the errors array rather than the status code alone. Before committing anything that affects production, try the same token and the same kind of change in a separate test environment.


Status changed to Awaiting User Response Railway • about 7 hours ago


wraithon
OP

3 hours ago

On a new Railway service, can an owner link a GitHub branch whose tip is B, pin the service to its parent commit A, and save that configuration with zero deployments? Does skipDeploys: true support this, and which read-only field confirms that A is the effective commit?


Status changed to Awaiting Railway Response Railway • about 3 hours ago


Railway
BOT

3 hours ago

The way we support targeting a specific commit like A, rather than the branch tip B, is the commitSha argument on serviceInstanceDeployV2. That call validates the SHA against the connected repo and creates a deployment of that commit, so it doesn't save a pinned commit with zero deployments (Manage Services). An unknown SHA returns "Commit not found" and no deployment is created.

skipDeploys controls whether a change triggers a redeploy. We can't confirm that skipDeploys: true lets a service store a pinned parent commit before its first deployment. We also can't name a read-only field that shows the effective commit before any deployment exists. Once a deployment exists, check that deployment's own commit metadata to see which commit it built.

If your workflow depends on pinning a commit without deploying it, test it first in a separate environment that doesn't affect production.


Status changed to Awaiting User Response Railway • about 3 hours ago


Railway

The way we support targeting a specific commit like A, rather than the branch tip B, is the `commitSha` argument on `serviceInstanceDeployV2`. That call validates the SHA against the connected repo and creates a deployment of that commit, so it doesn't save a pinned commit with zero deployments ([Manage Services](https://docs.railway.com/integrations/api/manage-services)). An unknown SHA returns "Commit not found" and no deployment is created. `skipDeploys` controls whether a change triggers a redeploy. We can't confirm that `skipDeploys: true` lets a service store a pinned parent commit before its first deployment. We also can't name a read-only field that shows the effective commit before any deployment exists. Once a deployment exists, check that deployment's own commit metadata to see which commit it built. If your workflow depends on pinning a commit without deploying it, test it first in a separate environment that doesn't affect production.

wraithon
OP

3 hours ago

Thanks. Could a Railway team member confirm whether there’s a supported way to link a GitHub branch whose tip is B, pin a new service to its parent commit A, and save that configuration without creating a deployment?

Specifically, does environmentPatchCommitStaged with skipDeploys: true prevent a deployment on the initial source link? If so, which read-only API field or dashboard view confirms that A is the saved, effective commit, rather than just a staged value or the branch tip?

If there’s no supported way to set and verify that baseline before the first deployment, please confirm that too. We’re trying to reserve the only deployment in a disposable test for a separate project-token permission check.


Status changed to Awaiting Railway Response Railway • about 3 hours ago


2 hours ago

You can commit staged changes without triggering deploys. In the dashboard that's the "commit without triggering deploys" option (Alt+Shift+Enter), and the API equivalent is committing with skipDeploys: true. That covers saving config such as a service's repo and branch without starting a deployment.

The supported way to target a specific commit like A, instead of the branch tip B, is the commitSha argument on serviceInstanceDeployV2. That call creates a deployment of that commit, so it doesn't save A as a pinned baseline with zero deployments (Manage Services).

We can't confirm a supported way to save A as the effective commit on a new service before its first deployment. We also can't point you to a read-only API field or dashboard view that shows A as the saved commit before then. environmentStagedChanges shows only what's staged, not what's in effect. Once a deployment exists, that deployment's commit metadata shows which commit was built.

For your test, we recommend deploying A directly with commitSha and not trying to set a pinned baseline first.


Status changed to Awaiting User Response mykal • about 3 hours ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...