BetaThe configuration of the permission
Deploying Permissions via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
Configuration for a custom permission resource. This feature is subject to breaking changes.
Betaconfig: { filter: string }The configuration of the permission.
A GROQ filter that selects the documents that the permission applies to, e.g. _type == "article".
Optional Betadescription?: stringA description of the permission. Defaults to an empty string.
Betaname: stringThe name of the permission.
Lowercase letters, numbers, hyphens, and underscores only. Must not start with sanity or res-.
BetapermissionType: BlueprintPermissionTypeThe type of the permission. It cannot change after the permission is created.
Manage creates content resources as sanity.document.filter.mode, and lists only custom permissions of that type.
Optional Betaproject?: stringThe project ID of the project that contains the permission.
The project attribute must be defined if your blueprint is scoped to an organization and the stack has no default project.
Optional Betatitle?: stringA human-readable title. Defaults to name.
The permission resource
definePermission({
name: 'articles-only',
title: 'Articles only',
description: 'Access to article documents',
permissionType: 'sanity.document.filter',
config: {filter: '_type == "article"'},
})
defineRole({
name: 'article-editor',
title: 'Article editor',
appliesToUsers: true,
appliesToRobots: false,
permissions: [
{name: 'sanity-project', action: 'read'},
{name: '$.resources.articles-only', action: 'read'},
{name: '$.resources.articles-only', action: 'update'},
],
})
Defines a custom permission that roles can grant, in the shape of the Access API.