api
marciogarcia590
HOBBYOP

10 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

9 months ago

https://docs.railway.com/guides/manage-deployments

If I had to guess, you would use

mutation deploymentRemove {
  deploymentRemove(id: "deployment-id")
}

marciogarcia590
HOBBYOP

9 months ago

How use the "Redeploy" button using the API?


9 months ago

I'll look for the HTTP API request


marciogarcia590
HOBBYOP

9 months ago

ok, I hope


9 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.


marciogarcia590
HOBBYOP

9 months ago

Hello,
I was able to successfully perform the deploymentRemove operation by following these steps:

  1. First, I retrieved the latest active deployment ID using this Python code:


marciogarcia590
HOBBYOP

9 months ago

  1. After getting the deployment_id, I ran this code to remove the deployment:


marciogarcia590
HOBBYOP

9 months ago

thank you


9 months ago

Yeah gimme a sec


marciogarcia590
HOBBYOP

9 months ago

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.


9 months ago

you probably want deploymentStop and deploymentRestart


marciogarcia590
HOBBYOP

9 months ago

Amazing, deploymentStop and deploymentRestart worked perfectly


marciogarcia590
HOBBYOP

9 months ago

I used this code:


9 months ago

Sigh


marciogarcia590
HOBBYOP

9 months ago

but in the railway frontend, it doesn't show when the application is stopped or paused


9 months ago

You also obviously need to put your actual API token


marciogarcia590
HOBBYOP

9 months ago

How? Could you show me how I do it in the code?


marciogarcia590
HOBBYOP

9 months ago

strange, I never had a problem with my database


marciogarcia590
HOBBYOP

9 months ago

@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"


Loading...