Budget Policies
Configure per-call, per-hour, and per-day spending limits.
Budget policies define spending limits and constraints. Sentinel evaluates every payment against the policy before it settles.
Preset Policies
import {
conservativePolicy,
standardPolicy,
liberalPolicy,
unlimitedPolicy,
customPolicy,
} from "@valeo/x402";| Preset | Per Call | Per Hour | Per Day | Use Case |
|---|---|---|---|---|
conservativePolicy() | $0.10 | $5.00 | $50.00 | Low-risk, testing |
standardPolicy() | $1.00 | $25.00 | $200.00 | Typical production |
liberalPolicy() | $10.00 | $100.00 | $1,000.00 | High-throughput, trusted |
unlimitedPolicy() | — | — | — | Audit only, no limits |
Custom Policy
Override any defaults with customPolicy:
const policy = customPolicy({
maxPerCall: "5.00",
maxPerHour: "50.00",
maxPerDay: "500.00",
maxTotal: "10000.00",
spikeThreshold: 5.0,
allowedEndpoints: ["https://api.trusted.com/*"],
blockedEndpoints: ["https://*.competitors.com/*"],
requireApproval: {
above: "50.00",
handler: async (ctx) => await askSlackForApproval(ctx),
},
});BudgetPolicy Fields
| Field | Type | Description |
|---|---|---|
maxPerCall | string | Max USDC per single payment (e.g., "1.00") |
maxPerHour | string | Hourly rolling cap |
maxPerDay | string | Daily rolling cap |
maxTotal | string | Lifetime total cap |
spikeThreshold | number | Flag if payment > N× rolling average (default 3.0) |
allowedEndpoints | string[] | URL patterns allowed (whitelist) |
blockedEndpoints | string[] | URL patterns blocked (blacklist) |
requireApproval | object | Human approval above threshold |
Endpoint patterns use glob-style matching. https://api.*.com/* matches https://api.weather.com/v1/current.