What is Role Definition ID?

In SharePoint, we are all familiar with SharePoint Permission and Permission levels like Full Control, Edit, Contribute, etc. We use these permission levels to manage Site/List/item level accessibility. Sometimes we create custom permission for business requirements. These permissions are defined in SharePoint with a unique id which is called “SharePoint Role Definition ID”.

Why it is needed?

In general, role definition IDs are not needed to provide permission to a user or group in a Site, List, or List Item. We can do it with OOB by clicking some steps. But when we try to set permission by using REST Calls, we can’t use the permission level’s name. Then we need these Role Definition IDs. As an example, if we try to change a user’s/group’s permission with a rest call, it will be as follows.

<SiteAddress>/_api/web/lists/getbytitle('<ListTitle>')/items(<ListItemId>)/roleassignments/addroleassignment(principalid='<Group/User’sPrincipleID>',roleDefId=<RoleDefinitionID>)

How to get a Role Definition ID?

So, now the question that comes to mind is, how to get these permission levels assigned an ID or SharePoint Role Definition ID. For most of the common permission levels, we can get the Role Definition Id from the internet easily. Here are some out-of-the-box role definition names (Permission level) and their corresponding role definition IDs given below.

Role Definition Name Role Definition Id
Full Control 1073741829
Design 1073741828
Edit 1073741830
Contribute 1073741827
Read 1073741826
Limited Access 1073741825
View Only 1073741924

But what about any custom permission level that is being created for some specific purpose in that site? Now step by step, we will walk through the process of how to get the SharePoint Custom Role Definition ID. To get the custom permission’s role definition ID we have to use rest call. And with this rest call we will also get the above out-of-the-box role definition IDs.

<SiteCollection>/_api/web/roledefinitions

Example

Let’s create custom permission in the site collection and get the role definition ID for that as an example with the following steps.

Conclusion

So this is the way to find the SharePoint Role Definition ID’s. In recent days when SharePoint 2010 Workflows are going to be retired, we had to use SharePoint 2013 workflow or Microsoft Power Automation. In these procedures, we need these Role Definition IDs to set permission with REST Call. I hope this article will help. Happy Coding.