Create Alert Rule
create_alert_ruleCreate a cost-alert rule (POST /api/reports/cost-dashboard/alerts) — the same rule the Alerts page's form builds. Required: alert_name, alert_type, the threshold for that type, and at least one recipient. By type: trend → threshold_percent (fires when total spend rises ≥ that % vs the previous period); anomaly → threshold_percent + optional threshold_amount minimum impact (per-service spike vs a 4-window baseline); budget → threshold_amount in the org's currency (spend over the analysis period reaches it — standalone, NOT a create_budget budget); expiry → threshold_amount = days notice, whole 1-365: every commitment on the Commitments page with an end date (AWS RIs and Savings Plans; Azure reservations and savings plans when their end dates are available; not Google Cloud CUDs) ending within that many days, listed by commitment id and end date, each notified once (service / account / tag filters do not apply); tokens_per_request ("Tokens per Request Rise", OpenAI only) → threshold_percent (> 0; the Alerts form suggests 50): fires when the 7-day average input tokens per request (uncached + cached input tokens ÷ requests) of an OpenAI API key or model is more than that % above its prior 28-day average on 3 consecutive days. It runs daily only (frequency daily, analysis_period 7d_vs_28d — both the defaults), is evaluated per per (api_key, the default, or model), skips any key / model with fewer than min_requests requests in the 7 days (default 1000), and values limits it to given key ids or model names; it watches every OpenAI connection, or one OpenAI integration_id, and takes no services / accounts / tags. frequency is the evaluation cadence at 08:00 UTC (daily | weekly = Mondays | monthly = the 3rd; default weekly); analysis_period the window (defaults per type). Scope: omit integration_id for the whole organization across every provider, or pin one connection; services, accounts, tags narrow it (empty = everything). Cost center (budget and trend only): cost_center_id (list_cost_centers) measures the rule on that cost center — its allocation rules decide what counts, child cost centers included, and the figures match the Allocation page's cost-center breakdown for the same window; it is organization-wide and takes no integration_id, services, accounts or tags. Recipients: notification_channel_ids (list_notification_channels) and/or emails (up to 5). A rule with nowhere to deliver is refused. Validation errors come back from the backend verbatim — fix the field it names. Returns the created rule as list_alert_rules shows it. In the app any active member can create alert rules and manage the ones they created, contributors and admins manage every rule, viewers can attach saved channels but not ad-hoc emails, and the public demo organization is read-only; over MCP every write additionally needs the admin gate below. Alert rules need a paid plan. WRITE TOOL — MCP WRITES ARE OFF BY DEFAULT FOR EVERY ORGANIZATION. This call needs ALL FOUR of: the admin:write scope, the organization switch turned on (an org admin enables it in Settings → Organization → AI agent access), an admin or super_admin org role, and confirm:true. Missing any one of them it refuses and changes nothing, and the error names which one — relay that to the user rather than retrying. Read-only cak_ API keys can never perform it. Example: { "alert_name": "EC2 weekly spike", "alert_type": "trend", "threshold_percent": 20, "frequency": "daily", "services": ["AmazonEC2"], "notification_channel_ids": ["<channel_id>"], "confirm": true }; { "alert_name": "Prompt bloat", "alert_type": "tokens_per_request", "threshold_percent": 50, "per": "model", "emails": ["ml@example.com"], "confirm": true }.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"alert_name": "<alert_name>",
"alert_type": "<alert_type>"
},
"name": "create_alert_rule"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| per | No | tokens_per_request only: evaluate each OpenAI API key (api_key, the default) or each model (model) on its own. | |
| tags | No | Only resources carrying ALL of these tags, e.g. [{ "key": "env", "value": "prod" }]. One value per key. [] or omitted = no tag filter. | |
| emails | No | Up to 5 email addresses to notify directly, without a channel. For a longer list, create an email channel and attach its id. | |
| values | No | tokens_per_request only: limit the rule to these OpenAI API key ids (per api_key — get_ai_spend group_by "api_key" lists them) or model names (per model). Omit (or []) for every key / model. | |
| confirm | No | Set to true to actually perform this write. Required: the tool refuses the mutation unless confirm:true is present. Authorization for the change itself is your org role, checked server-side. | |
| accounts | No | Only these sub-accounts — AWS linked accounts, Azure subscriptions, GCP projects — as raw ids (get_available_linked_accounts). [] or omitted = all accounts. | |
| services | No | Only these provider services (e.g. ["AmazonEC2"]; get_available_services lists them). [] or omitted = all services. | |
| frequency | No | How often the rule is evaluated, at 08:00 UTC: daily (every day) | weekly (Mondays) | monthly (the 3rd). Default weekly; tokens_per_request must be (and defaults to) daily. | |
| alert_name | Yes | Display name for the rule (1-200 characters). Required. | |
| alert_type | Yes | trend = total spend for the scope rose by ≥ threshold_percent vs the previous period; anomaly = per-service scan, each service vs its own baseline (average of the 4 prior windows), flagged when it rises ≥ threshold_percent AND the increase is ≥ threshold_amount (minimum impact, default 50); budget = total spend for the analysis period reached threshold_amount (a standalone spend threshold — NOT linked to budgets from create_budget); expiry = a commitment on the Commitments page in the rule's provider and connection scope (AWS Reserved Instances and Savings Plans; Azure reservations and savings plans when their end dates are available; never Google Cloud CUDs, which have no end date in Google's billing export) expires within threshold_amount days, day N included; each commitment notifies once, and services / accounts / tags do not apply; tokens_per_request = OpenAI only: the 7-day average input tokens per request (uncached + cached input tokens ÷ requests) of each OpenAI API key or model rose more than threshold_percent above its prior 28-day average on 3 consecutive days, counting only keys / models with at least min_requests requests in the 7 days (daily frequency only). | |
| min_requests | No | tokens_per_request only: a key or model needs at least this many requests in the 7-day window before it can fire (default 1000), so low-volume keys do not trip it. | |
| cost_center_id | No | budget (Spend Threshold) and trend (Trend Spike) only: measure the rule on this cost center (cost center id from list_cost_centers). Its allocation rules decide what counts, child cost centers included, so the figures match get_allocation_breakdown / the Allocation page for the same window. A cost-center rule is organization-wide: it takes no integration_id, services, accounts or tags. A cost center an alert rule uses cannot be deleted. | |
| integration_id | No | Evaluate only this provider connection's spend (integration id from list_integrations). Omit for the whole organization — combined spend across every connected provider. tokens_per_request: an OpenAI integration only; omit for every OpenAI connection. Not allowed with cost_center_id. | |
| analysis_period | No | The spend window evaluated, in whole UTC days of settled cost data: the last day counted is the day before yesterday for AWS, Azure and GCP and yesterday for Snowflake, OpenAI and Anthropic (an organization-wide rule follows the slowest provider it has recent data from). trend/anomaly compare it with the window before: daily (day over day) | weekly (7 days) | monthly (30 days). budget sums spend over last_24h (one day) | last_7d | last_30d | current_month (month to date; on a monthly-frequency rule, the last full calendar month). tokens_per_request takes only 7d_vs_28d (the last 7 days vs the 28 days before). Other type/period pairs are refused. expiry ignores it. Defaults: trend/anomaly weekly, budget current_month, expiry last_30d, tokens_per_request 7d_vs_28d. | |
| threshold_amount | No | budget: the spend amount (org display currency) that fires the rule, > 0. expiry: days of notice, a whole number 1-365. anomaly: optional minimum impact — the smallest increase worth flagging (default 50). Ignored by trend and tokens_per_request. | |
| threshold_percent | No | trend, anomaly and tokens_per_request: the % rise that fires the rule (must be > 0; required). For tokens_per_request the Alerts form suggests 50. Ignored by budget/expiry. | |
| notification_channel_ids | No | Ids of the organization's notification channels (any number, any type — email, Slack, Teams) to notify, from list_notification_channels. |