Quickstart
Make your first sandbox authorization decision with a generic documents.read action.
In this quickstart you register a documents.read action, publish a policy, and ask ReQlo whether an assistant
agent may read a document for a user. You will see one allow and one deny, then wire the check into code
so a denied action never runs.
The existing examples below use the published TypeScript SDK 0.3.0 API (authorize and enforce), or the other
language SDKs. The repository also contains TypeScript SDK 0.4.0, which has not been published. Its new
protect, execute, resume and approvals.wait helpers require a local build and archive installation; see
Protect a function with the checkout SDK.
The policy tester described below is implemented in this checkout. Deploy the updated dashboard and API before expecting it on a hosted installation. Configure your integration through Agents, Actions & resources, Policies and API keys.
Time: about 10 minutes. You need: a ReQlo account and one of Node.js 20.18+, Python 3.10+, Go 1.21+ or Java 11+. Everything below uses your Sandbox environment.
Create a sandbox API key
In the dashboard, open API keys, make sure Sandbox is selected in the header, and select Create API key. You confirm your password first. One key works for every agent in the project, so you only do this once. Copy it straight away (it's shown once) and keep it on your server. Never put it in browser code or commit it.
export REQLO_API_KEY="rq_test_..."Add your agent
Open Agents, select Add agent, name it Document assistant and select Create agent. On the agent's page,
copy its Agent ID (it starts with agt_). The examples below show it as <YOUR_AGENT_ID>.
This doesn't connect or install anything. The agent ID is a name your policies refer to, so different agents can have different permissions with the same API key. See How ReQlo fits.
Register the resource type and action
ReQlo rejects actions it doesn't know, so a typo never silently becomes an allow. Open Actions & resources:
- Select Register resource type. Name it
documentand add an attributeowner_idof type id, marked required. Select Register resource type. - Select Register action. Name it
documents.read, choose thedocumentresource type, and add a context attributedocument_classificationof type enum, required, with the valuespublic,internalandconfidential. Select Register action.
Create and publish a policy
This policy lets your agent read documents the user owns, and never confidential ones. Documents are one example; policies can control any registered action and resource. The optional dashboard templates cover several workflows and use your own catalog. A custom policy remains the default.
Open Policies and select Create policy. Name it Document access, switch the editor to JSON, paste the rules below with your agent ID, and select Create draft.
[
{
"id": "allow-own-documents",
"effect": "allow",
"actions": ["documents.read"],
"agents": { "ids": ["<YOUR_AGENT_ID>"] },
"subjects": { "kinds": ["user"] },
"condition": "resource.attributes.owner_id == subject.id"
},
{
"id": "deny-confidential",
"effect": "deny",
"actions": ["documents.*"],
"condition": "context.document_classification == \"confidential\""
}
]Drafts never affect runtime decisions. In the updated dashboard, open Policies → Test a decision and choose Draft: Document access. Paste this request with your agent ID:
{
"agent": { "id": "<YOUR_AGENT_ID>" },
"subject": { "id": "usr_94", "kind": "user" },
"action": "documents.read",
"resource": { "type": "document", "id": "doc_831", "attributes": { "owner_id": "usr_94" } },
"context": { "document_classification": "internal" }
}Select Test decision. Expect Allowed. Change owner_id to usr_12 and expect Denied. Restore the owner,
then change classification to confidential and expect Denied with the matching deny rule shown.
The selected draft replaces that policy's published rules only for the preview; other published policies still apply. Use an isolated Sandbox project for predictable example outcomes. A preview never executes a tool, records a runtime decision, creates an approval or consumes one. Delegations and approval IDs require the runtime API.
Back on Policies, select Manage on Document access, then Publish. New runtime decisions use it within seconds. Publishing needs an owner or admin. An allowed preview never replaces the authorization check in your code.
Install the SDK
npm install @reqlo/sdk@0.3.0Ask for a decision
The user usr_94 owns doc_831, an internal document, so this is allowed. In real code, subject.id comes from
your verified session and owner_id from your database, never from the model.
import { Reqlo } from "@reqlo/sdk";
const reqlo = new Reqlo({ apiKey: process.env.REQLO_API_KEY! });
const decision = await reqlo.authorize({
agent: { id: "<YOUR_AGENT_ID>" },
subject: { id: "usr_94", kind: "user" },
action: "documents.read",
resource: { type: "document", id: "doc_831", attributes: { owner_id: "usr_94" } },
context: { document_classification: "internal" },
});
console.log(decision.decision, decision.reason_code); // "allow" "policy_allowed"Now change owner_id to usr_12, or the classification to confidential, and run it again. The decision is
deny, with reason no_matching_policy or policy_denied. Every check appears under Observability.
Enforce it on the real execution path
A decision only protects you if your code acts on it. enforce returns only on allow; a deny throws
ReqloDeniedError, and API errors or timeouts throw too, so nothing runs by accident.
import { Reqlo, ReqloDeniedError } from "@reqlo/sdk";
const reqlo = new Reqlo({ apiKey: process.env.REQLO_API_KEY! });
async function readDocumentTool(session: Session, documentId: string) {
const doc = await db.documents.find(documentId); // authoritative facts
try {
await reqlo.enforce({
agent: { id: "<YOUR_AGENT_ID>" },
subject: { id: session.userId, kind: "user" }, // from your verified session
action: "documents.read",
resource: { type: "document", id: doc.id, attributes: { owner_id: doc.ownerId } },
context: { document_classification: doc.classification },
});
} catch (err) {
if (err instanceof ReqloDeniedError) return { error: "Not allowed to read this document." };
throw err; // errors and timeouts: do not read the document
}
return { content: doc.content };
}The same pattern in Python, Go and
Java: enforce only lets your code continue on an explicit allow.
Protect a function with the checkout SDK 0.4.0
This optional workflow uses the unpublished repository version, not the registry installation above. From the repository root, build and pack it:
npm run build --workspace=@reqlo/sdk
npm pack --workspace=@reqlo/sdk --pack-destination /tmpIn your application's directory, install the resulting archive:
npm install /tmp/reqlo-sdk-0.4.0.tgzWrap the tool once, then call run. This self-contained example simulates execution using the policy you created:
import { Reqlo } from "@reqlo/sdk";
const reqlo = new Reqlo({
apiKey: process.env.REQLO_API_KEY!,
baseUrl: process.env.REQLO_API_URL ?? "http://127.0.0.1:8080/v1",
});
const readDocument = reqlo.protect({
request: (args: { documentId: string; ownerId: string; classification: string; userId: string }) => ({
agent: { id: "<YOUR_AGENT_ID>" },
subject: { id: args.userId, kind: "user" },
action: "documents.read",
resource: { type: "document", id: args.documentId, attributes: { owner_id: args.ownerId } },
context: { document_classification: args.classification },
}),
execute: async (args) => ({ simulated: true, documentId: args.documentId }),
});
// In your application, load these facts from your database and verified session.
const result = await readDocument.run({
documentId: "doc_831",
ownerId: "usr_94",
classification: "internal",
userId: "usr_94",
});
console.log(result.status); // executed; a denial returns denied without running the toolprotect snapshots JSON arguments and binds their complete digest to the authorization request. Its callback runs
only on allow. A rule requiring human review returns pending without executing; see
Human approvals for durable storage and resumption. API errors, invalid responses and
timeouts stop execution by throwing. Tool callbacks are not retried.
Run the updated API locally using your project's API configuration. The checkout example defaults to port 8080;
adjust REQLO_API_URL if yours differs, or point it at a hosted API after deploying the changes. The repository's
examples/support-agent includes runnable allow, deny and approval
cases with simulated refunds, plus a signed webhook listener. Its README explains configuration through the existing
dashboard sections. Use Node.js 22.22+ for that example.
What you built
- A registered action and resource type, so malformed requests are rejected.
- A published policy with an allow rule and a deny rule. Deny always wins.
- An enforcement point that only reads the document after an explicit allow.
Next steps
- Write your first policy in a file and test it before publishing.
- Human approvals: hold risky actions for a person to approve.
- Tool-call enforcement: put the check inside every agent tool.
Something wrong or unclear? Report an issue with this page.