Skip to content

Preview drafts on your site

Page

Guide

Updated 13/11/2026

Editors want to see a draft on the real front end before publishing. The CMS issues a preview token (pvt_…) tied to exactly one entry and one language, valid for at most 900 seconds. The site exchanges that token for the draft.

Before you start

  • The site’s store key has the preview feature (besides read).
  • The content type has a preview URL template, for example https://your-site.example/api/draft?token={token}. Allowed variables: {id}, {group_id}, {locale}, {slug}, {path}, {token}. The template must be http(s) and at most 500 characters.

Steps

  1. Issue a token: POST /admin/cms/preview-tokens with group_id, locale and ttl (1 to 900 seconds, default 600). It needs permission to read the entry. The token is shown once.
  2. Open the site at the path that receives the token (for example /api/draft?token=pvt_…). The sample neutral/preview-gate.mjs in the Site Kit package sets an HttpOnly cookie and redirects to the clean URL.
  3. With that cookie, the site reads the draft through the preview Store API, sending the token in the x-cms-preview-token header:
    • GET /store/cms/preview/session: the entry bound to the token.
    • GET /store/cms/preview/entries/by-path?path= and GET /store/cms/preview/entries/{id}: confirm it is the same entry.
  4. Never cache preview responses: they are private, no-store.

Rules to remember

  • The token decides the entry and language; id, path and locale in the request only confirm it. There is no list and no search.
  • The content is the current draft. References to other entries show only when those entries are published.
  • An unknown, expired, revoked, wrong-site or wrong-entry token all return the same 401 cms_preview_token_invalid, so a token holder cannot probe other entries.
  • Revoking takes effect on the next read.
  • There is no public draft route: every preview path needs a token. Do not build a /draft page that skips the check (never.draft-route).

See also

Last updated: