Content updates visible in Desk/Vision but not available through API

23 replies
Last updated: Nov 9, 2021
has anyone ever experienced an issue where no content updates will come through your API, but they are visible in the Desk/Vision UI both locally and sanity hosted, and the UI inspector?
AI Update

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 raw perspective by default (all documents including drafts)
  • Your API queries are likely using the published perspective (only published documents)
  • If you've been editing but never clicked "Publish" in Studio, your documents have IDs like drafts.post-123 and won't appear in the published perspective

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 (no drafts. prefix)
  • previewDrafts - Prefers draft versions when they exist, falls back to published
  • raw - 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 thread
23 replies
This usually happens if a site is statically generated and needs a new build triggered in order to display new content.
user M
thanks. I'm using NextJS and I've running the new builds, but it actually doesn't show as updated in vision or hitting the API directly in the browser or using a REST client
I'm trying to figure out if there is a way to see all data, deleted or otherwise
I'm trying to figure out if there is a way to see all data, deleted or otherwise
and if there is a way to force pulling the latest data
Ah, I thought you had said that changes were showing up in Vision in your first post.
😬 my bad, i meant to say they were not showing up. I'll updated that
oh wait no, yeah they show up when inspecting the post in the Sanity UI, but not when pulling through an API/GROQ query
Hmm, have you double checked that the changes are published and not in drafts mode?
for example, here the "slug" and "mainImage" is there
but here, when running a groq query they are both null. Yes fully published and pulling from the same dataset.
but here, when running a groq query they are both null. Yes fully published and pulling from the same dataset.
If you set the api to v03-25-2021 does it work?
nope
that's what I have it set to normally
basically after i created this post, maybe i did something to break sync between the CMS and the API that gets generated from it because not post updates show for any posts and no new ones will show up.
The
_type == 'review'
might be stale documents from work done in the past? I’ve done that with
post
and
posts
.
GASPS
oh my goodness
first, good eye. second, it's a mistake I've made on other things (we all do it) and I was telling my cousin whom I'm helping teach to code this happens... burning a couple out hours for missing and "s". Thank you sir, and thank you User
hours*
I’ve been there many times, too. Glad it’s straightened.
it's all good, have a good one

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.

Was this answer helpful?