Sanity Library Reference Docs
    Preparing search index...
    • Defines a role that is scoped to the specified project.

      Parameters

      • projectId: string

        The ID of the project to which the role will be scoped

      • parameters: BlueprintRoleConfig

        The configuration of the role

        Configuration for a custom role.

        • appliesToRobots: boolean
        • appliesToUsers: boolean
        • Optionaldescription?: string
        • name: string

          The name of the resource. Unique within the blueprint. e.g. 'sync-webhook'

        • permissions: RolePermission[]
        • title: string

      Returns BlueprintProjectRoleResource

      The role resource

      defineProjectRole('my-project-id', {
      name: 'viewer-role',
      title: 'Viewer',
      appliesToUsers: true,
      appliesToRobots: false,
      permissions: [{
      name: 'sanity-project-cors',
      action: 'read',
      }],
      })
      defineProjectRole('my-project-id', {
      name: 'ci-deploy-role',
      title: 'CI Deploy Role',
      appliesToRobots: true,
      appliesToUsers: false,
      permissions: [{
      name: 'sanity-project-cors',
      action: 'create',
      }, {
      name: 'sanity-project-cors',
      action: 'delete',
      }],
      })

      defineRobotToken({
      name: 'ci-robot',
      memberships: [{
      resourceType: 'project',
      resourceId: 'my-project-id',
      roleNames: ['$.resources.ci-deploy-role'],
      }],
      })