Delete a tenant with the Java SDK
permit.api.tenants.delete() deletes a tenant from your Permit environment. A tenant is an isolated group of users and resources, such as one customer organization in a multi-tenant application. This reference is for Java developers who manage tenants from code. The examples assume an initialized Permit client named permit, as set up in Check permissions with the Java SDK.
Signature
void delete(String tenantKey) throws IOException, PermitApiError, PermitContextError
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
tenantKey | String | Yes | The key or the ID (UUID) of the tenant. The Permit API accepts either value. |
Example
Replace [TENANT KEY OR ID] with the key or ID of the tenant to delete.
permit.api.tenants.delete("[TENANT KEY OR ID]");
Return value
delete() returns nothing (void).
Deleting a tenant also deletes all data related to the tenant, including the role assignments scoped to the tenant.
Exceptions
All exception classes except IOException are in the io.permit.sdk.api package.
| Exception | Thrown when |
|---|---|
IOException | The HTTP request to the Permit API fails, for example because of a network error. |
PermitApiError | The Permit API returns an error status code. getResponseCode() returns the HTTP status code and getRawResponse() returns the response body. |
PermitContextError | The SDK context does not include an environment, for example because the API key is scoped to an organization or project. |