
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThere are two officially documented ways to bulk delete documents from Sanity:
The official CLI documents command provides a delete subcommand that can delete documents by ID:
# Delete single document
sanity documents delete myDocId
# Delete multiple documents by ID
sanity documents delete doc1 doc2 doc3Important limitation: The CLI delete command works by document ID only. There's no built-in --query flag to delete by filter directly from the CLI.
For deleting documents based on a GROQ query, you need to use the JavaScript client. There's an official recipe for this approach:
/**
* THIS SCRIPT DELETES DATA!
*
* To use:
* 1. Save this as deleteDocsByFilter.js in your studio folder
* 2. Backup your dataset: sanity dataset export
* 3. Run: sanity exec deleteDocsByFilter.js --with-user-token
*/
import client from 'part:@sanity/base/client'
client
.delete({query: '*[_type == "aDocumentType"][0...999]'})
.then(console.log)
.catch(console.error)Important notes:
[0...999] slice is critical - you can delete up to ~1000 documents per transactionsanity documents queryThe Vision plugin is great for testing queries, but it cannot perform deletions. Vision is read-only for querying - you must use the CLI or client for mutations.
Before deleting, verify your query targets the right documents:
# Preview which documents will be affected
sanity documents query '*[_type == "myType"]._id'This approach is documented in the official Sanity HTTP mutations reference, which confirms the delete mutation accepts a query parameter for bulk operations.
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