
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeI understand your frustration! The behavior you're experiencing is actually expected - when you use client.create() without specifying an _id, Sanity auto-generates one as a UUID, and this creates what Sanity considers a published document (no drafts. prefix in the ID).
The key thing to understand is that in Sanity, whether a document is "draft" or "published" is determined entirely by its _id:
drafts. (e.g., abc-123)drafts. (e.g., drafts.abc-123)According to the Perspectives documentation and Published Documents documentation, when you create a document without the drafts. prefix, it's already published.
The confusion likely comes from how you're viewing the documents. Here's what might be happening:
_id doesn't have drafts. prefix, they're already liveuseCdn: true, you might not see fresh data immediatelyRun this check to see what's really in your dataset:
const sanityClient = require('@sanity/client')
const client = sanityClient({
projectId: 'your-project-id',
dataset: 'bikeshop',
apiVersion: '2021-06-24', // Use a current date
token: 'sanity-auth-token',
useCdn: false // Important for accurate results
})
// Check for published documents (no drafts. prefix)
const published = await client.fetch('*[_type == "yourType" && !(_id in path("drafts.**"))]')
console.log('Published documents:', published.map(d => d._id))
// Check for draft documents (with drafts. prefix)
const drafts = await client.fetch('*[_type == "yourType" && _id in path("drafts.**")]')
console.log('Draft documents:', drafts.map(d => d._id))Your current approach should create published documents automatically:
const sanityClient = require('@sanity/client')
const client = sanityClient({
projectId: 'your-project-id',
dataset: 'bikeshop',
apiVersion: '2021-06-24', // Update to a current date
token: 'sanity-auth-token',
useCdn: false // Use false for write operations
})
// This creates a PUBLISHED document (auto-generated ID without drafts. prefix)
await client.create({
_type: 'yourDocumentType',
title: 'My Document',
// your other fields
})According to the Document ID documentation, when you don't specify an _id, Sanity auto-generates a UUID, and these are created as published documents by default.
Make these adjustments to your client setup:
useCdn: false - The CDN is only for reads, and using it for writes can cause confusionapiVersion - Use a more recent date like '2021-06-24' or laterIf you run the verification query above and find your documents ARE published (no drafts. prefix) but still aren't appearing where you expect:
published perspectiveThe documents created by client.create() without an explicit _id are already published and ready to use - no manual publishing step needed!
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