Skip to main content

Custom roles

If Self, Admin, and Public do not fit your needs in permissioning, then you may need to set up a custom role. (For example, perhaps you want certain sensitive data to only be accessible by admins and your compliance team. You would need to set up a "compliance" role, and add requester IDs of your compliance team members to that role.)

Setting up roles in the Privy console

You can create or edit roles easily using the Privy console. To do so, navigate to https://www.console.privy.io/roles. New roles will be available to assign to field permissions).

Once here, you can click on the + New Role button to create a new role. From there, just give your role a name (the API-safe ID is generated for you based on the name) and type the IDs of users who are part of this role inside the textbox.

Click Save and you're done.

Setting up roles using the Privy API

You can create a new role using privy-node as shown below:

import {PrivyClient} from 'privy-node';

const client = new PrivyClient(PRIVY_API_KEY, PRIVY_API_SECRET);

const newRole = await client.createRole('my-role-name', 'my-role-description');

Once you have created a role, you can add requester IDs to the role via the addRequestersToRole method as shown below:

const newRoleRequesters = await client.addRequestersToRole('<role_id>', [
'<requester_id_1>',
'<requester_id_2>',
'etc...',
]);

Now, you can assign your new custom role to Reader or Writer permissions for a field!