Integrations
Queues and background jobs
Authorize asynchronous work at execution time, with retries and decision freshness.
When an agent enqueues work, time passes before it runs: permissions may be revoked, delegations may expire and policies may change.
Authorize in the worker
Authorize when the job executes, not only when it is enqueued.
TypeScript
worker.process("send_invoice", async (job) => {
const { request, invoiceId } = job.data; // request built when enqueued, from trusted data
try {
await reqlo.enforce(request);
} catch (e) {
if (e instanceof ReqloDeniedError) return job.discard("denied"); // don't retry denials
throw e; // errors: let the queue retry later
}
await invoices.send(invoiceId);
});Rules
- Denials are final. Don't retry a denied job; record it.
- Errors are retryable. Let the queue retry with backoff, and never send on error.
- Rebuild attributes from authoritative data at execution time if they can change.
- Idempotent side effects. Use your own idempotency key so a retried job doesn't send twice.
- Approvals. For
approval_required, store the request and approval ID, and run the job only after redeeming.
Something wrong or unclear? Report an issue with this page.