# Reinstall a server

`POST https://console.advinservers.com/api/v1/client/servers/{server}/settings/reinstall`

### Overview

Reinstalls the server and **permanently erases all existing disk data**. Take a backup or snapshot first if you need to keep it. Send `template_uuid` from the server's available operating systems, or `marketplace_app` with an app's ID to install that app instead. Send the settings the app asks for in `app_variables`, and optionally `custom_domain`, a domain that is already a CNAME for the server's own domain name. Provide `account_password`, up to 25 key IDs in `ssh_keys`, or both. A password is required when no keys are supplied and for all Windows installations. A Windows password needs at least three of uppercase letters, lowercase letters, numbers and symbols, may not contain `Administrator`, and may be at most 127 characters. Optionally select a setup script with `user_script`. `start_on_completion` defaults to true.

Instead of an operating system or an app, you may send `iso` with the ID of a finished image from your ISO library: the server is rebuilt with an empty disk and starts from the image, so you install the system yourself over the console. Or send `backup` with the ID of a finished backup of one of your servers, including this one: the server is rebuilt and that backup restored onto it, bringing that server's system, files, keys and passwords. The backup must have been taken from a disk no larger than this server's, this server may not have a second disk, and its host must be able to read the backup. Neither takes SSH keys, a setup script or a root password. A restore copies the whole disk, so it can take a while for a large backup.

Installation runs in the background. The server enters an installing state; use `installation_progress` to track it. The request is rejected while another server operation is running.

### Permissions

Requires the `server.reinstall` (Reinstall servers) permission for the selected team. Resources outside that team return 404.

## Authorization

Send `Authorization: Bearer <token>` with the request. Your API key, sent as a bearer token. Create one in the control panel under API Keys, give it only the permissions the integration needs, and copy it when it is created. It cannot be shown again. Each key is restricted to one owned team. The key determines the team for every request.

## Path parameters

- `server` (string, required): The server uuid short

## Body

Sent as `application/json`.

- `template_uuid` (string | null): The template uuid UUID.
- `marketplace_app` (string | null): The value of `marketplace_app`. Exactly 36 characters
- `iso` (string | null): The value of `iso`. Exactly 36 characters
- `backup` (string | null): The value of `backup`. Exactly 36 characters
- `app_variables` (string[]): The value of `app_variables`. At most 50 items
- `custom_domain` (string | null): The value of `custom_domain`. At most 253 characters
- `account_password` (string | null, required): The value of `account_password`. 5 to 191 characters
- `start_on_completion` (boolean): The value of `start_on_completion`.
- `ssh_keys` (string[]): The value of `ssh_keys`. At most 25 items
- `user_script` (string | null): The value of `user_script`. Exactly 36 characters

## Response 204

Request accepted. No response body.

## Errors

- `401`: The key was missing, malformed, revoked, or belongs to an account that no longer exists.
- `403`: Access denied. Check the key's team, permissions and allowed IP addresses. Some actions, such as managing API keys, require a browser session. The response message explains the reason.
- `404`: The resource was not found in the selected team. Resources in another account or team also return 404.
- `422`: A field is missing or invalid, or the resource cannot accept this change in its current state. Check `message` for details. Field validation also includes an `errors` object keyed by field name.
- `429`: Too many requests. The `Retry-After` header says how many seconds to wait. Limits are per account, so several keys on one account share them.

## Example request

```bash
curl --request POST \
  --url 'https://console.advinservers.com/api/v1/client/servers/{server}/settings/reinstall' \
  --header 'Authorization: Bearer <token>' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{
  "template_uuid": "e28b39a8-059e-4a75-8048-c9a6e7231b9f",
  "account_password": "resonance-cascade-1998",
  "start_on_completion": true,
  "ssh_keys": [
    "97721fd4-746a-40cc-8da0-4c9f623c112e"
  ],
  "user_script": "8edb21bc-9aee-4bd9-8a02-17043fa82a87"
}'
```
