Set confluence Page permissions through plugin or User macro

Hello everyone,

Is there methods to set a page restrictions in Confluence server for particular users.

For example method to restrict particular user to edit or view the page, maybe through REST API or maybe the Java doc methods.

I have looked but haven’t find anything.

Also is is possible to make those restrictions through the User Macro, or maybe the User Macro is all about rendering some content.

Thank you

Hi Ivana,
for plugin development this can be done via the ContentPermissionManager.
You first have to get a ContentPermnissionSet from the desired page for the permission type you want to assign (these types are ContentPermission.EDIT_PERMISSION,ContentPermission.SHARED_PERMISSION, ContentPermission.VIEW_PERMISSION). Then you can create a new ContentPermission via the ContentPermission (you can use the method createUserPermission(, )
for this). Now you only have to add this new permission to the previously taken ContentPermisssionSet and via ContentPermissionManager add the ContentPermission to the page.
Then save the page and you are fine.
Hope this helps.

Regards Götz