# Migration (cPanel/DirectAdmin)

<a id="post-api-v1-migration-cancel-job-id"></a>
#### `POST /api/v1/migration/cancel/{job_id}`

*Cancel migration*

Cancel a running migration job.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `job_id` | string | yes | — |

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `ApiSuccess_MigrationJobResponse_` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "data": {
    "accounts": [
      "..."
    ],
    "completed_accounts": 0,
    "completed_at": "...",
    "error": "...",
    "failed_accounts": 0,
    "job_id": "string",
    "panel_type": "",
    "progress": 0,
    "scan_result": "...",
    "server_hostname": "string",
    "started_at": "...",
    "status": "pending",
    "total_accounts": 0
  },
  "message": "",
  "status": "success",
  "warnings": [
    "string"
  ]
}
```

**cURL example:**

```bash
curl -X POST \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  https://your-server:2000/api/v1/migration/cancel/{job_id}
```

---

<a id="get-api-v1-migration-history"></a>
#### `GET /api/v1/migration/history`

*Migration history*

List all migration jobs as history entries.

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `ApiSuccess_list_MigrationHistoryEntry__` | Successful Response |

**Response example (200):**

```json
{
  "data": [
    {
      "completed_accounts": "...",
      "completed_at": "...",
      "failed_accounts": "...",
      "job_id": "...",
      "panel_type": "...",
      "server_hostname": "...",
      "started_at": "...",
      "status": "...",
      "total_accounts": "..."
    }
  ],
  "message": "",
  "status": "success",
  "warnings": [
    "string"
  ]
}
```

**cURL example:**

```bash
curl -X GET \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  https://your-server:2000/api/v1/migration/history
```

---

<a id="get-api-v1-migration-history-job-id"></a>
#### `GET /api/v1/migration/history/{job_id}`

*Migration history detail*

Get a specific migration job detail from history.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `job_id` | string | yes | — |

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `ApiSuccess_MigrationJobResponse_` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "data": {
    "accounts": [
      "..."
    ],
    "completed_accounts": 0,
    "completed_at": "...",
    "error": "...",
    "failed_accounts": 0,
    "job_id": "string",
    "panel_type": "",
    "progress": 0,
    "scan_result": "...",
    "server_hostname": "string",
    "started_at": "...",
    "status": "pending",
    "total_accounts": 0
  },
  "message": "",
  "status": "success",
  "warnings": [
    "string"
  ]
}
```

**cURL example:**

```bash
curl -X GET \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  https://your-server:2000/api/v1/migration/history/{job_id}
```

---

<a id="post-api-v1-migration-retry-job-id"></a>
#### `POST /api/v1/migration/retry/{job_id}`

*Retry migration*

Retry a failed migration job.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `job_id` | string | yes | — |

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `ApiSuccess_MigrationJobResponse_` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "data": {
    "accounts": [
      "..."
    ],
    "completed_accounts": 0,
    "completed_at": "...",
    "error": "...",
    "failed_accounts": 0,
    "job_id": "string",
    "panel_type": "",
    "progress": 0,
    "scan_result": "...",
    "server_hostname": "string",
    "started_at": "...",
    "status": "pending",
    "total_accounts": 0
  },
  "message": "",
  "status": "success",
  "warnings": [
    "string"
  ]
}
```

**cURL example:**

```bash
curl -X POST \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  https://your-server:2000/api/v1/migration/retry/{job_id}
```

---

<a id="post-api-v1-migration-scan"></a>
#### `POST /api/v1/migration/scan`

*Scan source server*

Connect via SSH, detect panel type (cPanel/DirectAdmin/Plesk), and enumerate transferable resources.

**Body fields:**

| Field | Type | Required | Notes |
|-------|------|----------|-------|
| `api_key` | string | no | default ``; maxLength=256 |
| `api_secret` | string | no | default ``; maxLength=256 |
| `host` | string | yes | minLength=1; maxLength=255; pattern=`^[a-zA-Z0-9][a-zA-Z0-9.:_-]*$` |
| `panel_type` | string | no | — |
| `password` | string | no | default ``; maxLength=512 |
| `port` | integer | no | default `22`; minimum=1.0; maximum=65535.0 |
| `ssh_key` | string | no | default ``; maxLength=16384 |
| `username` | string | no | default `root`; maxLength=64; pattern=`^[A-Za-z0-9._-]{1,64}$` |
| `verify_ssl` | boolean | no | default `True` |

**Request body example:**

```json
{
  "api_key": "",
  "api_secret": "",
  "host": "string",
  "panel_type": "cpanel",
  "password": "",
  "port": 22,
  "ssh_key": "",
  "username": "root",
  "verify_ssl": true
}
```

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `ApiSuccess_MigrationJobResponse_` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "data": {
    "accounts": [
      "..."
    ],
    "completed_accounts": 0,
    "completed_at": "...",
    "error": "...",
    "failed_accounts": 0,
    "job_id": "string",
    "panel_type": "",
    "progress": 0,
    "scan_result": "...",
    "server_hostname": "string",
    "started_at": "...",
    "status": "pending",
    "total_accounts": 0
  },
  "message": "",
  "status": "success",
  "warnings": [
    "string"
  ]
}
```

**cURL example:**

```bash
curl -X POST \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  -H "Content-Type: application/json" \
  -d @body.json \
  https://your-server:2000/api/v1/migration/scan
```

---

<a id="get-api-v1-migration-scan-job-id"></a>
#### `GET /api/v1/migration/scan/{job_id}`

*Poll scan*

Poll the scan status for a migration job.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `job_id` | string | yes | — |

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `ApiSuccess_MigrationScanResult_` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "data": {
    "accounts": [
      "..."
    ],
    "job_id": "",
    "panel_type": "string",
    "panel_version": "",
    "plans": [
      "..."
    ],
    "scan_duration_seconds": 0,
    "server_hostname": "",
    "source_webserver": "",
    "total_accounts": 0,
    "total_disk_mb": 0
  },
  "message": "",
  "status": "success",
  "warnings": [
    "string"
  ]
}
```

**cURL example:**

```bash
curl -X GET \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  https://your-server:2000/api/v1/migration/scan/{job_id}
```

---

<a id="post-api-v1-migration-start"></a>
#### `POST /api/v1/migration/start`

*Start migration*

Begin transferring selected accounts from the source server.

**Body fields:**

| Field | Type | Required | Notes |
|-------|------|----------|-------|
| `accounts` | array<string> | no | — |
| `job_id` | string | yes | minLength=1; maxLength=200; pattern=`^[a-zA-Z0-9._-]+$` |
| `overwrite_existing` | boolean | no | default `False` |
| `php_overrides` | object | no | — |
| `plan_mapping` | object | no | — |
| `skip_databases` | boolean | no | default `False` |
| `skip_dns` | boolean | no | default `False` |
| `skip_email` | boolean | no | default `False` |

**Request body example:**

```json
{
  "accounts": [
    "string"
  ],
  "job_id": "string",
  "overwrite_existing": false,
  "php_overrides": {},
  "plan_mapping": {},
  "skip_databases": false,
  "skip_dns": false,
  "skip_email": false
}
```

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `ApiSuccess_MigrationJobResponse_` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "data": {
    "accounts": [
      "..."
    ],
    "completed_accounts": 0,
    "completed_at": "...",
    "error": "...",
    "failed_accounts": 0,
    "job_id": "string",
    "panel_type": "",
    "progress": 0,
    "scan_result": "...",
    "server_hostname": "string",
    "started_at": "...",
    "status": "pending",
    "total_accounts": 0
  },
  "message": "",
  "status": "success",
  "warnings": [
    "string"
  ]
}
```

**cURL example:**

```bash
curl -X POST \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  -H "Content-Type: application/json" \
  -d @body.json \
  https://your-server:2000/api/v1/migration/start
```

---

<a id="get-api-v1-migration-status-job-id"></a>
#### `GET /api/v1/migration/status/{job_id}`

*Migration status*

Snapshot of a migration job's progress.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `job_id` | string | yes | — |

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `ApiSuccess_MigrationJobResponse_` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "data": {
    "accounts": [
      "..."
    ],
    "completed_accounts": 0,
    "completed_at": "...",
    "error": "...",
    "failed_accounts": 0,
    "job_id": "string",
    "panel_type": "",
    "progress": 0,
    "scan_result": "...",
    "server_hostname": "string",
    "started_at": "...",
    "status": "pending",
    "total_accounts": 0
  },
  "message": "",
  "status": "success",
  "warnings": [
    "string"
  ]
}
```

**cURL example:**

```bash
curl -X GET \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  https://your-server:2000/api/v1/migration/status/{job_id}
```

---

<a id="get-api-v1-migration-status-job-id-stream"></a>
#### `GET /api/v1/migration/status/{job_id}/stream`

*Stream Status*

SSE stream of migration progress for real-time updates.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `job_id` | string | yes | — |

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | — | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**cURL example:**

```bash
curl -X GET \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  https://your-server:2000/api/v1/migration/status/{job_id}/stream
```

---

<a id="post-api-v1-migration-upload"></a>
#### `POST /api/v1/migration/upload`

*Upload backup archive (not available)*

Not available: restoring from an uploaded backup file is not offered. The call always answers `409 MIGRATION_UPLOAD_RESTORE_UNAVAILABLE` and keeps nothing; migrate accounts over SSH with `POST /migration/scan` and `POST /migration/start`.

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `ApiSuccess_dict_str__Any__` | Successful Response |

**Response example (200):**

```json
{
  "data": {},
  "message": "",
  "status": "success",
  "warnings": [
    "string"
  ]
}
```

**cURL example:**

```bash
curl -X POST \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  https://your-server:2000/api/v1/migration/upload
```

---

<a id="post-api-v1-migration-upload-restore"></a>
#### `POST /api/v1/migration/upload/restore`

*Restore uploaded backup (not available)*

Not available: restoring from an uploaded backup file is not offered. The call always answers `409 MIGRATION_UPLOAD_RESTORE_UNAVAILABLE` and keeps nothing; migrate accounts over SSH with `POST /migration/scan` and `POST /migration/start`.

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `ApiSuccess_dict_str__Any__` | Successful Response |

**Response example (200):**

```json
{
  "data": {},
  "message": "",
  "status": "success",
  "warnings": [
    "string"
  ]
}
```

**cURL example:**

```bash
curl -X POST \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  https://your-server:2000/api/v1/migration/upload/restore
```

---
