Content updates visible in Desk/Vision but not available through API
This is a classic issue that catches people! Yes, this happens, and it's almost always related to API perspectives and a recent default behavior change.
The Most Likely Cause: Perspective Mismatch
When you see content in Studio/Vision but not in your API responses, you're probably querying with the published perspective (or no perspective specified, which now defaults to published as of API version 2025-02-19), but your documents only exist as drafts.
Here's what's happening:
- Studio and Vision show you the
rawperspective by default (all documents including drafts) - Your API queries are likely using the
publishedperspective (only published documents) - If you've been editing but never clicked "Publish" in Studio, your documents have IDs like
drafts.post-123and won't appear in thepublishedperspective
Quick Fixes
1. Check if your documents are published:
Look at the document ID in Studio. If it starts with drafts., it hasn't been published yet. Click the "Publish" button in Studio.
2. Use the correct perspective in your API calls:
Add ?perspective=previewDrafts to your API URL:
https://YOUR_PROJECT_ID.api.sanity.io/v2025-02-19/data/query/YOUR_DATASET?query=YOUR_QUERY&perspective=previewDrafts
3. If using a client library:
const client = createClient({
// ... other config
perspective: 'previewDrafts', // or 'raw' to see everything
})Understanding Perspectives
Sanity has several perspectives:
published- Only published documents (nodrafts.prefix)previewDrafts- Prefers draft versions when they exist, falls back to publishedraw- Everything (both drafts and published versions)
Recent Breaking Change
If this suddenly started happening after February 2025, note that the default perspective changed from raw to published in API version 2025-02-19. This means if you're using the latest API version without explicitly setting a perspective, you'll only see published content.
Still Not Working?
If you've verified the perspective and documents are published, check:
- CDN caching: The API has a CDN. Try adding
?perspective=published&t=${Date.now()}to bust cache - Dataset: Confirm you're querying the correct dataset (production vs. development)
- API version: Make sure your client library and API endpoints are using compatible versions
The UI inspector and Vision both use the raw perspective by default, which is why you see the content there but not in your production API calls. This is actually a feature - it lets you preview unpublished changes!
Show original thread23 replies
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.