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
- A
permitclient created with an API key for the environment. See Create a Permit client.
Method signature
| Method | Signature | Status |
|---|---|---|
permit.api.roles.delete | delete(roleKey: string): Promise<void> | Recommended |
permit.api.deleteRole | deleteRole(roleId: string): Promise<AxiosResponse<void>> | Deprecated alias |
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
roleKey | string | Yes | Key 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.