Update a preview

Change a preview’s visibility or password.

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

Requires the deploy scope.

Usage

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

Authorizations

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

Body

FieldTypeRequiredDescription
visibilitystringYespublic, password, or workspace. Always required, so a password-only PATCH is refused with 422.
passwordstringNoSets the preview password, at most 72 bytes. Required when switching to password visibility unless a password is already set. Switching without one, or sending a longer one, is refused with 422, code: validation_failed, and fields.password.

Response

200 OK with the preview as it now stands, in the same shape as read a preview, createdByName included.

400 when {previewId} is malformed. 404 when it is well formed but names no preview on this site.

409 when the preview is not building or ready. A failed, promoted, or expired preview cannot be updated.

A token never receives an authUrl, even for workspace visibility. To fetch a preview’s content back, create it public or with a password.