Daily budget monitoring template
Set a daily spending cap and get alerts as your agents approach it. This template covers the rule configuration and the alert integration.
Step 1: Set the daily cap
# Daily total cap — blocks after $2,000 in a calendar day (UTC)
curl -X POST https://sipi.bot/api/rules \
-H "Authorization: Bearer $ADMIN_TOKEN" \
-H "Content-Type: application/json" \
-d '{"rule_type":"daily_total","params":{"max_amount":2000},"action":"BLOCKED","label":"daily-cap"}'
Step 2: Add threshold alerts
# Warning at 50% of daily budget
curl -X POST https://sipi.bot/api/rules \
-H "Authorization: Bearer $ADMIN_TOKEN" \
-d '{"rule_type":"daily_total","params":{"max_amount":1000},"action":"FLAGGED","label":"daily-50pct-warning"}'
# Warning at 80% of daily budget
curl -X POST https://sipi.bot/api/rules \
-H "Authorization: Bearer $ADMIN_TOKEN" \
-d '{"rule_type":"daily_total","params":{"max_amount":1600},"action":"FLAGGED","label":"daily-80pct-warning"}'
Step 3: Integrate alerts
Poll the SSE stream at /v1/activity or call /api/stats periodically. When the daily total crosses your thresholds, trigger a notification:
# In your monitoring script (Python)
import requests, json
stats = requests.get("https://sipi.bot/api/stats").json()
spent_today = stats["spent_today"]
daily_cap = 2000
if spent_today >= daily_cap * 0.5:
send_slack_alert(f"⚠️ Agent spending at {spent_today/daily_cap:.0%} of daily ${daily_cap} cap")
if spent_today >= daily_cap * 0.8:
send_pagerduty_alert(f"🚨 Agent spending at {spent_today/daily_cap:.0%} — approaching daily cap")
if spent_today >= daily_cap:
send_incident_alert(f"🔴 Daily cap reached. All further agent spending is BLOCKED.")
Frequently asked
Is the daily cap per agent or across all agents?
The daily_total rule applies to the entire sipi.bot instance — all agents share the cap. For per-agent limits, create separate API keys and instances, or use the per_transaction rule on a per-agent basis.
When does the daily cap reset?
At midnight UTC. The daily total is tracked in the SQLite database and resets when the calendar day changes.
Can I set different caps for different categories?
Yes. Use the category_limit rule type to set per-category daily caps (e.g., $500/day for compute, $200/day for ads). Combine with the global daily_total for an overall cap.