Preview your Content Before Publishing with the Content Preview API

September 23, 2014


There’s a reason why WYSIWYG editors are still around. People like to see how their content is going to look like before they make it publicly available. Many of our customers have been asking for this sort of functionality as well. The device-independent nature of Contentful however, makes this quite difficult.

Because our clients use Contentful to publish content across a ton of different platforms and devices, simply introducing a preview in your browser wouldn't cut it. You need to be able to review your content across mobile apps, large monitors in shops, cars, etc., so we built a solution that supports all of these use cases.

Consider for a second a media company publishing content across mobile apps and a website. When authoring an article you want to see it exactly as it will appear in the website and on your mobile apps. Previously, you could only accomplish this by publishing content with extra fields to control visibility, then filtering on those fields when displaying content in your applications. This approach meant that your "hidden" content could still be found by a user with a normal access token.

The new Content Preview API addresses this by providing an API that is compatible with our Content Delivery API, but instead of delivering the content you “Publish”, it fetches your latest draft content. None of your code needs to be adjusted. Simply change 2 options and your Content Delivery API based application will show your draft content as though it were published.

The Preview API uses a separate access token, so you can be sure that your draft content remains completely invisible to the public Delivery API. We've also added some extra safeguards in the Contentful app to prevent accidentally changing your production access tokens.

Preview API Screenshot

It takes just three clicks to obtain your API access tokens

One way this could be used is to set up private staging servers for websites, or preview builds of mobile applications, that use the Preview API instead of the Delivery API. This would allow you to preview your content as though it were published, every single time you make an adjustment. To learn more about how to use the new API, check out the developer documentation.

Happy editing :)

About the author

Don't miss the latest

Get updates in your inbox
Discover how to build better digital experiences with Contentful.
add-circle arrow-right remove style-two-pin-marker subtract-circle remove