# Start a restore batch

`POST /api/v1/servers/{server}/restore-batches`

Restores the server's accounts one after another, each from its newest backup that can be restored (at or before `as_of` when given), with the same choices for every account. Name the accounts in `hosting_account_ids`, or leave it out for every account that can be restored; an account with no such backup is left out. Answers 201 with the batch; its first restore is queued at once. 409 while another batch runs on the server. 422 when the batch cannot start, with the reason in `message`: no Plesk or cPanel, the integration switched off, an agent too old, or no chosen account with a backup that can be restored.

Guides: [Restore many accounts at once](/docs/restores/bulk-restore)

## Path Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| server | integer | yes | The ID of the server. Example: `12`. |

## Body Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| as_of | string · date-time | no | Restore each account from its newest backup at or before this moment (ISO 8601, not in the future). Leave it out for the newest backup. Nullable. Example: `2026-11-20T00:00:00+00:00`. |
| hosting_account_ids | integer[] | no | The accounts of this server to restore. Leave it out for every account that can be restored. As in the panel, retired accounts and accounts without a backup that can be restored are left out of the batch; `GET /servers/{server}/restore-candidates` lists them with the reason. Example: `[17]`. |
| components | string[] | yes | The parts to restore for every account: `settings`, `files`, `databases`, `mail`. One of: `settings`, `files`, `databases`, `mail`. Example: `["files","databases"]`. |
| apply_settings | boolean | no | With `settings`: apply them. Re-creates a deleted subscription or account; on cPanel it also rolls a live account's configuration back. Default: `false`. Example: `false`. |
| rollback_live | boolean | no | Plesk, with `settings` and `apply_settings`: also roll back subscriptions that still exist. Their settings and every password go back to the backup's. Default: `false`. Example: `false`. |
| database_mode | string | no | `new` restores each database as `name_restored` and leaves the original alone; `overwrite` empties the original and loads the backup into it, for every account. When left out it is decided per account when the batch is created, as in the single restore: `overwrite` for an account that was missing from the server at the last account sync when `apply_settings` re-creates it (its databases come back empty), `new` for every other account. The batch's `choices` then show `per_account` and each account's mode. Nullable. One of: `new`, `overwrite`, `null`. Example: `new`. |
| mail_overwrite | boolean | no | Overwrite messages that already exist. Default: `false`. Example: `false`. |

## Response

### 201

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| data | object | yes |  |
| data.id | integer | yes |  |
| data.server_id | integer | yes |  |
| data.status | string | yes | `running` while accounts are restored, `stopping` while the restore in progress finishes after a stop; then `completed`, `completed_with_failures` or `stopped`. One of: `running`, `stopping`, `completed`, `completed_with_failures`, `stopped`. |
| data.status_label | string | yes | One of: `Running`, `Stopping`, `Completed`, `Completed with failures`, `Stopped`. |
| data.choices | object | yes | The choices applied to every account. `database_mode` is `per_account` when it was left out with settings applied: then `database_modes` gives each account's mode (`overwrite` for an account missing from the server at the last sync when the batch was created, `new` for the others), keyed by hosting account id; it is an empty list `[]` otherwise. |
| data.choices.components | string[] | yes | One of: `settings`, `files`, `databases`, `mail`. |
| data.choices.apply_settings | boolean | yes |  |
| data.choices.rollback_live | boolean | yes |  |
| data.choices.database_mode | string | yes | One of: `new`, `overwrite`, `per_account`. |
| data.choices.database_modes | object | yes |  |
| data.choices.mail_overwrite | boolean | yes |  |
| data.as_of | string · date-time | yes | Each account is restored from its newest backup at or before this moment; null for its newest backup. Nullable. |
| data.accounts | object | yes | What happened to each account, counted per account: an account restored one component at a time counts once. |
| data.accounts.restored | integer | yes |  |
| data.accounts.restored_with_warnings | integer | yes |  |
| data.accounts.failed | integer | yes |  |
| data.accounts.skipped | integer | yes |  |
| data.accounts.cancelled | integer | yes |  |
| data.accounts.left | integer | yes |  |
| data.accounts.total | integer | yes |  |
| data.initiated_by_user_id | integer | yes | The user who started the batch. Nullable. |
| data.retry_of_batch_id | integer | yes | The ended batch whose failed accounts this one restores again; null for a first batch. Nullable. |
| data.stop_reason | string | yes | Why the batch was stopped: `Stopped by a user` (a stop from the panel or the API) or `Client suspended`; null unless it was stopped. Nullable. |
| data.stop_requested_at | string · date-time | yes | When the stop was asked for; null unless the batch was stopped. Nullable. |
| data.started_at | string · date-time | yes | Nullable. |
| data.finished_at | string · date-time | yes | When the batch ended; null while it is running or stopping. Nullable. |
| data.items | object[] | yes |  |
| data.items.position | integer | yes | The item's place in the batch, from 1. Items run in this order. |
| data.items.hosting_account_id | integer | yes | The account restored; null once the account was deleted. Nullable. |
| data.items.domain_name | string | yes | The account's domain; null once the account was deleted. Nullable. |
| data.items.component | string | yes | The one component this item restores when the plan keeps one backup per component; null when the backup holds them all. Nullable. One of: `settings`, `files`, `databases`, `mail`, `null`. |
| data.items.backup_artifact_id | integer | yes | The backup restored; null once it was deleted. Nullable. |
| data.items.backup_run_id | integer | yes | The restore run of this item, once it was queued; null before. Nullable. |
| data.items.status | string | yes | One of: `pending`, `running`, `completed`, `failed`, `skipped`, `cancelled`. |
| data.items.status_label | string | yes | One of: `Pending`, `Running`, `Completed`, `Failed`, `Skipped`, `Cancelled`. |
| data.items.reason | string | yes | Why the item failed or was skipped, or what a restore that completed only in part left out; null otherwise. Nullable. |
| data.created_at | string · date-time | yes | Nullable. |
| data.updated_at | string · date-time | yes | Nullable. |

### 401

The request carries no valid token: the `Authorization: Bearer` header is missing, or its token is unknown, revoked or past its expiry date. Send a current personal access token.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| message | string | yes | Always `Unauthenticated.`. |

### 403

The token may not do this. The `message` says why: `This token lacks the required ability.` (a `read` token), `Your role does not permit this action.` (its owner is not an Admin or Operator in the client), `This account is disabled.`, `This token is not bound to a client you belong to.`, or `Client suspended`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| message | string | yes | What went wrong. |

### 404

Not found

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| message | string | yes | What went wrong. |

### 409

A restore batch is already running or stopping on the server.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| message | string | yes | What went wrong. |

### 422

The body or the query is invalid. `message` names the first problem and `errors` lists every problem by field. A batch that cannot start is refused with a `message` only: the server has no Plesk or cPanel, that panel's integration is switched off, its agent is too old for the choices, or none of the chosen accounts has a backup that can be restored.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| message | string | yes | The first problem, and how many more there are. |
| errors | object | yes | Every problem, by field. |

### 429

More than 120 requests a minute for this user. Wait the seconds in `Retry-After`, then retry.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| message | string | yes | What went wrong. |

## Request example

```bash
curl -X POST 'https://app.clokeep.com/api/v1/servers/12/restore-batches' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
    "as_of": "2026-11-20T00:00:00+00:00",
    "hosting_account_ids": [
      17
    ],
    "components": [
      "files",
      "databases"
    ],
    "apply_settings": false,
    "rollback_live": false,
    "database_mode": "new",
    "mail_overwrite": false
  }'
```

## Response example (201)

```json
{
  "data": {
    "id": 64,
    "server_id": 12,
    "status": "running",
    "status_label": "Running",
    "choices": {
      "components": [
        "files",
        "databases"
      ],
      "apply_settings": false,
      "rollback_live": false,
      "database_mode": "new",
      "database_modes": [],
      "mail_overwrite": false
    },
    "as_of": null,
    "accounts": {
      "restored": 0,
      "restored_with_warnings": 0,
      "failed": 0,
      "skipped": 0,
      "cancelled": 0,
      "left": 1,
      "total": 1
    },
    "initiated_by_user_id": 8,
    "retry_of_batch_id": null,
    "stop_reason": null,
    "stop_requested_at": null,
    "started_at": "2026-11-20T10:40:00+00:00",
    "finished_at": null,
    "items": [
      {
        "position": 1,
        "hosting_account_id": 17,
        "domain_name": "example.com",
        "component": null,
        "backup_artifact_id": 2291,
        "backup_run_id": 1875,
        "status": "completed",
        "status_label": "Completed",
        "reason": null
      }
    ],
    "created_at": "2026-11-20T10:40:00+00:00",
    "updated_at": "2026-11-20T10:40:00+00:00"
  }
}
```

## Response example (401)

```json
{
  "message": "Unauthenticated."
}
```

## Response example (403)

```json
{
  "message": "This token lacks the required ability."
}
```

## Response example (404)

```json
{
  "message": "No query results for model [App\\Models\\Server] 12"
}
```

## Response example (409)

```json
{
  "message": "A restore batch is already running on web-01. Stop it, or wait for it to end."
}
```

## Response example (422)

```json
{
  "message": "The components field is required.",
  "errors": {
    "components": [
      "The components field is required."
    ]
  }
}
```

## Response example (429)

```json
{
  "message": "Too Many Attempts."
}
```
