Skip to main content

Delete a tenant with the .NET SDK

permitClient.Api.DeleteTenant() deletes a tenant and all its related data from the environment that your API key belongs to. This reference is for .NET developers who manage tenants from backend code.

warning

DeleteTenant removes the tenant and all its related data in one call. The .NET SDK has no method to restore a deleted tenant.

DeleteTenant signature

public async Task DeleteTenant(string tenantKey)

DeleteTenant parameters

ParameterTypeRequiredDescription
tenantKeystringYesThe key of the tenant to delete. The tenant ID also works.

Example: delete a tenant with DeleteTenant

The example uses a client named permitClient, created with new Permit(...) as shown in Check permissions with the .NET SDK. tenantId holds the key or ID of the tenant. DeleteTenant returns a Task with no result:

await permitClient.Api.DeleteTenant(tenantId);

DeleteTenant return value and errors

DeleteTenant returns a Task that completes when the tenant is deleted. The task has no result value.

If the Permit API returns an error, DeleteTenant throws a PermitApiException. The exception's StatusCode property has the HTTP status, such as 404 when no tenant with that key or ID exists, and its Response property has the response body.