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
previewfeature (besidesread). - 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 behttp(s)and at most 500 characters.
Steps
- Issue a token:
POST /admin/cms/preview-tokenswithgroup_id,localeandttl(1 to 900 seconds, default 600). It needs permission to read the entry. The token is shown once. - Open the site at the path that receives the token (for example
/api/draft?token=pvt_…). The sampleneutral/preview-gate.mjsin the Site Kit package sets an HttpOnly cookie and redirects to the clean URL. - With that cookie, the site reads the draft through the preview Store API, sending the token in the
x-cms-preview-tokenheader:GET /store/cms/preview/session: the entry bound to the token.GET /store/cms/preview/entries/by-path?path=andGET /store/cms/preview/entries/{id}: confirm it is the same entry.
- Never cache preview responses: they are
private, no-store.
Rules to remember
- The token decides the entry and language;
id,pathandlocalein 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
/draftpage that skips the check (never.draft-route).
See also
- Keys and preview token and Store API.
- Preview button on the entry page: the current state of the Console button.