Skip to content

Exchange a preview token

POST
/content/delivery/v1/preview/exchange
curl --request POST \
--url https://api.ebitex.io/content/delivery/v1/preview/exchange \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "token": "example" }'

Turns the one-time ebitex-preview-token that live preview adds to a server-rendered site’s URL into a preview session secret. Keep the secret in your own cookie, redirect to the same address without the token, and send the secret as X-Ebitex-Preview-Session when resolving paths.

A token is valid for five minutes and can be spent once. A session ends when the editor closes live preview, after 30 minutes without an edit, or 8 hours after it started.

Key: a server-side delivery key with content.delivery.preview (Allow draft preview). A browser-safe key can never hold it.

Media typeapplication/json
object
token
required
null | string
Examplegenerated
{
"token": "example"
}

{ "session": "cps_…", "expiresAtUtc": "…" }

invalid_preview_token: the token is spent, expired, unknown, or was minted for another delivery environment.

missing_api_key or invalid_api_key: no key was sent, or it is unknown, revoked or expired.

scope_denied: the key lacks this route’s scope. origin_denied or ip_denied: a browser-safe key was used from an origin or address outside its restrictions. app_not_available: Content is not enabled for the organization.

Quota exceeded; Retry-After says how long to wait. too_many_failed_authentications: too many bad keys from this address.