Skip to main content

Unassign a role from a user with the Node.js SDK

permit.api.users.unassignRole() removes a role that a user holds in a tenant of the Permit.io environment that your Node.js SDK client is connected to. This reference is for backend developers who revoke roles from code.

Prerequisites

Method signature

MethodSignatureStatus
permit.api.users.unassignRoleunassignRole(unassignment: RoleAssignmentRemove): Promise<void>Recommended
permit.api.unassignRoleunassignRole(removedRole: RoleAssignmentRemove): Promise<AxiosResponse<void>>Deprecated alias

Parameters

The method takes one argument: a RoleAssignmentRemove object. Pass the object itself, not a JSON string.

FieldTypeRequiredDescription
userstringYesKey or ID of the user who loses the role.
rolestringYesKey or ID of the role to remove.
tenantstringYesKey or ID of the tenant in which the user holds the role.
resource_instancestringNoResource instance of an instance-level role, as an ID or in the format resource_type:resource_instance_key.

Example RoleAssignmentRemove object:

{
role: "role",
tenant: "tenant",
user: "user"
}

Example

await permit.api.users.unassignRole(unassignedRole);

Return value

permit.api.users.unassignRole() resolves to undefined when the role assignment is removed. The deprecated permit.api.unassignRole() resolves to the Axios response of the delete request.

If the Permit API returns an error status code, permit.api.users.unassignRole() throws a PermitApiError. The deprecated permit.api.unassignRole() rethrows the underlying Axios error.