# Migrations

URL: https://docs.vaultpanel.net/api-reference/migrations

> API reference for moving websites, databases and email to one of your servers from a cPanel full account backup.

A migration moves a cPanel account to one of your servers from its full account backup (`backup-….tar.gz` or `cpmove-user.tar.gz`). The backup is uploaded to the panel in pieces, then read on the chosen server. From what the server found, you pick what to move; the panel makes the websites, databases and email the usual way, and the server fills them with the files, data and mail. See [Moving from cPanel](https://docs.vaultpanel.net/guides/websites/moving-from-cpanel).

Migrations need agent 0.48.0 or newer on the server, and 0.50.0 or newer to move email. They are for staff with `websites.manage` and `databases.manage` (and `mail.manage` to move email); hosting customers are refused with `403 FORBIDDEN`.

## How a migration works

| Step | Request | Status afterwards |
| --- | --- | --- |
| 1 | [Start a migration](https://docs.vaultpanel.net/api-reference/migrations#start-a-migration) and [send the backup](https://docs.vaultpanel.net/api-reference/migrations#send-a-piece-of-the-backup) in pieces. | `uploading` |
| 2 | [Finish the upload](https://docs.vaultpanel.net/api-reference/migrations#finish-the-upload). The server reads the backup (`MIGRATION_INSPECT`). | `inspecting`, then `ready` |
| 3 | Read `inspection` with [Get a migration](https://docs.vaultpanel.net/api-reference/migrations#get-a-migration), then [move what you pick](https://docs.vaultpanel.net/api-reference/migrations#move-what-you-picked). | `creating`, then `restoring` (`MIGRATION_RESTORE`), then `done` |

Any step can end in `failed`, with `lastError`. [Discard](https://docs.vaultpanel.net/api-reference/migrations#discard-a-migration) sets `discarded`. The backup is deleted from the server once the move is done or discarded.

## Endpoints

| Method | Path | Description |
| --- | --- | --- |
| GET | `/api/v1/migrations` | [List migrations](https://docs.vaultpanel.net/api-reference/migrations#list-migrations) |
| POST | `/api/v1/migrations` | [Start a migration](https://docs.vaultpanel.net/api-reference/migrations#start-a-migration) |
| GET | `/api/v1/migrations/:id` | [Get a migration](https://docs.vaultpanel.net/api-reference/migrations#get-a-migration) |
| PUT | `/api/v1/migrations/:id/uploads/:uploadId/chunks/:offset` | [Send a piece of the backup](https://docs.vaultpanel.net/api-reference/migrations#send-a-piece-of-the-backup) |
| POST | `/api/v1/migrations/:id/uploads/:uploadId/finish` | [Finish the upload](https://docs.vaultpanel.net/api-reference/migrations#finish-the-upload) |
| POST | `/api/v1/migrations/:id/start` | [Move what you picked](https://docs.vaultpanel.net/api-reference/migrations#move-what-you-picked) |
| POST | `/api/v1/migrations/:id/discard` | [Discard a migration](https://docs.vaultpanel.net/api-reference/migrations#discard-a-migration) |

## The migration object

```json
{
  "id": "5f1e2d3c-4b5a-4968-8776-a5b4c3d2e1f0",
  "serverId": "1f6a3c2e-5b4d-4e7f-9a8b-0c1d2e3f4a5b",
  "serverName": "web-1",
  "fileName": "backup-11.10.2026_09-30-12_shopacct.tar.gz",
  "sizeBytes": 734003200,
  "status": "ready",
  "inspection": {
    "account": "shopacct",
    "mainDomain": "example.com",
    "totalBytes": 734003200,
    "sites": [
      { "domain": "example.com", "aliases": ["www.example.com"], "root": "public_html", "phpVersion": "8.2", "kind": "main", "bytes": 412000000 },
      { "domain": "shop.com", "aliases": ["www.shop.com"], "root": "public_html/shop", "phpVersion": null, "kind": "addon", "bytes": 98000000 }
    ],
    "databases": [{ "name": "shopacct_wp", "bytes": 52428800 }],
    "mail": [
      {
        "domain": "example.com",
        "mailboxes": [{ "local": "info", "address": "info@example.com", "quotaMb": 1024, "bytes": 15728640, "hasMail": true, "hasPassword": true }],
        "forwarders": [{ "local": "sales", "address": "sales@example.com", "destinations": ["team@example.org"] }]
      }
    ]
  },
  "plan": null,
  "result": null,
  "lastJobId": "…",
  "lastError": null,
  "createdAt": "2026-11-11T09:40:00.000Z",
  "updatedAt": "2026-11-11T09:42:10.000Z"
}
```

| Field | Description |
| --- | --- |
| `status` | `uploading`, `inspecting`, `ready`, `creating`, `restoring`, `done`, `failed` or `discarded`. |
| `inspection` | What the server found in the backup, once `ready`. Each site's `kind` is `main`, `addon` or `subdomain`, and its `root` is its folder in the old home. `mail` is `null` when an agent older than 0.50.0 read the backup. Password hashes are never in it. |
| `plan` | What was made for the move: `sites` (`{ root, websiteId, name, domains }`), `databases` (`{ source, databaseId, userId, name, user }`) and `mail` (`{ domains, mailboxes, forwarders, skipped }`). Each mailbox has `needsPassword` when its password could not come over. |
| `result` | When `done`: the moved `sites`, `databases`, the `wordpress` sites pointed at their new database, the `mail` moved per mailbox (`{ address, messages, bytes }`) and `mailErrors`. |

## List migrations

`GET /api/v1/migrations` — Permission: websites.manage, databases.manage — Token scope: manage

The 50 newest migrations that were not discarded, newest first.

**Example request**

**cURL**

```bash
curl https://panel.example.com/api/v1/migrations \
  -H "Authorization: Bearer $VAULTPANEL_TOKEN"
```

**JavaScript**

```js
const { items } = await panel.request('GET', '/migrations');
```

**Response** `200 OK`: `{ items: [migration] }`.

## Start a migration

`POST /api/v1/migrations` — Permission: websites.manage, databases.manage — Token scope: manage

Makes a migration to a server and starts the upload of its backup.

**Request body**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `serverId` | string (UUID) | Yes | The server to move to. |
| `fileName` | string | Yes | The backup's file name, up to 255 characters. |
| `size` | integer | Yes | The backup's size in bytes. At most `VAULTPANEL_FILE_UPLOAD_MAX_MB` (2048 MB by default). |

**Example request**

**cURL**

```bash
curl https://panel.example.com/api/v1/migrations \
  -H "Authorization: Bearer $VAULTPANEL_TOKEN" -H "Content-Type: application/json" \
  -d '{"serverId":"1f6a3c2e-5b4d-4e7f-9a8b-0c1d2e3f4a5b","fileName":"cpmove-shopacct.tar.gz","size":734003200}'
```

**JavaScript**

```js
const { migration, upload } = await panel.request('POST', '/migrations', {
  body: { serverId, fileName: 'cpmove-shopacct.tar.gz', size: file.length },
});
```

**Response** `201 Created`: `{ migration, upload }`, message `Upload the backup`. `upload` is `{ uploadId, chunkBytes, size }`; `chunkBytes` is the largest piece (8 MB).

**Errors**

| Status | Code | When |
| --- | --- | --- |
| 403 | `FORBIDDEN` | A hosting customer, or a missing permission. |
| 409 | `AGENT_OUTDATED` | The server's agent is older than 0.48.0. |
| 413 | `FILE_TOO_LARGE` | The backup is larger than `VAULTPANEL_FILE_UPLOAD_MAX_MB`. |
| 422 | `VALIDATION_ERROR` | The server does not exist, or a field is invalid. |

## Get a migration

`GET /api/v1/migrations/:id` — Permission: websites.manage, databases.manage — Token scope: manage

**Response** `200 OK`: `{ migration }`. Poll it to follow a migration. `404 NOT_FOUND` when there is no such migration.

## Send a piece of the backup

`PUT /api/v1/migrations/:id/uploads/:uploadId/chunks/:offset` — Permission: websites.manage, databases.manage — Token scope: manage

Sends the backup's bytes from `offset`, as the raw request body (`Content-Type: application/octet-stream`), up to `chunkBytes` per request, in order. Only the person who started the upload can add to it.

**Example request**

```bash
curl -X PUT "https://panel.example.com/api/v1/migrations/$MIGRATION_ID/uploads/$UPLOAD_ID/chunks/0" \
  -H "Authorization: Bearer $VAULTPANEL_TOKEN" -H "Content-Type: application/octet-stream" \
  --data-binary @part-0
```

**Response** `200 OK`: `{ received, size }`. Send the next piece from `received`.

**Errors**

| Status | Code | When |
| --- | --- | --- |
| 404 | `NOT_FOUND` | No such upload, or it is someone else's. |
| 409 | `OFFSET_MISMATCH` | The piece is not for the next offset. `details.expected` is where to continue. |
| 409 | `UPLOAD_FINISHED` | The upload is already finished. |
| 413 | `CHUNK_TOO_LARGE` | The piece is larger than `chunkBytes`. |
| 422 | `UPLOAD_TOO_LARGE` | More data than the size given at the start. |

## Finish the upload

`POST /api/v1/migrations/:id/uploads/:uploadId/finish` — Permission: websites.manage, databases.manage — Token scope: manage

Checks that every byte arrived, computes the backup's SHA-256 and queues `MIGRATION_INSPECT`. The server fetches the backup, checks it against the SHA-256, keeps it in a folder only root can read and lists what is in it. When the job succeeds, `status` is `ready` and `inspection` is filled in; the panel's copy is deleted.

**Response** `202 Accepted`: `{ migration, job }`, message `Reading the backup`.

**Errors**

| Status | Code | When |
| --- | --- | --- |
| 409 | `MIGRATION_BUSY` | The backup was already uploaded. |
| 409 | `UPLOAD_INCOMPLETE` | Not every byte has arrived. `details.received` says how many have. |

The job fails with `MIGRATION_UNSUPPORTED` for a file that is not a cPanel full backup, a backup that keeps the home folder as `homedir.tar`, or one with more than one account; with `MIGRATION_ARCHIVE_INVALID` for a file `tar` cannot read; and with `MIGRATION_UNREADABLE` when the backup's `userdata/` does not name the account's domain or website folders.

## Move what you picked

`POST /api/v1/migrations/:id/start` — Permission: websites.manage, databases.manage — Token scope: manage

Moves the websites, databases and email domains you pick from `inspection`. Pick at least one.

- Each website is made as a PHP website with document root `public` (`CREATE_SITE`), and the files of its folder are unpacked into it, owned by the website, without setuid bits. Folders of other moved websites inside it are left out.
- Each database is made with a user of the same name (cut to 32 characters) with full access, and its dump is imported as an account that reaches only it. Databases are linked to the first moved website.
- A WordPress whose `wp-config.php` uses a moved database is pointed at the new one.
- Each email domain is added to the server's mail server (no DNS records are added), with its mailboxes (passwords as cPanel kept them, quotas and all their mail) and forwarders. Addresses the panel already has are left as they are and listed in `plan.mail.skipped`. Needs a mail server set up on the server, `mail.manage` and agent 0.50.0 or newer.

When every website and database exists, the panel queues `MIGRATION_RESTORE`. If making them fails, what was already made is kept and the migration is `failed`.

**Request body**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `sites` | object[] | No | Up to 100. Each `{ root, name, domains, phpVersion }`: `root` from `inspection.sites`, the website `name` (3 to 32 lowercase letters, digits and dashes), 1 to 20 `domains` (no wildcards) and an optional PHP version such as `8.3`. |
| `databases` | object[] | No | Up to 200. Each `{ source, name }`: `source` from `inspection.databases` and the new database's `name`. |
| `mail` | object | No | `{ domains }`: up to 200 email domains from `inspection.mail`, moved whole. |

**Example request**

**cURL**

```bash
curl https://panel.example.com/api/v1/migrations/5f1e2d3c-4b5a-4968-8776-a5b4c3d2e1f0/start \
  -H "Authorization: Bearer $VAULTPANEL_TOKEN" -H "Content-Type: application/json" \
  -d '{"sites":[{"root":"public_html","name":"example","domains":["example.com","www.example.com"],"phpVersion":"8.2"}],"databases":[{"source":"shopacct_wp","name":"example_wp"}],"mail":{"domains":["example.com"]}}'
```

**JavaScript**

```js
const { migration } = await panel.request('POST', `/migrations/${migrationId}/start`, {
  body: {
    sites: [{ root: 'public_html', name: 'example', domains: ['example.com', 'www.example.com'], phpVersion: '8.2' }],
    databases: [{ source: 'shopacct_wp', name: 'example_wp' }],
    mail: { domains: ['example.com'] },
  },
});
```

**Response** `202 Accepted`: `{ migration }`, message `Moving the websites`.

**Errors**

| Status | Code | When |
| --- | --- | --- |
| 409 | `MIGRATION_BUSY` | The backup is not read yet, is already being moved, or was moved. |
| 409 | `AGENT_OUTDATED` | Email was picked and the agent is older than 0.50.0. |
| 409 | `MAIL_NOT_SET_UP` | Email was picked and the server has no mail server. |
| 409 | `DATABASE_SERVER_NOT_INSTALLED` and others | A website or database could not be made: the errors of [creating a website](https://docs.vaultpanel.net/api-reference/websites#create-a-website) or [a database](https://docs.vaultpanel.net/api-reference/databases#create-a-database). |
| 422 | `VALIDATION_ERROR` | Nothing picked, a folder, database or email domain that is not in the backup, one listed twice, an invalid name or domain, an email domain that has email on another server, or a backup read by an agent too old to list its email. |

The `MIGRATION_RESTORE` job fails with `MIGRATION_ARCHIVE_GONE` when the backup is no longer on the server, and with `IMPORT_FAILED` when a database dump cannot be imported (see [Import a dump](https://docs.vaultpanel.net/api-reference/databases#import-a-dump)). Mail that cannot be moved for one mailbox does not stop the job: it is listed in `result.mailErrors`.

## Discard a migration

`POST /api/v1/migrations/:id/discard` — Permission: websites.manage, databases.manage — Token scope: manage

Removes the backup from the server (`MIGRATION_DISCARD`) when it is still there, and hides the migration from the list. What was already moved stays.

**Response** `200 OK`: `{ migration }`.

**Errors**

| Status | Code | When |
| --- | --- | --- |
| 409 | `MIGRATION_BUSY` | The backup is being read or moved: wait until the current step has finished. |
