Skip to main content

Delete a role with the Java SDK

permit.api.roles.delete() deletes a role from your Permit environment. This reference is for Java developers who manage role-based access control (RBAC) roles 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 roleKey) throws IOException, PermitApiError, PermitContextError

Parameters

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

Example

Replace [ROLE KEY OR ID] with the key or ID of the role to delete.

permit.api.roles.delete("[ROLE KEY OR ID]");

Return value

delete() returns nothing (void).

warning

Deleting a role also deletes the data related to the role, including the permissions granted to the role. Users who had only this role lose the access that the role granted.

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.