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

a day 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 Railway Response

10 Replies

Railway
BOT

a day 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 23 hours ago


wraithon
OP

19 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 19 hours ago


Railway
BOT

19 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 19 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

19 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 19 hours ago


19 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 19 hours ago


mykal

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](https://docs.railway.com/integrations/api/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.

wraithon
OP

15 hours ago

Thanks, mykal. Saving the source without deploying worked, and the owner deployment built the requested commit. Our separate project-token identity check then returned HTTP 200 with GraphQL INTERNAL_SERVER_ERROR and neither scope ID. We stopped before staging or submitting B.

Your Public API guide shows projectToken { projectId environmentId } with Project-Access-Token. Is this the supported way to verify both IDs using only a project token in a fresh environment with no services or deployments? If it returns this error, what read-only diagnostic or alternative do you recommend, and which redacted details would help your team trace it?


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


Railway
BOT

15 hours ago

Yes. Sending query { projectToken { projectId environmentId } } with the Project-Access-Token header is the supported way to confirm both IDs using only a project token. It doesn't depend on the environment having any services or deployments.

An INTERNAL_SERVER_ERROR code with HTTP 200 and no IDs usually means the request was refused, not that the server crashed. Our authorization errors don't set their own GraphQL code, so they show up with that default code. Check the error's message field: Not Authorized means the token wasn't accepted for that query.

When that happens, the cause is usually one of three things. The token may have been sent as Authorization: Bearer instead of Project-Access-Token. The value may be truncated or have extra whitespace. Or the token may have been deleted or regenerated since you copied it. You can see whether the token still exists in that environment's project tokens list under the project's settings.

If the header and token both check out and the query still fails, please send the exact error message text, the header name you used, and the request time in UTC. Leave out the token value itself.


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


Railway

Yes. Sending `query { projectToken { projectId environmentId } }` with the `Project-Access-Token` header is the supported way to confirm both IDs using only a project token. It doesn't depend on the environment having any services or deployments. An `INTERNAL_SERVER_ERROR` code with HTTP 200 and no IDs usually means the request was refused, not that the server crashed. Our authorization errors don't set their own GraphQL code, so they show up with that default code. Check the error's `message` field: `Not Authorized` means the token wasn't accepted for that query. When that happens, the cause is usually one of three things. The token may have been sent as `Authorization: Bearer` instead of `Project-Access-Token`. The value may be truncated or have extra whitespace. Or the token may have been deleted or regenerated since you copied it. You can see whether the token still exists in that environment's project tokens list under the project's settings. If the header and token both check out and the query still fails, please send the exact error `message` text, the header name you used, and the request time in UTC. Leave out the token value itself.

wraithon
OP

3 hours ago

We staged 13 new synthetic service variables with isSealed: true. Before commit, the staged patch showed only a string-valued value field for each name. We inspected field types only and discarded the patch.

Is there a supported, read-only way to confirm that a named service variable will be sealed by that specific pending patch, without reading its value or committing the patch? If so, which API field, dashboard indicator or audit event identifies both the seal state and the patch it belongs to? If there is no supported check, could someone confirm that?


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


Railway
BOT

3 hours ago

We can't confirm a supported read-only check that shows a specific pending patch will seal a named variable before you commit it. Reading environmentStagedChanges without decryptVariables returns the patch structure and variable names with values left encrypted. Your result showed only a value field for each name, and we can't point you to a separate seal field or patch-specific audit event to use instead.

Once a variable is sealed, its value is provided to builds and deployments but can't be read from the dashboard or the API, and sealing can't be undone (Using Variables). Because of that, if your workflow relies on seal state, validate it with synthetic variables in a disposable environment before using it anywhere it matters.


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


Railway

We can't confirm a supported read-only check that shows a specific pending patch will seal a named variable before you commit it. Reading `environmentStagedChanges` without `decryptVariables` returns the patch structure and variable names with values left encrypted. Your result showed only a `value` field for each name, and we can't point you to a separate seal field or patch-specific audit event to use instead. Once a variable is sealed, its value is provided to builds and deployments but can't be read from the dashboard or the API, and sealing can't be undone ([Using Variables](https://docs.railway.com/variables#sealed-variables)). Because of that, if your workflow relies on seal state, validate it with synthetic variables in a disposable environment before using it anywhere it matters.

wraithon
OP

3 hours ago

Could a Railway team member confirm whether there’s a supported read-only way to verify that a newly staged service variable will be sealed by that specific pending patch, before committing it and without reading its value? We staged it with isSealed: true, but the staged readback didn’t expose the flag. If there’s no supported pre-commit check, please confirm that too.


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


Welcome!

Sign in to your Railway account to join the conversation.

Loading...