Skip to main content

Delete a role with the Node.js SDK

permit.api.roles.delete() deletes a role, identified by key or ID, from the Permit.io environment that your Node.js SDK client is connected to. This reference is for backend developers who manage roles from code.

Prerequisites

Method signature

MethodSignatureStatus
permit.api.roles.deletedelete(roleKey: string): Promise<void>Recommended
permit.api.deleteRoledeleteRole(roleId: string): Promise<AxiosResponse<void>>Deprecated alias

Parameters

NameTypeRequiredDescription
roleKeystringYesKey or ID of the role to delete.

Example

await permit.api.roles.delete(roleKey);

Return value

permit.api.roles.delete() resolves to undefined when the role is deleted. The deprecated permit.api.deleteRole() resolves to the Axios response of the delete request.

If the role doesn't exist or the Permit API returns another error status code, permit.api.roles.delete() throws a PermitApiError. The deprecated permit.api.deleteRole() rethrows the underlying Axios error.