Skip to content
Project Token scope for usage queries, deployment stop/cancel and Volume billing cutoff
alonyarel
OP

16 days ago

We are preparing a small, time- and cost-bounded isolated test on an existing Hobby plan. Before creating a Project Token or test resources, we need to confirm the supported least-privilege route. The CLI docs describe Project Tokens as environment-scoped/deployment-related; the official CLI v5.58.0 schema exposes this query shape:

query UsageScope($projectId: String!, $from: DateTime!, $to: DateTime!) {
  usage(projectId: $projectId, startDate: $from, endDate: $to,
    includeDeleted: true,
    measurements: [MEMORY_USAGE_GB, CPU_USAGE, NETWORK_TX_GB, DISK_USAGE_GB, BACKUP_USAGE_GB],
    groupBy: [ENVIRONMENT_ID, SERVICE_ID, VOLUME_ID]) {
    measurement
    value
    tags { projectId environmentId serviceId volumeId }
  }
}

All variables are placeholders; no token/API call has been used to test this.

  1. May a Project Token bound to one environment execute usage in this form? If supported, please provide the supported request shape and clarify whether the server returns only its bound environment, all project environments, or workspace data. Is environment isolation enforced by authorization or only by client filtering? Does estimatedUsage(projectId: ..., measurements: ...) support this token, and what scope does that result cover?
  2. Are these raw usage measurements or monetary billing amounts? What are the exact units for each measurement/value, update frequency and maximum reporting delay? Which charges are excluded (for example retained/deleting Volumes, backups, egress, platform fees/taxes or other billable usage)? How should deleted resources remain attributable until their final charge is visible?
  3. If this Project Token cannot read the required usage, is there an officially supported narrower read-only usage route that does not require account/workspace management credentials?
  4. The API examples list deploymentStop(id) for running deployments and deploymentCancel(id) for building/queued deployments. Can the same environment-bound Project Token execute both, with server-enforced rejection outside its environment? What is the supported handling for DEPLOYING, and do any additional environment-scoped actions/settings prevent pending or automatic redeployment after a stop?
  5. Volume documentation says deletion is queued and permanent deletion occurs within 48 hours. At what exact event does storage billing stop: accepted deletion request, unmount, physical deletion, or another event? Is the recoverable 48-hour window billed, and what supported status/receipt confirms the billing cutoff?

We are requesting technical information only. Public documentation/examples or a precise permission statement would let us prepare the controller without creating a broader credential.

References:

https://docs.railway.com/cli/deploying

https://raw.githubusercontent.com/railwayapp/cli/v5.58.0/src/gql/schema.json

https://docs.railway.com/integrations/api/manage-deployments

https://docs.railway.com/volumes/reference

Solved

3 Replies

Status changed to Awaiting Railway Response Railway • 16 days ago


Railway
BOT

16 days ago

The usage and metrics queries are supported with a workspace-scoped API token. We can't confirm that an environment-bound Project Token can run usage or estimatedUsage, so we can't state what scope it would return, and there is no read-only usage token narrower than a workspace token. A workspace token covers that workspace, so any per-environment view comes from your own groupBy and filtering.

usage returns aggregated resource usage, not monetary amounts, metered per minute, and also accepts DEPLOYMENT_ID and DEPLOYMENT_INSTANCE_ID in groupBy. There is no real-time cost figure and no guaranteed maximum reporting delay; usage typically appears within a few minutes, and responses are briefly cached. Once a deployment reaches REMOVED it produces no further samples, so polling until the run's total stops moving is a sound completion rule.

deploymentStop stops the container but leaves the deployment reporting SUCCESS, giving no completion signal. deploymentRemove drains with SIGTERM, escalates to SIGKILL after the service's draining seconds (default 0), and moves the deployment through REMOVING to REMOVED after teardown completes. deploymentCancel applies only to building or queued deployments. A removed deployment only comes back through a new deployment you trigger or a platform-initiated migration.

Volume storage, including retained backups, keeps billing during the 48-hour recoverable window after deletion is applied, and detaching does not stop it. There is no self-serve control to shorten that window for a single volume.


Status changed to Awaiting User Response Railway • 16 days ago


alonyarel
OP

15 days ago

Thank you. Could a Railway technical colleague confirm the following, or link explicit official documentation? We need the platform and token permission contract, not help designing a controller.

  1. Can a Project Token bound to one environment execute the usage query in the original post? If not, please explicitly state that it is unsupported for this token, and whether a narrower read-only alternative exists.

  2. Which exact API mutation is supported to stop/remove a deployment in that environment using a Project Token? Please confirm the accepted token type and server-enforced authorization scope; availability of Remove in the dashboard alone does not answer this.

  3. Does Volume storage billing stop when deletion is requested/accepted, or only at permanent deletion? Please link the official billing rule. If no cutoff timing is guaranteed, please state that explicitly.

We have recorded that measurement reporting has no guaranteed maximum delay and are not requesting one again. We will not treat estimated costs or delayed usage as a guaranteed budget cap.

Technical clarification only; no account changes or resource actions are requested.

Thank you.


Status changed to Awaiting Railway Response Railway • 15 days ago


Railway
BOT

15 days ago

Project tokens are scoped to a single environment within a project, and the server only accepts them for requests to that environment (Public API tokens). They use the Project-Access-Token header, and you can read the bound environment with query { projectToken { projectId environmentId } }. If a token is used outside its scope, the API returns HTTP 200 with a Not Authorized entry in the errors array.

On question 1, we can't confirm that usage or estimatedUsage run with an environment-bound project token, so treat them as unsupported for that token type. We also have no read-only usage credential narrower than a workspace token, which covers the whole workspace.

On question 2, we can't confirm which deployment mutations a project token is accepted for. The only scope we can state is the environment-level scope above, and we don't have a per-mutation permission list for deploymentStop, deploymentRemove or deploymentCancel with that token.

On question 3, volume storage billing does not stop when deletion is requested or accepted. Stored data and retained backups keep billing through the 48-hour recoverable window after the deletion is applied, and detaching the volume does not stop it. We don't publish an exact cutoff timestamp or a receipt that marks the end of billing, and usage reporting is not instant.


Status changed to Awaiting User Response Railway • 15 days ago


Railway
BOT

8 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 • 8 days ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...