
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeI understand your frustration! This error occurs because Sanity uses strong references to maintain referential integrity - documents that are referenced by other documents cannot be deleted to prevent broken links.
The good news is that the error message actually tells you which document is referencing the one you're trying to delete: 2a3d6c4b-f2bf-47ab-bf9f-e90709b88b79. Here's how to resolve this:
Open the referencing document in Sanity Studio by navigating to:
https://your-project.sanity.studio/desk/YOUR_DOCUMENT_TYPE;2a3d6c4b-f2bf-47ab-bf9f-e90709b88b79
Or use Vision (the GROQ query tool in your Studio) to find it:
*[_id == "2a3d6c4b-f2bf-47ab-bf9f-e90709b88b79"]If you need to find all documents that reference your target document, use this GROQ query:
*[references("25e2930f-4a28-48c6-8e08-673d8ab9e0ad")]The references() function in GROQ will find any document that has a reference field pointing to your document.
Once you've found the referencing document(s), you have a few options:
You can also use the CLI to patch the document and remove the reference. For example, if the reference is in a field called myReference:
sanity documents patch 2a3d6c4b-f2bf-47ab-bf9f-e90709b88b79 --unset myReferenceAfter removing all references, you should be able to delete your original document:
sanity documents delete 25e2930f-4a28-48c6-8e08-673d8ab9e0adIf you need references that don't prevent deletion, you can configure your schema to use weak references by setting weak: true in your reference field definition. Weak references allow the referenced document to be deleted without blocking, though this means you could end up with broken references.
The error message will keep telling you which documents are blocking the deletion, so you may need to repeat this process if multiple documents reference the one you're trying to delete.
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