create_alert
Create a saved Costory cost monitor that evaluates queries and sends notifications when its condition fires. Use when the user requests ongoing monitoring. Creation configures future delivery rather than sending an immediate notification. New alerts are creator-only (you get Admin). To share, call set_object_permissions with resourceKind "costAlert". The advertised series schema is compact to reduce tool size. Use the full series schema in query.queries; the same series validation applies and no separate query call is required. Accepts the same query config as query (datePreset for preset ranges; hand-computed from/to only for custom ranges). scopeId is the same id as list_teams. It is stored on the alert and is not merged into the query filters. Omit it for no scope. The firing rule is a single condition boolean expression over the query names, e.g. a > 1000, rollingSum(a, 7, DAY) > 50000, or (a - timeShift(a, 1, DAY)) / timeShift(a, 1, DAY) > 0.2. For today vs the previous complete calendar month daily average, use (a - lastMonthAvg(a)) / abs(lastMonthAvg(a)) > 0.1. Window math (rollingSum/weekToDateSum/monthToDateSum/lastWeekSum/lastWeekAvg/lastMonthSum/lastMonthAvg/timeShift) is evaluated daily in BigQuery, so you do NOT pick an evaluation period — instead set dedup to control re-notification frequency (CALENDAR once per WEEK/MONTH, or ROLLING once every N days). The period (datePreset or from/to) defines the preview/look-back window for the underlying queries. Use list_available_destinations for SLACK/TEAMS channel IDs. Optional tagIds: existing IDs from list_tags and/or { name, color? } for new tags; color defaults to #6366F1; missing tags are created. Omit and [] both leave the alert untagged. Optional messageWidgets: the alert's message content — exactly one ALERT widget (the notification body) plus optional TEXT / GRAPH_SNAPSHOT / TOP_FLOP / DASHBOARD_PDF widgets in delivery order; omit for the default single ALERT widget. Query-backed widgets may omit queries to inherit the alert's first source cost query. Returns a URL that you MUST include in your response so the user can view/edit the alert.
Effects: Saves a monitoring workflow that enables future irreversible notifications. Before creating it, show the monitored data scope, firing condition, notification frequency, and all recipients; obtain the user's explicit confirmation. Scope: Notifications reach other people through a Slack channel, a Teams channel, or an email address the caller specifies, including an address outside the organization.
EXAMPLE: "Alert me on Slack if our production AWS spend exceeds $50k over any 7 days, at most once a week" → { name: "Prod AWS weekly alert", queries: [{ type: "cost", name: "a", metricId: "cost", currency: "USD", filterCel: "cos_provider in ["AWS"] && cos_environment in ["prod"]" }], datePreset: "TRAILING_90_DAYS", condition: "rollingSum(a, 7, DAY) > 50000", dedup: { kind: "CALENDAR", calendarUnit: "WEEK" }, notificationChannel: "SLACK", slackChannelId: "C01ABC" }
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": {
"queries": "<queries>",
"name": "<name>",
"condition": "<condition>",
"dedup": "<dedup>",
"notificationChannel": "<notificationChannel>"
},
"name": "create_alert"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | No | Explicit window end (inclusive, YYYY-MM-DD). Use with from instead of datePreset. | |
| from | No | Explicit window start (YYYY-MM-DD). Use with to instead of datePreset. | |
| name | Yes | Display name for the alert. | |
| slug | No | Organization slug. Omit to auto-detect from your account (fails if you belong to multiple orgs). | |
| aggBy | No | Time grain for the series: Hour, Day, Week, Month, or Period (default Month). | Month |
| dedup | Yes | Deduplication config controlling how often a still-firing group notifies. The window is per groupBy value; delivery stays one message listing newly eligible groups. Either CALENDAR (kind: CALENDAR, calendarUnit: WEEK | MONTH) = at most once per current ISO week / calendar month, or ROLLING (kind: ROLLING, windowDays: N) = at most once every N days. | |
| limit | No | Max groups/rows per series. Omit to use the default (100). Increase up to 1000 when you need more than 100 breakdown groups. | |
| scout | No | Scout persona NAME (from list_scouts) or its id, assigned to dynamic explanations. Omitted = no scout. Setting this does not require DIGEST display "summary" or enableAiInvestigation — do not ask the user for a digest explanation. | |
| emails | No | Email addresses (required if EMAIL) | |
| tagIds | No | `list_tags` id or `{ name, color? }` (created if missing, default #6366F1). Omit and [] leave it untagged. | |
| compare | No | Add a comparison period to show cost evolution side-by-side. Omit `from`/`to` to compare against the preceding period automatically; set `chartType` to choose how it renders. | |
| context | No | Optional context used only for analytics; it does not affect tool execution. Omit it by default. Do not include conversation text, personal information, or workspace data. | |
| queries | Yes | The advertised series items are compact to reduce tool size. Use the full series schema in `query.queries`; the server validates each series against it, and no separate query call is required. | |
| scopeId | No | Team scope id (list_teams). Stored on the alert, not merged into query filters. Omit for no scope. | |
| condition | Yes | Alerts v3 firing rule: a single boolean expression over the query names (`name` field of each query). Supports arithmetic (+ - * /), comparisons (> >= < <= == !=), logical and/or/not, parentheses, and these window functions: rollingSum(a, N, UNIT) (trailing sum over the last N units, UNIT ∈ DAY|WEEK|MONTH where MONTH is a 30-day window, not a calendar month, inclusive of today), weekToDateSum(a) (Monday-to-date), monthToDateSum(a) (1st-of-month-to-date), lastWeekSum(a)/lastMonthSum(a) (previous complete calendar period totals), lastWeekAvg(a)/lastMonthAvg(a) (period sum divided by 7 or the actual 28–31 calendar days, including zero-spend days), and timeShift(a, N, UNIT) (value shifted back N units; UNIT ∈ DAY|WEEK only — MONTH and YEAR are not supported; use timeShift(a, 30, DAY) as a 30-day approximation; may wrap a window function). Examples: `a > 1000`, `(a - lastMonthAvg(a)) / abs(lastMonthAvg(a)) > 0.1`, `rollingSum(a, 7, DAY) > 1000`, `(a - timeShift(a, 1, DAY)) / timeShift(a, 1, DAY) > 0.2`, `a > 10000 or rollingSum(a, 7, DAY) > 50000`. | |
| llm_model | No | The model identifier you are running as, for example "claude-opus-4-8" or "gpt-5.2". Pass "unknown" if you are not certain. Recorded for the server developer's analytics. | |
| datePreset | No | Official date preset (same as Explore, e.g. MTD, LAST_MONTH). Forecast: CURRENT_MONTH / CURRENT_QUARTER / CURRENT_YEAR. Mutually exclusive with from/to. | |
| messageWidgets | No | Replaces the alert's message-widget list wholesale (alert body plus optional TEXT / GRAPH_SNAPSHOT / TOP_FLOP / DASHBOARD_PDF extras). Omit to leave the stored list unchanged. Exactly one ALERT widget is required; DIGEST is not supported on alerts. Read the current list via `get` and echo each entry's `config` back verbatim for widgets you are not changing (the prose `parameters` summary is truncated and not writable). | |
| slackChannelId | No | Slack target id (required if SLACK): a channel id (C…) to post to a channel, or a Slack user id (U…) to deliver a direct message to that user. Use list_available_destinations to discover both channels and the signed-in user's DM. | |
| teamsChannelId | No | Teams channel ID (required if TEAMS) | |
| conversation_id | No | The conversation_id this server returned earlier in this conversation, unchanged, including after later user messages. Omit it if you have none. Recorded for the server developer's analytics. | |
| notificationChannel | Yes | Notification channel |