A headless CMS turns content into an API, so its security depends on the tokens, roles, origins and webhooks that connect it to every frontend, build pipeline and integration. In a traditional CMS the admin panel and the public site live in one application. In a headless CMS the content store sits behind a set of APIs, and a website, a mobile app, a static site generator, a preview deployment and a search indexer each hold a credential to reach it. Those credentials are non-human identities. Most of them are long-lived bearer tokens, many are shared across environments, and a surprising number end up inside JavaScript bundles or CI logs.
This guide covers the controls that matter across headless platforms: separating delivery, preview and management credentials, scoping tokens to environments, protecting draft content, locking down cross-origin access, verifying webhooks and responding when a token leaks. It then gives a short, neutral section for each of four widely used platforms, Contentful, Payload, Sanity and Strapi, describing their own settings as documented by each vendor. Platforms are listed alphabetically; the order implies nothing about quality. Front-end key exposure in general is covered in our Secrets in Frontend JavaScript Bundles and Source Maps guide, so this page focuses on the CMS side.
Key takeaways
- Treat every CMS API token as a non-human identity with an owner, a purpose, a scope and an expiry date, and record it in your NHI inventory.
- Keep three classes of credential apart: published content delivery, draft or preview access, and content management. Only the first should ever reach a browser, and only when the content is genuinely public.
- Preview tokens read unpublished content: embargoed announcements, pricing, legal copy. Handle them as secrets, never ship them in client code and never share them across production and preview builds.
- Issue one token per consuming application and per environment so you can revoke one channel without breaking the rest.
- Cross-origin settings that allow credentials, especially with wildcards on shared hosting domains, let other sites act as your logged-in editors.
- Verify webhook signatures and timestamps before a build, cache purge or downstream sync acts on a request.
Why a headless CMS is an identity problem
A headless CMS is mostly accessed by machines. The editors log in through a single sign-on session, but the traffic that matters is the static site build pulling every entry at deploy time, the frontend fetching content at runtime, the preview environment rendering drafts, the translation connector writing localised fields and the search service indexing pages. Each of those flows uses a token, and the token is the only thing standing between the content repository and the outside world.
Three properties make these credentials risky. First, many are bearer tokens with no binding to a client, network or device, so anyone who copies one can use it. Second, platforms often create default tokens at project set-up, and teams reuse those defaults for everything because they work. Third, content is usually seen as low sensitivity, which leads teams to treat its credentials casually, even though unpublished content, personal data held in content types and write access to a live website all have real value to an attacker.
Write access deserves particular attention. A management token can change the text, links and scripts that your website renders. An attacker with that access can inject a malicious link into a high-traffic page, alter a payment instruction, deface a brand site or plant content that a downstream system treats as trusted. Content integrity is therefore part of web security, not only an editorial concern.
Separating delivery, preview and management credentials
Every major headless platform distinguishes between reading published content, reading draft content and changing content, even if the names differ. Build your credential model around those three tiers.
| Credential tier | What it can do | Where it may live | Suggested lifetime |
|---|---|---|---|
| Published delivery | Read published entries and assets | Server side by default; browser only when all content in scope is public | Rotate on a schedule and on staff or vendor change |
| Preview or draft | Read unpublished and scheduled content | Server side only, in preview environments, behind authentication | Short; tie to the preview environment lifecycle |
| Management | Create, update, publish and delete content, models and settings | Secrets manager or CI secret store, never in application bundles | Shortest practical; prefer per-pipeline tokens with expiry |
The suggested lifetimes are NHI Mgmt Group recommendations rather than vendor defaults. The principle is that the more a token can see or change, the less widely it should be distributed and the sooner it should expire.
A common mistake is to use a management token for a build because it also reads content. That gives the build pipeline, and anyone who compromises it, the power to rewrite the site. Builds should use delivery credentials; migration and content-modelling scripts should use separate management tokens that are issued for the job and revoked afterwards.
Preview tokens are secrets
Preview is where most headless CMS exposures begin. Teams want editors to see drafts rendered in the real site, so they set up a preview deployment that fetches unpublished content. The quickest way to make that work is to put the preview credential in a public environment variable, which framework build tools then inline into the client bundle. From that point the token is readable by anyone who loads the page or downloads the source map.
Unpublished content often includes product launches, financial results, merger copy, pricing changes and legal notices. Leaking it can move markets or breach disclosure obligations. Apply these rules:
- Fetch draft content on the server and render it there. The browser should receive HTML, not a token.
- Gate preview routes behind your own authentication or your hosting platform's deployment protection, and do not rely on obscure URLs.
- Use a distinct preview credential per environment, so a token leaked from a feature branch deployment cannot read production drafts.
- Scan built bundles and source maps for CMS token formats before deployment, and block the release if a preview or management token appears.
- When preview deployments are created from pull requests on public repositories, make sure fork builds do not receive preview secrets.
Scoping tokens to environments and applications
Most headless platforms support multiple environments or datasets: production, staging, development and sometimes per-feature sandboxes. Scope each token to the smallest set of environments it needs. A staging build should not be able to read production drafts, and a developer's local token should not reach production at all.
Equally, issue one token per consuming application. If the marketing site, the mobile app and the search indexer share a single token, you cannot revoke it without breaking all three, so in practice nobody revokes it. Separate tokens make rotation and incident response routine. Name each token after its consumer and environment, record its owner and ticket reference in the description field where the platform offers one, and review the list quarterly.
For content models that hold personal data, such as author profiles, form submissions stored as entries or customer testimonials with contact details, consider a separate space, dataset or project with tighter access, so that a public delivery token cannot reach those types by accident.
Roles for people and integrations
Editor roles in a headless CMS decide who can publish, who can change content models and who can create tokens. Token creation is the key privilege: a user who can create a management token can create an identity that outlives their own account. Restrict token and integration management to a small group of administrators, and make sure tokens created by a departing user are reviewed during offboarding.
Where a platform lets a personal token act with the rights of the user who created it, avoid using personal tokens for automation. When that person changes role or leaves, the automation either breaks or, worse, keeps their old rights. Use the platform's machine or robot token type instead, owned by a team, with a documented purpose.
Connect the editorial interface to your identity provider with single sign-on and multi-factor authentication where your plan supports it, and use role mapping so that access is removed centrally when someone leaves.
Cross-origin access and the admin studio
Some headless platforms let browsers call the content API directly, controlled by an allow list of origins. The risky setting is one that allows credentials, meaning the browser sends a logged-in editor's session or token along with the request. If an origin with credentials enabled is broader than you intend, any page on that origin can act as your editors. Wildcards on shared hosting domains, such as the default preview domains of public hosting platforms, are the classic error: an attacker can deploy their own site on the same parent domain. Keep credentialed origins to exact hostnames you own, and remove origins for retired previews and sandboxes. Our CORS Misconfiguration Guide covers the general mechanics.
Webhooks and outbound integrations
Headless platforms emit webhooks when content changes, and those webhooks trigger builds, cache purges, search indexing and syncs into other systems. An unverified webhook endpoint is an unauthenticated trigger for your build pipeline. At minimum:
- Enable request signing where the platform supports it, store the signing secret in your secrets manager and verify the signature on every request.
- Check the signed timestamp and reject requests older than a short window to limit replay; add idempotency on the receiver so a replayed event cannot cause harm.
- Do not put credentials in webhook URLs as query parameters, because URLs end up in logs.
- Treat the webhook payload as untrusted input. Fetch the authoritative content from the API using your own credential rather than acting on fields in the payload.
The same thinking applies to installed apps and marketplace integrations. Each one receives a credential, often with write access. Review installed apps, the scopes they hold and who installed them. Our Webhook Secrets Security Guide goes deeper on signing secrets and rotation.
Platform notes
The following sections describe each platform's own controls from its public documentation as of November 2026. They are listed alphabetically and are not a comparison. Confirm details against each vendor's current documentation.
Contentful
Contentful's authentication reference describes API keys for the Content Delivery API and the Content Preview API, created in the web app under Settings and API keys. Delivery tokens give read-only access to one or more environments, and Contentful recommends separate tokens per environment, for example one for production and another for staging or CI, so each channel can be revoked independently. The Content Management API uses personal access tokens, created under Settings and CMA tokens, or OAuth tokens for public integrations. Personal access tokens carry the same rights as the account owner and cannot be retrieved after creation. Contentful recommends sending tokens in the Authorization: Bearer header rather than the access_token query parameter. For webhooks, Contentful's request verification feature uses a 64-character signing secret and adds x-contentful-signature, x-contentful-signed-headers and x-contentful-timestamp headers; the verifyRequest helper in @contentful/node-apps-toolkit applies a default 30-second time limit and can check both an old and new secret during rotation.
Payload
Payload is code-first, so access rules live in the application configuration. Its access control documentation describes three levels: collection, global and field access control, with separate functions per operation such as create, read, update and delete. Access functions run before an operation changes anything. By default Payload requires authentication: the default access function checks whether a user is present on the request, so teams that open read access for public content must do so deliberately in their own functions. The Local API skips access control by default; to enforce it, set overrideAccess to false. That default matters for server-side code paths such as preview routes and custom endpoints, which should pass the requesting user and enforce access rather than read everything. Access functions can also read req.locale to apply per-locale rules, and collections a user cannot edit are hidden in the Admin Panel.
Sanity
Sanity's authentication documentation describes robot tokens for applications and third-party services. Sanity advises a separate token per application so each can be replaced or revoked independently. Robot tokens are shown only once and do not expire by default, but an expiry of 30, 60 or 90 days or a custom date can be set; expired tokens cannot be reactivated. Unauthenticated users can read published documents except in cases such as private datasets, while reading drafts or making changes requires a project member with write access. Sanity's CORS documentation explains that an origin allowed to send credentials can make authenticated requests using the token or session of any logged-in visitor. It describes wildcards with credentials as dangerous, says never to add a platform-wide wildcard with credentials such as https://*.netlify.app or https://*.vercel.app, advises disabling fork deploy previews on public repositories and notes that a read-only token does not keep data private.
Strapi
Strapi's API tokens documentation describes tokens that let external clients call the Content API without a user account; they are separate from admin tokens and are rejected on each other's routes. Token types are Read-only, which can only use find and findOne, Full access and Custom, which sets permissions per content type. Durations are 7 days, 30 days, 90 days or Unlimited. Strapi pre-generates a Full access token and a Read-only token, which teams should review and remove or restrict if unused. Tokens are hashed with a salt held in API_TOKEN_SALT; changing the salt invalidates every existing token, which is a useful emergency control. Without an encryption key set in secrets.encryptionKey, a token is shown only once after creation or regeneration; with one, tokens stay viewable in the admin panel, so that setting widens who can read them. Tokens can be regenerated from the token's edit screen.
Responding to a leaked CMS token
When a CMS token appears in a bundle, repository, log or ticket, act on its tier. A published delivery token for genuinely public content is low urgency but should still be rotated. A preview token means unpublished content may have been read, so check what drafts and scheduled entries existed while it was exposed and brief whoever owns embargoed material. A management token is a full incident: revoke it, review the audit or activity history for changes made since the exposure began, compare published content against a known good export and check for new tokens, users, webhooks or installed apps created during the window.
- Identify the token's tier, environment and consumer from your inventory.
- Issue a replacement, deploy it to the consumer and then revoke the exposed token.
- Review activity for the exposure window and roll back any unauthorised content or configuration change.
- Find the root cause, such as a public environment variable or a committed file, and add a scanning rule to stop it recurring.
The API Key Leak Response Playbook gives a fuller response template.
Common failure patterns
- Preview token in a public environment variable. The token is inlined into the client bundle and unpublished content becomes readable by anyone.
- Management token used for builds. The build pipeline can rewrite the live site, so a pipeline compromise becomes a website compromise.
- One token for everything. Shared across sites, apps and environments, it can never be rotated without an outage, so it never is.
- Default tokens left in place. Tokens created at project set-up remain with broad rights long after anyone remembers them.
- Personal tokens for automation. Integrations break, or keep stale rights, when the creator changes role or leaves.
- Credentialed wildcard origins. A wildcard on a shared hosting domain lets unrelated sites act as logged-in editors.
- Unsigned webhooks. Anyone who finds the endpoint can trigger builds or push fake events into downstream systems.
- Personal data in public content types. Contact details stored in entries become readable through a public delivery token.
Practitioner checklist
- Inventory every CMS token with owner, consumer, environment, tier and expiry.
- Remove or restrict default tokens created at project set-up.
- Use delivery credentials for builds and runtime reads; keep management tokens for named jobs only.
- Render preview content on the server and gate preview routes with authentication.
- Issue separate tokens per application and per environment.
- Set expiry on tokens wherever the platform supports it, and rotate the rest on a schedule.
- Scan client bundles and source maps for CMS tokens before each release.
- Restrict token and integration creation to a small administrator group and review it at offboarding.
- Allow credentials only for exact, owned origins and remove retired preview origins.
- Enable and verify webhook signatures with a short timestamp window.
- Keep personal data in content types that public tokens cannot read.
- Rehearse a management token leak, including content rollback from a known good export.
Standards and references
- Contentful: Authentication reference
- Payload: Access Control overview
- Sanity: Authentication and API tokens
- Strapi: API Tokens
- Sanity: CORS origins
- Contentful: Webhook request verification
- OWASP: API Security Top 10 2023
- MITRE ATT&CK: T1552.001 Credentials In Files
Related NHI Mgmt Group resources: Secrets in Frontend JavaScript Bundles and Source Maps · Webhook Secrets Security Guide · CORS Misconfiguration Guide · API Key Leak Response Playbook