Joint session with Vercel: How to build intelligent storefronts (May 15th)

Getting latest draft via HTTP API

1 replyLast updated: Nov 30, 2025

Hey all. Is there a way using the HTTP API to get the latest draft of some content? I can't seem to find any documentation on getting drafts through the HTTP API.
AI Update

Absolutely! You can get draft content through the HTTP API using the perspective parameter. Sanity has built-in support for this via their Perspectives feature.

Here's how it works:

Using the previewDrafts perspective

The easiest way to get the latest draft is to use the previewDrafts perspective, which prioritizes draft documents over published versions:

/v2025-02-19/data/query/YOUR_DATASET?query=*[]&perspective=previewDrafts

This will return draft versions when they exist, and fall back to published content when no draft is available.

Available perspectives

You have several options depending on your needs:

Important notes

Using with the JS/TS client

If you're using @sanity/client, you can configure it like this:

import {createClient} from '@sanity/client'

const client = createClient({
  projectId: 'your-project-id',
  dataset: 'your-dataset',
  useCdn: false, // Required for drafts
  perspective: 'previewDrafts',
  token: 'your-token' // Required for authentication
})

This is similar to how other headless CMSs handle drafts (like Contentful's preview API, Strapi's publicationState=preview, or Storyblok's version=draft), but Sanity's perspective system is more flexible and works consistently across all queries.

Check out the full Perspectives documentation and the guide on presenting and previewing content for more details!

Show original thread
1 reply

Was this answer helpful?

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Related contributions