Sanity Pioneers: Get early access to betas, extra AI credits, and a direct line to the engineering team. Apply now

Can a single Sanity dataset contain both public and private documents?

10 repliesLast updated: Nov 29, 2025

Is that possible to create a dataset that contains public & private documents, and the client can only access the public data while in the CMS can access both public and private data? Or I can only create different datasets individually?
AI Update

Yes, absolutely! You can create a single dataset that contains both public and private documents, and control access so that:

This is achieved through Custom Roles (available on Enterprise plans) combined with GROQ filters and API tokens. Here's how it works:

Document-Level Access Control

You can use content resources with GROQ filters to define which documents are accessible. For example, add a field to your documents like isPublic: boolean, then create a custom role that filters documents:

// Custom role configuration
{
  name: 'public-reader',
  permissions: [
    {
      name: 'read-public-only',
      filter: '_type == "article" && isPublic == true',
      grant: ['read']
    }
  ]
}

This means:

Important Considerations

Alternative: Separate Datasets

If you're not on an Enterprise plan (Custom Roles are Enterprise-only), you would need to use separate datasets instead. You can configure multiple datasets using workspaces and have your frontend only query the public dataset while Studio users can switch between both datasets.

The single-dataset approach with Custom Roles is generally more flexible and easier to manage, especially if content needs to transition between public and private states. With separate datasets, you'd need to manually copy or recreate documents when changing their visibility status.

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