# Use the Partner Rebuild APIThe WebPros Nova Partner Rebuild API lets cPanel partners submit an existing website URL to Nova and start an asynchronous site recreation process. Partners authenticate with X-Partner-Id and X-API-Key headers, POST to /api/integration/partners/cpanel/rebuilds with a sourceUrl and optional prompt, and receive a partner_project_rebuild_completed webhook callback when the rebuild finishes. Requests are idempotent per partner and source URL. Rate limit: 30 requests per hour per partner by default. Available to cPanel partners only; requires the Partner Rebuild API feature flag enabled by WebPros.

The Partner Rebuild API lets you send a website URL to Nova to automatically recreate that site. Nova accepts the request immediately and runs the rebuild process in the background. When the process finishes, Nova sends a completion callback to your registered [webhook endpoint](/en/partners/webhooks/).

{{< callout context="note" icon="outline/info-circle" >}}

This feature is available for cPanel Partners only. To enable it for your account, contact WebPros.

{{< /callout >}}

## Authentication

Authenticate your requests with the following HTTP headers:

| Header | Description |
|---|---|
| `X-Partner-Id` | Your partner company ID. WebPros provides this value when enabling the feature for your account. |
| `X-API-Key` | Your Partner Rebuild API key. WebPros generates and shares this key during setup. |

{{< callout context="caution" icon="outline/alert-triangle" >}}

- The Partner Rebuild API key is separate from your Partner Webhooks API key. Do **not** use these keys interchangeably.
- **Only** send the API key in the request header. Do **not** include it in query parameters.

{{< /callout >}}

## Submit a rebuild request

```http
POST /api/integration/partners/cpanel/rebuilds
```

### Request body

```json
{
  "sourceUrl": "https://example.com",
  "prompt": "Optional custom instructions for the rebuild"
}
```

| Field | Required | Description |
|---|---|---|
| `sourceUrl` | Yes | The public URL of the website to recreate. |
| `prompt` | No | Custom instructions for the rebuild. If you omit this value, Nova uses the default modernization prompt. |

### Example request

```shell
curl -X POST "https://<nova-api-domain>/api/integration/partners/cpanel/rebuilds" \
  -H "Content-Type: application/json" \
  -H "X-Partner-Id: <partner-company-id>" \
  -H "X-API-Key: <partner-rebuild-api-key>" \
  -d '{
    "sourceUrl": "https://customer-site.example",
    "prompt": "Modernize the website while preserving the business identity."
  }'
```

## Responses

### New rebuild request

Nova returns `202 Accepted` when you create a new rebuild request.

```json
{
  "requestId": "rebuild_01JZ8Y2R4S3T6V7W8X9Y0Z",
  "projectId": "8wwnkg-lzs06y-3ewtwx",
  "status": "running"
}
```

### Existing rebuild request

If you submit the same `sourceUrl` value again, Nova returns `200 OK` with the existing request instead of starting a new rebuild.

```json
{
  "requestId": "rebuild_01JZ8Y2R4S3T6V7W8X9Y0Z",
  "projectId": "8wwnkg-lzs06y-3ewtwx",
  "status": "success",
  "previewUrl": "https://8wwnkg-lzs06y-3ewtwx.nova.example.com"
}
```

### Response fields

| Field | Description |
|---|---|
| `requestId` | The unique identifier for this rebuild request. |
| `projectId` | The Nova project ID for the rebuild. |
| `status` | The current status: `running`, `success`, or `failed`. |
| `previewUrl` | The preview URL for the generated project. Responses only include this value when the `status` value is `success`. |

## Idempotency

Nova handles rebuild requests as idempotent per partner and source URL: if you submit the same `sourceUrl` value again, Nova returns the existing rebuild request rather than starting a new one. Changing the `prompt` value does not create a new rebuild if you submitted the same `sourceUrl` value.

## Rate limiting

Requests are rate-limited to 30 per hour per partner by default. If you exceed the limit, Nova returns an error:

```json
{
  "message": "Rate limit exceeded",
  "error": {
    "code": "RATE_LIMIT_EXCEEDED"
  }
}
```

## Completion callback

Nova sends a webhook callback when the rebuild reaches a final state. Callbacks use the [Partner Webhooks](/en/partners/webhooks/) delivery system and go to your configured webhook endpoint.

**Event type:** `partner_project_rebuild_completed`

### Successful callback payload

```json
{
  "event_type": "partner_project_rebuild_completed",
  "request_id": "rebuild_01JZ8Y2R4S3T6V7W8X9Y0Z",
  "partner_id": 42,
  "project_id": "8wwnkg-lzs06y-3ewtwx",
  "source_url": "https://customer-site.example",
  "status": "success",
  "preview_url": "https://8wwnkg-lzs06y-3ewtwx.nova.example.com"
}
```

### Failed callback payload

```json
{
  "event_type": "partner_project_rebuild_completed",
  "request_id": "rebuild_01JZ8Y2R4S3T6V7W8X9Y0Z",
  "partner_id": 42,
  "project_id": "8wwnkg-lzs06y-3ewtwx",
  "source_url": "https://customer-site.example",
  "status": "failed",
  "error_code": "process_failed",
  "error_message": "Partner project recreation process failed"
}
```

### Callback fields

| Field | Included | Description |
|---|---|---|
| `event_type` | Always | This value is always `partner_project_rebuild_completed`. |
| `request_id` | Always | The returned rebuild request ID. |
| `partner_id` | Always | The Nova partner ID. |
| `project_id` | Always | The Nova project ID for the rebuild. |
| `source_url` | Always | The original submitted URL. |
| `status` | Always | Whether the rebuild succeeded (`success`) or failed (`failed`). |
| `preview_url` | Success only | The preview URL for the generated Nova project. |
| `error_code` | Failure only, when available. | A machine-readable error code. |
| `error_message` | Failure only, when available. | A human-readable failure message. |

## Assign a rebuild to a customer

If the rebuild request is successful, Nova stores the project temporarily under a system account. You can assign the rebuild to a customer using a magic link or the admin panel.

{{< callout context="caution" icon="outline/alert-triangle" >}}

Nova does not check for previous customer assignments. Any new assignments will create a new independent copy of the rebuild project. Assign rebuilds only once per customer to avoid duplicate projects.

{{< /callout >}}

### Assign a rebuild with a magic link

Generate custom magic links to give your customers seamless access to rebuild projects. Nova will only assign the rebuild if the payload's `status` value is `success` and the `projectId` value matches a rebuild on your account. Otherwise, Nova will ignore the payload and the customer will sign in normally.

To attach a completed rebuild to a customer's magic link:

1. Copy the `projectId` value from the rebuild response and use it to create the following `key=value` pair, where `projectID` represents the `projectId` value: `rebuildId=projectId` For example, `rebuildId=8wwnkg-lzs06y-3ewtwx`.
2. Encode that entire string using Base64. For example, `cmVidWlsZElkPTh3d25rZy1senMwNnktemV3dHd4`.
3. Set the `promptToken` value in your magic link to this encoded string. For example, `promptToken=cmVidWlsZElkPTh3d25rZy1senMwNnktemV3dHd4`.

When the customer opens the magic link and logs in, Nova takes them directly to the new rebuild project.

### Assign a rebuild from the admin panel

You can use the admin panel to assign a rebuild to an existing user directly. You can only assign rebuilds that have a `status` value of `success`.

To assign a rebuild from the admin panel:

1. Log in to your admin panel and navigate to the _Partner Rebuilds_ section.
2. Find the rebuild that you want to assign.
3. Select _Clone to user_ and choose the target user.

Nova creates a new copy of the rebuild project and assigns it to the selected user. This action will not affect the original rebuild project and preview URL in your admin panel.

## Error handling

| Scenario | Result |
|---|---|
| Missing or invalid `X-API-Key` | Request rejected. |
| Missing or invalid `X-Partner-Id` | Request rejected. |
| Feature not enabled for partner | Request rejected. |
| `sourceUrl` missing or invalid | Request rejected. |
| Partner Webhooks not configured | Request rejected. |
| Rate limit exceeded | Request rejected with `RATE_LIMIT_EXCEEDED` error. |
| Rebuild process fails after acceptance | Partner receives a failed completion callback. |
