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