Railway
Connect
Connect Railway from the terminal. Pass --help for the flags Railway accepts, plus --no-browser for headless environments.
polylane cloud connect --provider railwayOAuth authorization.
Connect your Railway workspace through OAuth. Polylane encrypts the tokens before it stores them, and the agent never sees them.
- Click Continue to Railway in Polylane.
- Sign in to Railway and approve the viewer access that Polylane asks for.
- Railway sends you back to Polylane, and the first sync starts.
To send deploy failures and alerts to Polylane, add a webhook as described under Deploy and alert webhooks.
Connect Railway from a CI job or any other environment without a browser.
Connecting Railway needs no browser: the same endpoint the console calls fits in a CI job. One authenticated POST creates the connection and starts the first sync.
Prerequisites
- A Polylane API key with the
cloud_accounts:writeandcloud_accounts:readscopes. See API keys and OAuth. - Your workspace ID, which starts with
ws_. Read it fromGET /v1/workspaceswith the same key. - A Railway workspace token from your workspace settings. The console's OAuth flow needs a browser; workspace tokens do not.
Create the connection
curl -X POST https://api.polylane.com/v1/cloud_accounts \
-H "x-api-key: $POLYLANE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"provider": "railway",
"workspaceId": "ws_0abc123",
"token": "<railway-workspace-token>"
}'
One call connects every Railway workspace the token can reach; pass the optional railwayWorkspaceId to connect just one.
The response lists what was connected, with the first sync already running. Trimmed to the two fields the rest of the flow reads:
{
"success": true,
"result": {
"provider": "railway",
"accounts": [{ "id": "acc_34gky74ibc92h8t2efn8csrh", "status": "syncing" }],
"failures": []
}
}
An account that is already connected lands in failures instead of accounts, so repeating the call never duplicates a connection.
Wait for the first sync
Poll each returned account by its id until status reaches ready (new on registration, syncing while resources stream in):
until [ "$(curl -s "https://api.polylane.com/v1/cloud_accounts/$WORKSPACE_ID/$ACCOUNT_ID" \
-H "x-api-key: $POLYLANE_API_KEY" | jq -r '.result.status')" = "ready" ]; do
sleep 15
done
Give the loop a deadline so a failed connect fails the job instead of hanging it. Once the account is ready, its resources are in the topology and Polylane has started its first check.
Disconnect from the API
Deleting the connection stops every sync and check and deletes the credentials Polylane held. The call needs the cloud_accounts:delete scope:
curl -X DELETE "https://api.polylane.com/v1/cloud_accounts/$WORKSPACE_ID/$ACCOUNT_ID" \
-H "x-api-key: $POLYLANE_API_KEY"
Then revoke the Railway credential, as described under Disconnecting.
How it works
Resources in the context graph
Polylane maps your projects, environments, services, the 20 most recent deployments of each project, volumes, domains, TCP proxies and notification rules. It syncs every 15 minutes, and about two minutes after a deployment event from the webhook.
Sync stores the names of your variables on each service and environment, not their values.
Pull request environments appear in the graph. Polylane monitors only the production environment until you turn on Pull request, staging and development environments in the account settings.
Deploy failures and alerts become issues
When you add the webhook, these Railway events open an issue, or add to the open issue for the same service:
- a failed, crashed or out-of-memory deployment
- a volume alert or a monitor alert
- other Railway notices with the severity NOTICE, WARNING or CRITICAL
A successful deployment resolves the deployment issue. A resolved volume alert or monitor alert, or a deleted monitor, resolves its issue. Polylane triages each issue and investigates it. Polylane ignores events from pull request environments.
Anomaly detection
Each service gets its own monitor. Polylane reads its CPU, memory, network, disk and ephemeral disk use, its runtime logs and its deployments. Each volume reports its disk and backup use. Polylane compares each series with its usual level, and opens an issue when a change is a real problem.
What agents can do
During an investigation, agents read runtime logs, build and HTTP logs, deployments, metrics, domains, TCP proxies and usage estimates. With the webhook, agents can set a watch that wakes a thread when the next deployment of a service lands. Agents can check whether a variable is set. They see a value only for a short list of names that are not secret, such as NODE_ENV and PORT.
Agents can also request a fixed list of changes: restart, redeploy, roll back, stop or cancel a deployment, and change replicas, regions or limits. With the OAuth grant, Polylane has viewer access only, and Railway refuses these changes. They work when the account uses a Railway token that can write. The account is read-only by default, and each change needs safety review and approval before it runs.
Deploy and alert webhooks
Railway sends deployment changes and alerts through notification rules. Add one rule for each Railway workspace:
- Copy the webhook URL from the Webhooks card on the account's Settings page in Polylane. It has the form
https://sinks.polylane.com/v1/railway/<Railway workspace ID>. - In Railway, open the Notifications settings of your workspace and add a webhook rule with that URL.
- Select the Deployment events:
Deployment.deployed,Deployment.failed,Deployment.crashedandDeployment.oom_killed. Railway's success event isDeployment.deployed. There is noDeployment.success. - Select the VolumeAlert and Monitor events, and include
VolumeAlert.resolvedandMonitor.resolved.
Railway does not sign webhooks. Polylane accepts a delivery only when the workspace ID in the URL matches a connected account and the workspace in the payload.
Troubleshooting
Authorization fails or is canceled
- Sign in to Railway with an account that can open the workspace.
- Start again from Continue to Railway. The authorization link is valid for a few minutes only.
Missing resources
- The first sync can take a few minutes.
- Click Sync in the account header to sync again.
Disconnecting
Disconnecting does not change Railway. Revoke the OAuth grant in your Railway account settings, and delete the notification rule if you added one.
Disconnect
Disconnecting stops every sync and check and deletes the credentials Polylane held. Polylane removes what Railway's API lets it remove. The following stays until you remove it yourself:
- OAuth grant
polylane cloud disconnect <id>Tools
4Operations agents can perform in threads.
Supported resources
8Resource types that show up in your infrastructure graph.