Create a preview

Build the site to a preview URL instead of deploying live. To check a large change before it reaches visitors, build a preview, read it back, then promote it.

Preview builds are metered like deploys (quota and cooldown), and create, rebuild, and promote all spend from the shared hourly budget described under rate limiting. Creating a preview expires the site’s previous previews.

A workspace preview created with a token comes back with no authUrl, because a token is not a workspace member. To fetch the preview’s content back, create it with public or password visibility.

POST https://sitepaste.com/api/v1/public/sites/{siteId}/previews

Requires the deploy scope.

Usage

curl -X POST "https://sitepaste.com/api/v1/public/sites/default/previews" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "visibility": "public" }'

Authorizations

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token (Authorization: Bearer sp_...). Created in the dashboard under Account > Tokens. See authentication.

Body

FieldTypeRequiredDescription
visibilitystringYespublic, password, or workspace. It decides who can open the preview, whatever protects the live site. A page with its own password still asks for it in a public or password preview. Members signed in to a workspace preview can read it without its password.
passwordstringFor password visibilityThe preview’s password, at most 72 bytes. A longer one is refused with 422 and fields.password before anything else happens.

Response

202 Accepted with the preview record (status: "building", and createdByName set to the token’s name), in the shape list previews describes, and a Location header naming the preview to poll. Poll that URI, which is also GET /sites/{siteId}/previews/{previewId}, until ready, then open url.

402 with "code": "pro_features_in_use" when the workspace is not on Pro but the site uses Pro features, as for a deploy.