🗓️ Everything *[NYC] is back. A free gathering for AI builders. Sept 9

How to make a document type non-deletable in Sanity?

8 repliesLast updated: Nov 29, 2025

How would I go about making a document type not deletable? I’ve come as far as adding only once instance to the structurebuilder but it’s still possible to duplicate and delete it. Tried with the following: “__experimental_actions: [“update”, /* ‘create’, ‘delete’, */ “publish”],” but it didn’t do anything for it.
AI Update

You're on the right track! The __experimental_actions property you mentioned was from Sanity v2 and is no longer the correct approach in v3. Here's how to properly disable delete and duplicate actions for a document type in the current version of Sanity:

Configure Document Actions in sanity.config.ts

You need to use the document.actions configuration in your sanity.config.ts file. Here's how to filter out the delete and duplicate actions for a specific document type:

import {defineConfig} from 'sanity'

export default defineConfig({
  // ... rest of your config
  document: {
    actions: (prev, context) => {
      // For your singleton document type, remove delete and duplicate actions
      if (context.schemaType === 'yourDocumentType') {
        return prev.filter(
          (action) => action.action !== 'delete' && action.action !== 'duplicate'
        )
      }
      return prev
    },
  },
})

Replace 'yourDocumentType' with the actual name of your document type.

For Multiple Document Types

If you need to apply this to multiple document types:

document: {
  actions: (prev, context) => {
    const singletonTypes = ['settings', 'homepage', 'footer']
    
    if (singletonTypes.includes(context.schemaType)) {
      return prev.filter(
        (action) => !['delete', 'duplicate'].includes(action.action || '')
      )
    }
    return prev
  },
}

Complete Example with Structure Builder

For a singleton pattern, you'd typically combine this with Structure Builder configuration:

import {defineConfig} from 'sanity'
import {structureTool} from 'sanity/structure'

export default defineConfig({
  // ... other config
  plugins: [
    structureTool({
      structure: (S) =>
        S.list()
          .title('Content')
          .items([
            S.listItem()
              .title('Settings')
              .child(
                S.document()
                  .schemaType('settings')
                  .documentId('settings')
              ),
            // ... other items
          ])
    })
  ],
  document: {
    actions: (prev, context) => {
      if (context.schemaType === 'settings') {
        return prev.filter(
          (action) => action.action !== 'delete' && action.action !== 'duplicate'
        )
      }
      return prev
    },
  },
})

This approach:

The key difference from v2 is that you're now filtering the prev array of actions rather than setting a property on the schema type itself. You can read more about this in the Document Actions documentation.

Show original thread
8 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