
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeYes, 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:
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:
isPublic == trueDataset Privacy: Set your dataset to private (not public). Public datasets allow anyone to read all documents regardless of authentication, which would bypass your access control.
API Tokens: Create different API tokens with different role assignments:
Roles are Additive: If a token has multiple roles, it gets the combined permissions of all roles.
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.
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