
# Rebuild a preview

Rebuild a preview against the current content and extend its expiry. Metered like a deploy.

```sh
POST https://sitepaste.com/api/v1/public/sites/{siteId}/previews/{previewId}/rebuild
```

Requires the `deploy` scope.

## Usage

```bash
curl -X POST "https://sitepaste.com/api/v1/public/sites/default/previews/pv7k3q9r2m4x/rebuild" \
  -H "Authorization: Bearer $TOKEN"
```

## Authorizations

| Header | Type | Required | Description |
|--------|------|----------|-------------|
| Authorization | string | Yes | Bearer token (`Authorization: Bearer sp_...`). Created in the dashboard under Account > Tokens. See [authentication](/api/authentication). |

## Response

202 Accepted with the preview record back in `status: "building"` (its `createdByName` still names whoever first created it), and a `Location` header naming the preview to poll. The preview keeps its id and its URL, so a link you have already shared serves the new build once it is `ready`.

A preview that is not in a rebuildable state answers 409. 400 when `{previewId}` is malformed. 404 when it is well formed but names no preview on this site.

402 with `"code": "pro_features_in_use"` when the workspace is not on Pro but the site uses Pro features, as for a [deploy](/api/deployments/post-deployments#errors).