
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeI completely understand your frustration! Unfortunately, there's no built-in way to temporarily disable validation rules in Sanity Studio to allow publishing of documents that don't meet validation requirements. This is a common pain point when data gets imported via the API (which bypasses client-side validation) and then needs to be fixed in the Studio.
Here are your best options to fix this situation:
The most straightforward approach is to temporarily comment out or remove the validation rules from your schema definition:
defineField({
name: 'yourField',
type: 'string',
// validation: (rule) => rule.required(), // temporarily disabled
})After making this change:
This is the cleanest approach because it lets you use the Studio's UI to fix the data properly.
Since the API bypasses Studio validation, you can write a script to fix the data programmatically using the Mutation API. This is especially useful if you have many documents to fix:
import {createClient} from '@sanity/client'
const client = createClient({
projectId: 'your-project-id',
dataset: 'your-dataset',
token: 'your-token',
apiVersion: '2024-01-01'
})
// Query for problematic documents and patch them
const documents = await client.fetch(`*[_type == "yourType"]`)
for (const doc of documents) {
await client
.patch(doc._id)
.set({ yourField: 'corrected-value' })
.commit()
}This approach is particularly useful for bulk fixes or when the correction logic is straightforward enough to script.
As noted in the field validation documentation, validation in Sanity is client-side only within the Studio. This is why the API accepted your incorrect data in the first place – the Mutation API doesn't enforce the same validation rules that the Studio does. This design gives you flexibility but means you need to implement your own validation layer if you're accepting data via API.
For future imports, consider validating your data against your schema rules before pushing to the API, or implement a validation layer in your import scripts to catch these issues before they reach your dataset.
The temporary schema modification approach (Option 1) is usually the fastest way to unblock yourself and get your content back to a publishable state!
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