🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

How to modify and delete grants and roles in the new Role/permissions system.

11 replies
Last updated: Jun 15, 2021
Hi, with the new Role/permissions system is it possible to:• Delete an existing grant from a role (maybe a
DELETE
request to the
/grants
endpoint?) • Delete an existing role? Not
deleting a user role , but deleting the role itself so that it doesn't show up when you fetch the list of roles through the
/roles
endpoint.
Jun 14, 2021, 11:03 PM
Hi User! You can only modify grants for roles you have created yourself. Same goes for delete
Jun 15, 2021, 12:13 AM
Hi
user P
, thanks that's good to know! Is there any documentation on how the request should look like for modifying/deleting grants (and deleting custom roles that I created, if that is possible)? I looked through a couple docs but wasn't able to find anything.
https://www.sanity.io/docs/roles-reference
https://www.sanity.io/docs/roles
Jun 15, 2021, 12:16 AM
Looks like the docs might be missing for creating grants atm, but you should be able to create a grant by POSTing to
/v2021-06-07/projects/{{project_id}}/grants
with the payload:
{
    "roleName": "role-name",
    "permissionName": "<permissionName>",
    "permissionResourceId": "<resourceId>",
    "params": {
    }
}
The permissions resource ids you can find at
/v2021-06-07/projects/{{project_id}}/permissionResources
Jun 15, 2021, 12:22 AM
Looks like we have a bug when it comes to deleting custom roles. I’ll get a fix rolled out ASAP tomorrow morning (CET-time)
Jun 15, 2021, 12:23 AM
Looks like we have a bug when it comes to deleting custom roles. I’ll get a fix rolled out ASAP tomorrow morning (CET-time)
Awesome, thank you!
Jun 15, 2021, 12:25 AM
Np. Sorry for the inconvenience. The route should be under
DELETE /v2021-06-07/projects/:id/roles/:roleName
Jun 15, 2021, 12:27 AM
What would the request look like for deleting grants? Would it be something like
DELETE /v2021-06-07/projects/:id/grants
with
roleName
,
permissionName
and
permissionResourceId
specified in the body?
Jun 15, 2021, 12:32 AM
Yes, delete would be the same as a create but DELETE instead of POST
Jun 15, 2021, 12:33 AM
Awesome! Thank you again for the help, I really appreciate it 🙌
Jun 15, 2021, 12:33 AM
Fix for the role delete should now be in production 🙂
Jun 15, 2021, 9:04 AM
Great! thanks for letting me know :D
Jun 15, 2021, 3:50 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?