Skip to main content

Delete a user with the Node.js SDK

permit.api.users.delete() deletes a user, identified by key or ID, from the Permit.io environment that your Node.js SDK client is connected to. The Permit API deletes the user and the data related to the user. This reference is for backend developers who remove users from Permit when the users leave the application.

Prerequisites

Method signature

MethodSignatureStatus
permit.api.users.deletedelete(userKey: string): Promise<void>Recommended
permit.api.deleteUserdeleteUser(userId: string): Promise<AxiosResponse<void>>Deprecated alias

Parameters

NameTypeRequiredDescription
userKeystringYesKey or ID of the user to delete.

Example

await permit.api.users.delete(userKey);

Return value

permit.api.users.delete() resolves to undefined when the user is deleted. The deprecated permit.api.deleteUser() resolves to the Axios response of the delete request.

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