Overview
Notification rules let you set up alerts when agents exceed usage thresholds. You can monitor token consumption or costs over different time periods and choose to receive notifications, block requests, or both.List Notification Rules
Retrieve all notification rules for a specific agent, including their trigger history.Query Parameters
Name of the agent to retrieve rules for
Response Fields
Unique identifier for the rule
Name of the agent this rule monitors
Type of metric to monitor. Either
tokens or costThreshold value that triggers the alert. For tokens, this is the total token count. For cost, this is USD.
Time window for threshold calculation. One of:
hour, day, week, monthAction to take when threshold is exceeded. One of:
notify- Send email notification onlyblock- Block agent requests until threshold resetsboth- Send notification and block requests
Whether the rule is currently active
Number of times this rule has been triggered
ISO 8601 timestamp of rule creation
ISO 8601 timestamp of last update
Example Request
Example Response
Create Notification Rule
Create a new notification rule for an agent.Request Body
Name of the agent to monitor. Must be an existing agent in your workspace.
Type of metric to monitor:
tokens- Monitor total token usage (input + output)cost- Monitor cost in USD
Threshold value that triggers the alert. Must be greater than or equal to 1.
- For
tokens: Total token count - For
cost: USD amount (e.g., 10.5 for $10.50)
Time window for threshold calculation:
hour- Rolling 60-minute windowday- Rolling 24-hour windowweek- Rolling 7-day windowmonth- Rolling 30-day window
Action to take when threshold is exceeded:
notify- Send email notificationblock- Block agent API requestsboth- Send notification and block requests
Example Request
Example Response
Update Notification Rule
Update an existing notification rule. All fields are optional.Path Parameters
The unique identifier of the rule to update
Request Body
Change the metric type. Either
tokens or cost.Update the threshold value. Must be greater than or equal to 1.
Change the time window:
hour, day, week, or monthEnable or disable the rule without deleting it
Change the action:
notify, block, or bothExample Request
Example Response
Delete Notification Rule
Permanently delete a notification rule.Path Parameters
The unique identifier of the rule to delete
Example Request
Example Response
How Thresholds Work
Rolling Windows
All time periods use rolling windows, not calendar boundaries:- Hour: Usage in the last 60 minutes from now
- Day: Usage in the last 24 hours from now
- Week: Usage in the last 7 days from now
- Month: Usage in the last 30 days from now
Threshold Checking
Rules are evaluated every 5 minutes by a background cron job. When usage exceeds the threshold:- Notify action: An email is sent to the configured notification email address
- Block action: Subsequent OTLP requests from the agent are rejected with a 429 status
- Both action: Email is sent and requests are blocked
Cost Calculation
Cost thresholds use the model pricing data configured in your workspace. Costs are calculated as:model_pricing table.
Use Cases
Development Safety Net
Prevent runaway costs during development:Production Monitoring
Get notified about unusual spikes without blocking production:Budget Enforcement
Hard cap on monthly spending:Notes
- You must configure an email provider before creating rules with
notifyorbothactions - Rules are tenant-scoped — you can only create rules for agents you own
- Deleting an agent also deletes all its notification rules
- The
trigger_countfield tracks historical triggers and never decreases - Blocked requests return HTTP 429 with a descriptive error message