
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeYes! You can use perspectives to control whether drafts are included in your queries without adding !(_id in path('drafts.**')) to every GROQ request.
The easiest solution is to set the perspective parameter to published when making your API requests. The perspectives feature provides different views of your content:
published - Returns only published documents (no drafts)previewDrafts - Returns drafts when they exist, falling back to published versionsraw - Returns everything (both drafts and published documents)In client configuration:
import {createClient} from '@sanity/client'
const client = createClient({
projectId: 'your-project-id',
dataset: 'production',
useCdn: true,
apiVersion: '2025-02-19',
perspective: 'published' // This filters out drafts automatically
})In individual queries:
const data = await client.fetch(
`*[_type == "post"]`,
{},
{perspective: 'published'}
)In HTTP API requests:
https://your-project.api.sanity.io/v2025-02-19/data/query/production?query=*[_type=="post"]&perspective=published
If you're using the API version 2025-02-19 or later, the default perspective changed to published, so you'll automatically get only published documents without any additional configuration. In older API versions, the default was raw, which includes both drafts and published documents.
This is much cleaner than manually filtering drafts in every query, and it gives you flexibility to switch between perspectives based on your environment (e.g., use previewDrafts for preview environments and published for production).
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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store