Easily restore your project to a previous version with our new Instant One-click Backup Recovery
Hygraph
Docs

Roles and permissions

Roles are a critical part of ensuring the safety of the data stored in a CMS, creating efficient workflows, building independent teams. Each role has specific permissions which determine what the user is allowed to perform and view in the CMS.

With some roles in Hygraph, you do not see the developer functionality, which declutters the interface and makes sure you only see what is relevant to your role.

Roles and Permissions overviewRoles and Permissions overview

#System roles

System roles are the default roles in Hygraph, and cannot be edited or deleted.

There are five standard system roles in Hygraph. As part of the content team, the Owner, Editor, and Contributor roles are relevant to you.

Each role has its own set of predefined permissions, as follows:

RoleRights
OwnerAdmin + Ability to change billing and to delete projects
AdminDeveloper + Ability to manage teams and create, update projects.
DeveloperEditor + Ability to create, update and delete models and enums.
EditorContributor + Ability to delete content.
ContributorAbility to create and update content.

Since every team is different and sometimes people wear more than one hat in the company, it is possible to create custom roles.

#Custom roles

Custom Roles will let you create roles that match the functionality that they need, without having to see features they don't need. Custom roles can only be created by Project Admins and Owners. These roles are fully adjustable to provide maximum flexibility in permissions for each user working on the project.

When creating custom roles, it is important to remember to select all of the Read permissions - read and read versions - in order for the user to have the required basic functionality. If Read permissions are not selected, the user won't be able to open a content entry.

You can find roles and permissions under settings. Click here to read more about custom roles permissions.

#Add custom role

Add custom roleAdd custom role

To add a custom role, click on the + Add custom role button, located at the top right corner of the custom roles form. The Create role screen will pop up as a result.

Add a role screenAdd a role screen

Add the name of the role in the Name field, and optionally add a description in the Description field. Once you've completed this, click on the Create button to add the new custom role to the form.

Now that you've added the custom role to your project, you can select the following options in the context menu:

#Edit custom role permissions

To edit custom role permissions, click on the role on the table. The permissions screen for that role will display as a result.

Edit custom role permissionsEdit custom role permissions

In addition to the actions for the regular View Permissions screen - described here - you can add Content Permissions, and edit Management API Permissions.

#Add Content Permissions

To add Content Permissions, click on the + Add permission button. The Add permission screen will pop up as a result:

Add Content permissionsAdd Content permissions

Use the Model dropdown to select the model that permissions will be applied to. By default, the action rules will be applied to all the models in your project. However, you can choose to restrict the permissions to only one model.

Next, use the checkboxes to select which content permissions should be assigned to the custom role. When you select a checkbox, additional options might display, such as dropdowns to select Locales and Stages. This will help you customize your roles further, as the configuration is extremely granular.

NamePermissions
ReadMinimum permission required to be able to view content entries.
CreatePermission to create new content entries and save it.
UpdatePermission to make some changes to already existing content entries and save the changes.
DeletePermission to delete a content entry.
PublishPermission to publish content.
UnpublishPermission to unpublish content.
Read versionsPermission to view versions of content.

You have the option to use the Reset button located at the bottom left corner of the screen to reset the permissions to their default state.

Once you have set the permissions for the role, click on Create to save.

#Edit Management API Permissions

To edit Management API Permissions, use the switches. By default, the screen shows only the permissions that are enabled, to see the full list click on Show all available permissions instead at the top of the form.

Edit Management API permissionsEdit Management API permissions

  • Basic Read permissions are selected by default, as they are necessary for the user to have the required basic functionality. You can edit this - if needed - and select other permissions as well.
  • If you use the checkboxes to select more than one of the enabled permissions, the Disable selected bulk action appears at the top of the table.
  • If you use the checkboxes to select more than one of the disabled permissions, the Enable selected bulk action appears at the top of the table.
  • The Show all permissions link at the top of the table displays all permissions, enabled and disabled. After clicking on it, the link at the top of the table will say Show enabled permissions, and clicking on it returns you to the view where only enabled permissions are visible.

#Delete a custom role

While system roles cannot be deleted, custom roles can. To delete a custom role, select the Delete role option from the context menu.

Delete a custom roleDelete a custom role

As this action cannot be reverted, a confirmation screen will pop up.

Delete a custom role - confirmationDelete a custom role - confirmation

Click on the Delete button to confirm.

#Assign members

Follow these instructions to assign a team member to a role:

Assign members to a custom roleAssign members to a custom role

  1. Click on the Assign members option for the role you want to add members to.
  2. Select one or more team members using the checkboxes.
  3. Click Assign.

If the person you want to assign to the role has not yet been invited to the project, you can navigate to Members and invite them.

#View permissions

To view all the Content & Management API permissions associated to a role, select the View Permissions option from the context menu. A screen will display listing all the granted permissions for that role.

You can sort the permissions alphabetically by model or action, and you can filter them by actions, models, locales, and stages.

You also have the option to assign new members to the current role from this screen, by clicking on the Assign members button located at the top right corner of the screen. Clicking on this button triggers the Assign member flow that we described in the previous section.

#Removing a user

You can remove team members from a specific role in Project settings > Team > Members.

Check out this document to learn more.

#Examples

This document section provides some examples for different setups.

#Read-only user

This example shows the setup of a read-only permission on all models, on all locales and stages.

Read-only userRead-only user

Content API permissions:

  • Model dropdown: Select all.
  • Read: Select this rule for all locales and all stages.
  • Read versions: Select this rule.

For this type of read-only permission set up, the Management API Permissions will have already been pre-selected - by default - and you do not have any further setup to do.

#Read and publish setup

For a Read and Publish permissions setup, you must first set up the Content API permissions.

Read and publish setupRead and publish setup

Content API permissions:

  • Model dropdown: Select all.
  • Read: Select this rule for all locales and all stages.
  • Publish: Select this rule from all stages, to all destination stages, with all locales.
  • Read versions: Select this rule.

Once the Content API permissions are set, use the checkboxes below to select the following Management API Permissions:

  • Update published entries
  • Create new entries
  • Publish non published entries
  • Update existing non published entries
  • Delete existing entries

#Setup by models

You can choose to restrict the permissions to access only one model.

To do that you should click on the Model dropdown menu, and select the model desired for this custom role.

Setup by modelsSetup by models

#Setup by locales

If your project has several locales, then you can set up the permissions on all locales, only one, or several ones.

Setup by localesSetup by locales

When selecting a rule, simply select the locale or locales you wish to grant access to from the dropdown menu.

#Setup by content stage

Your project is created with two content stages by default (DRAFT and PUBLISHED). If your project had a QA stage, for instance, you could choose to restrict the permissions to DRAFT stage, or only allow a role to publish from the DRAFT stage to an intermediate QA stage before publishing.

Setup by content stageSetup by content stage

Simply use the dropdown menus to select From stages and To stages.

#Setup by environment

Every Hygraph project has its main environment, or master environment. By default, when creating a content based permission, the role will be created on all your environments at the same time, in an identical way.

However, you can set up different permissions per environment. For instance, you can set up a role that allows users to publish on a secondary environment and has read-only permissions on the master environment.

To set up the use case described above, follow these steps:

  1. Go to your master environment
  2. Set up a role on the master environment as a read-only role, as described here.
  3. Go to your second environment.
  4. Go to the custom role you have just created, and select View Permissions from the context menu, so you can edit them.
  5. Edit the Content API Permissions: To the Read permissions, you will add the Publishing and Unpublishing permissions.
  6. Edit the Management API Permissions: At the moment only Read permissions are selected, so you will have to add the Publishing permissions, as described here.

#Conditions

You can use conditions to grant some users less access than others. For the following example, imagine you want to set up the role permission for one model only and, additionally, you want users in this role to have access to only one content entry of this model and fields related to it.

You can do this by using content conditions. You can use fields like id for certain content entries to grant users in this role the ability to create/update/delete/publish a specified entry. The setup would be then similar to this example:

ConditionsConditions

The condition shown above would grant the user permission to read the content entry with this particular id.

#Resources

You might find the following documents useful:

  • Permissions: This document contains information on permissions, how they work, and their limits.
  • Authorization: This document contains information on public API permissions, permanent auth tokens, and API endpoints.
  • API access: This document covers the API access section of the Hygraph app as well as its subsections: Endpoints, Content API, and Permanent auth tokens.