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
| Parameter | Type | Required | Description |
|---|---|---|---|
roleKey | String | Yes | The 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.
| 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. |