8 months ago
Hi! I need some help regarding the Railway Public API.
I'm trying to temporarily disable (pause/sleep) a web service in my project using the API, without deleting it — and later I want to re-enable it.
Is there a supported way to pause or stop a deployment or service via the API?
Any help or guidance would be greatly appreciated. Thank you!
Is it possible to disable (or pause) a web service using the Railway API through a Python request — without deleting it?
I just want to stop it temporarily and restart it later via API.
19 Replies
8 months ago
https://docs.railway.com/guides/manage-deployments
If I had to guess, you would use
mutation deploymentRemove {
deploymentRemove(id: "deployment-id")
}8 months ago
I'll look for the HTTP API request
8 months ago
{
"query": "mutation deploymentRedeploy($id: String!) {\n deploymentRedeploy(id: $id) {\n id\n }\n}",
"variables": {
"id": "6ddf3b71-a1a0-4cd9-ae9b-4c59160fff77"
},
"operationName": "deploymentRedeploy"
}For a raw HTTP request. ID is the service ID.
Hello,
I was able to successfully perform the deploymentRemove operation by following these steps:
First, I retrieved the latest active deployment ID using this Python code:
After getting the deployment_id, I ran this code to remove the deployment:
8 months ago
Yeah gimme a sec
If I can click "Redeploy" on the last deployment it would be great. But if I click "Deploy" and pull from my github repository it would also work.
8 months ago
you probably want deploymentStop and deploymentRestart
8 months ago
Sigh
but in the railway frontend, it doesn't show when the application is stopped or paused
8 months ago
You also obviously need to put your actual API token
@Brody using deploymentStop and deploymentRestart in the python code, it only shows in the terminal:
API response:
200
{"data":{"deploymentRestart":true}}
JSON content:
{'data': {'deploymentRestart': True}}
but in the railway frontend it still has the status "Active"