In short: when a client asks you to start, restart or reinstall their server, your own system can do it through the API, without opening Meu MozOut. Each action goes into a queue and comes back with a number you follow to the end. Anything that deletes data, such as a reinstall, needs a permission of its own and the server name in the request. This covers VPS and Cloud; dedicated servers are handled with our team. See the server reseller page.
One key for everyday tasks, another for anything that wipes
| Task |
Permission |
| See the servers and the state of each one |
vps:read |
| Start, stop and restart |
vps:write |
| Reinstall the system |
vps:reinstall (sensitive) |
| Restore a backup |
vps:restore (sensitive) |
| Create a new root password |
vps:password (sensitive) |
The three sensitive ones are off on every key. If your system gives the client a "restart" button, that key has no business reinstalling anything. Keep the sensitive permissions on a separate key, used only when a request calls for it. More in sensitive API permissions.
Start, stop and restart
| 1 |
Check the state with GET /v1/servers/{id}. power_state says running, stopped, restarting or another state. The id is the same as the service's.
|
|
| 2 |
Ask for the action with POST /v1/servers/{id}/start, stop or restart. The answer is 202 with an action_id.
|
|
| 3 |
Follow it with GET /v1/actions/{id}: running while it runs, then done or failed. Starting usually takes about 2 minutes and stopping about 6. Only the key that asked for the action can look it up.
|
|
ACTION=$(curl -s -X POST https://api.mozout.co.mz/v1/servers/700/start \
-H "Authorization: Bearer $MOZOUT_API_KEY" -H "X-API-Mode: production" | jq -r '.data.action_id')
curl -s https://api.mozout.co.mz/v1/actions/$ACTION \
-H "Authorization: Bearer $MOZOUT_API_KEY" | jq -r '.data.status'
The X-API-Mode: production header makes sure the request never runs with the wrong key: if the key is a Sandbox one, the API refuses it. If the action ends failed with timed_out, check the server state before trying again. More on the action_id in long-running API operations.
Reinstalling, with a backup first
| 1 |
Pick the system from GET /v1/servers/{id}/operating-systems and keep its id.
|
|
| 2 |
Ask for the reinstall with POST /v1/servers/{id}/reinstall: confirm with the server name (the name from GET /v1/servers/{id}), operating_system and backup_first, plus the Idempotency-Key header.
|
|
| 3 |
Save the root password straight away. It appears only in that response and works once the reinstall has finished. Retrying with the same Idempotency-Key does not create another.
|
|
| 4 |
Follow it with the action_id. With backup_first set to true, the reinstall starts on its own once the backup appears, which can take up to an hour.
|
|
curl https://api.mozout.co.mz/v1/servers/700/reinstall -X POST \
-H "Authorization: Bearer $MOZOUT_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: request-318-reinstall" \
-d '{"confirm": "web1.asuaempresa.co.mz", "operating_system": "ubuntu-24.04", "backup_first": true}'
|
A reinstall deletes everything on the server. Confirm with your client before you ask for it. If the server already has 4 backups, a request with a backup first answers 409 backup_limit_reached and deletes nothing. There is a limit of 3 reinstalls or restores per hour across the account. Afterwards your client can log in with an SSH key, as we explain in how to create an SSH key.
|
Your client lost the root password
POST /v1/servers/{id}/password creates a new one, with vps:password and the server name in confirm. The server restarts to apply it, and the password works after 1 to 2 minutes. As with a reinstall, it appears only in the response: pass it to your client over a safe channel and keep it out of your system's logs.
The answers your system should expect
| Answer |
When |
What to do |
| 409 already_running / already_stopped |
The server is already the way you asked. |
Nothing. Tell your client it already was. |
| 409 server_stopped |
You asked to restart a server that is off. |
Use start. |
| 409 action_in_progress |
The server is busy with another action. Its action_id is in details. |
Follow that one instead of asking again. |
| 409 service_not_active |
The service is suspended: data can be read, actions cannot run. |
Check the unpaid invoices in Meu MozOut. |
| 429 rate_limited |
15 seconds between actions on the same server, 10 actions per minute per account, 5 new passwords per hour. |
Wait the seconds in Retry-After. |
|
Want to handle your clients' requests from your own system? See the server reseller page.
See server reselling
|