Java SDK
Enforce ReQlo decisions from Java 11+ (and Kotlin), with approvals, delegations and webhook verification. No dependencies.
The Java SDK is server-side, supports Java 11+ and has no dependencies, so it never conflicts with your JSON or
HTTP libraries. A Reqlo client is thread-safe: create one and share it.
<dependency>
<groupId>io.reqlo</groupId>
<artifactId>reqlo-java</artifactId>
<version>0.1.0</version>
</dependency>Enforce before acting
enforce returns only on allow. Deny and approval required throw ReqloDeniedException; timeouts, network
failures and HTTP errors throw other ReqloExceptions. All are unchecked, so nothing is swallowed by accident.
import io.reqlo.*;
public final class DocumentTool {
private static final Reqlo REQLO = Reqlo.builder().apiKey(System.getenv("REQLO_API_KEY")).build();
public String read(Session session, String documentId) {
Document doc = documents.get(documentId); // authoritative facts from your database
AuthorizeRequest request = AuthorizeRequest.builder()
.agent("<YOUR_AGENT_ID>")
.subject(session.userId(), "user") // from your verified session
.action("documents.read")
.resource("document", doc.id())
.resourceAttribute("owner_id", doc.ownerId())
.context("document_classification", doc.classification())
.build();
try {
REQLO.enforce(request);
} catch (ReqloDeniedException denied) {
throw new ForbiddenException(denied.decision().reasonCode());
}
// Any other ReqloException propagates: the document is not read.
return doc.content();
}
}authorize(request) returns the Decision without throwing on deny. Act only when decision.isAllowed().
Approvals and delegations
Decision held = reqlo.authorize(request);
if (held.isApprovalRequired()) saveForLater(request, held.approval().id()); // redeem with .approvalId(...) once approved
Approval approval = reqlo.approvals().retrieve(approvalId);
List<Approval> pending = reqlo.approvals().list("pending");
Delegation grant = reqlo.delegations().create("<YOUR_AGENT_ID>", "usr_94", "user",
List.of("calendar.schedule"), "2026-12-31T00:00:00Z");
reqlo.delegations().list(null, "usr_94");
reqlo.delegations().revoke(grant.id());Webhooks
byte[] body = request.getInputStream().readAllBytes();
Map<?, ?> event;
try {
event = Webhooks.constructEvent(body, request.getHeader("Reqlo-Signature"), System.getenv("REQLO_WEBHOOK_SECRET"));
} catch (ReqloSignatureException e) {
response.setStatus(400);
return;
}
if ("approval.requested".equals(event.get("type"))) notifyApprovers(event);
response.setStatus(204);Configuration
Reqlo reqlo = Reqlo.builder()
.apiKey(System.getenv("REQLO_API_KEY"))
.timeout(Duration.ofSeconds(3)) // per attempt
.maxRetries(2) // 429 and 5xx only, with backoff
.build();Timeouts and network errors are never retried, and delegations().create is never retried, because a request that
timed out may have reached ReQlo.
Errors
| Exception | When |
|---|---|
ReqloDeniedException | enforce got deny or approval required. .decision() has the reason. |
ReqloApiException | HTTP error. .status(), .code() and .requestId(). |
ReqloTimeoutException, ReqloNetworkException | No answer. |
ReqloResponseException | A malformed response. Never permission to act. |
ReqloConfigurationException | Invalid options or arguments. |
ReqloSignatureException | A webhook signature is missing, invalid or too old. |
All extend ReqloException, an unchecked exception.
Something wrong or unclear? Report an issue with this page.