Skip to main content

Delete a resource with the Java SDK

permit.api.resources.delete() deletes a resource type from your Permit environment. This reference is for Java developers who manage their authorization schema 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 resourceKey) throws IOException, PermitApiError, PermitContextError

Parameters

ParameterTypeRequiredDescription
resourceKeyStringYesThe key or the ID (UUID) of the resource. The Permit API accepts either value.

Example

Replace [RESOURCE KEY OR ID] with the key or ID of the resource to delete.

permit.api.resources.delete("[RESOURCE KEY OR ID]");

Return value

delete() returns nothing (void).

warning

Deleting a resource also deletes all data related to the resource, including its actions and attributes. Policies lose the permissions defined on the deleted resource.

Exceptions

All exception classes except IOException are in the io.permit.sdk.api package.

ExceptionThrown when
IOExceptionThe HTTP request to the Permit API fails, for example because of a network error.
PermitApiErrorThe Permit API returns an error status code. getResponseCode() returns the HTTP status code and getRawResponse() returns the response body.
PermitContextErrorThe SDK context does not include an environment, for example because the API key is scoped to an organization or project.