How roles grant access in Sanity
Permissions are additive, so a member or token with several roles gets the combined permissions, and one role cannot remove what another grants. A custom role limited to one document type therefore restricts nothing when the same member also holds a default role with access to all documents. Content access levels build on each other, from Read through Update and create to Publish, which adds deleting and publishing. Roles do not hide a public dataset, where every project member can read published content even when their role is set to no access.
Organization roles apply across the whole organization, while project roles are specific to one project. Membership in an organization does not by itself give access to its projects. The appliesToUsers and appliesToRobots flags of a role decide whether people, robot tokens, or both can hold it, as Sanity's roles and permissions concepts page explains.
Default roles per plan and custom roles
The Free plan has two default roles, Administrator and Viewer, and the Growth and Enterprise plans add Editor, Developer and Contributor. Sanity's Roles page describes what each one can do.
Administrator has read and write access to all datasets and full access to all project settings.
Editor has read and write access to all datasets and limited access to project settings, and cannot create new datasets.
Developer has read and write access to all datasets and access to the project settings that developers need.
Viewer has read-only access to all datasets and no access to project settings.
Contributor has read and write access to draft content in all datasets, but cannot publish documents.
Only an administrator can assign or remove a default role that has admin permissions, a rule that does not apply to custom roles. Users who hold only the built-in Viewer role do not count toward a plan's seats. A custom role is billed as a regular user even when it grants only read access. The Sanity CMS pricing article lists seat prices and limits for each plan.
Custom roles are a paid feature on certain Enterprise plans. The Sanity vs Directus comparison sets Sanity's role and SSO limits next to those of Directus. A team defines a custom role in Manage, on the Roles screen of the Access section, or with the Access API. A content resource is a GROQ filter that limits the permissions of a custom role to some documents, for example one document type. In a new custom role, all content permissions start at No access.
Pagepro's Sanity CMS development page covers builds and migrations, with editor roles and permissions as one part of the setup.
Sources
- RolesSanity · sanity.io
- Roles and permissionsSanity · sanity.io
- Keeping your data safeSanity · sanity.io
- Platform terminologySanity · sanity.io
- Access API referenceSanity · sanity.io