How AI is powering better personalization in e-commerce [with Vercel]. Sign up now

How can I delete a document in sanity studio?

2 repliesLast updated: Nov 29, 2025

Hi! how can I delete a document in sanity studio?
AI Update

There are a few ways to delete documents in Sanity Studio depending on your needs:

Deleting in Sanity Studio (UI)

The most straightforward method is through the Studio interface:

This is part of the document actions system in Sanity Studio. The delete action is available by default for all documents unless it's been explicitly disabled through custom document actions configuration.

Deleting via Sanity CLI

If you need to delete documents programmatically or in bulk, you can use the Sanity CLI:

sanity documents delete <document-id>

You'll need to have the Sanity CLI installed (npm install -g @sanity/cli) and be authenticated to your project.

For bulk deletions, you can combine GROQ queries with the delete command:

sanity documents query "*[_type == 'yourType']" | sanity documents delete

Programmatic Deletion

You can also delete documents programmatically using the Sanity client:

import {createClient} from '@sanity/client'

const client = createClient({
  projectId: 'your-project-id',
  dataset: 'your-dataset',
  token: 'your-token',
  apiVersion: '2024-01-01'
})

await client.delete('document-id')

Troubleshooting

If you don't see the delete option in the Studio menu, it could be because:

The delete action may be filtered out for certain document types to prevent accidental deletion of critical content like site settings or configuration documents.

Show original thread
2 replies

Was this answer helpful?

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.

Related contributions