Policies
Creating and managing budget policies in the dashboard.
Budget policies are configured in code via wrapWithSentinel. The dashboard does not edit policies — it surfaces the effects of policies (violations, blocked payments, anomalies).
Policy Effects in the Dashboard
| Dashboard Feature | Policy Connection |
|---|---|
getAlerts() | Violations = blocked payments; Anomalies = spike/flagged |
violations() | Records with policy_evaluation: "blocked" |
anomalies() | Records flagged by spike detection or custom logic |
policy_evaluation on records | "allowed" | "flagged" | "blocked" |
Viewing Violations
const alerts = await dashboard.getAlerts();
const violationAlerts = alerts.filter((a) => a.type === "violation");
import { violations } from "@valeo/x402/dashboard";
const blockedRecords = await violations(storage, "last_day");Each violation has a BudgetViolation with type, limit, current, attempted, agentId, endpoint, timestamp.
Policy Configuration
Policies are set in code. See Budget Policies for the full reference. The dashboard cannot change them — use wrapWithSentinel config and redeploy.
Budget Remaining
Each successful payment record includes budget_remaining — the remaining budget in the relevant window after that payment.
const records = await logger.query({
agentId: "agent-1",
limit: 1,
orderBy: "created_at",
order: "desc",
});
const lastRecord = records[0];
console.log("Budget remaining:", lastRecord.budget_remaining);