Delete a tenant with the Node.js SDK
permit.api.tenants.delete() deletes a tenant, 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 remove tenants from code, for example when a customer account closes.
Prerequisites
- A
permitclient created with an API key for the environment. See Create a Permit client.
Method signature
| Method | Signature | Status |
|---|---|---|
permit.api.tenants.delete | delete(tenantKey: string): Promise<void> | Recommended |
permit.api.deleteTenant | deleteTenant(tenantId: string): Promise<AxiosResponse<void>> | Deprecated alias |
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
tenantKey | string | Yes | Key or ID of the tenant to delete. |
Example
await permit.api.tenants.delete(tenantKey);
Return value
permit.api.tenants.delete() resolves to undefined when the tenant is deleted. The deprecated permit.api.deleteTenant() resolves to the Axios response of the delete request.
If the tenant doesn't exist or the Permit API returns another error status code, permit.api.tenants.delete() throws a PermitApiError. The deprecated permit.api.deleteTenant() rethrows the underlying Axios error.