---
title: "Create or replace a notification rule"
method: PUT
path: "/v1/ai-cost-management/budgets/{budgetId}/notification-rule"
tags: ["budgets"]
---

# Create or replace a notification rule

`PUT /v1/ai-cost-management/budgets/{budgetId}/notification-rule`

## Request

- Base URL: `https://global.api.konghq.com`
- URL: `https://global.api.konghq.com/v1/ai-cost-management/budgets/{budgetId}/notification-rule`
- Auth: one of:
  - HTTP bearer
  - HTTP bearer
  - HTTP bearer
  - HTTP bearer

Creates a limit budget's notification rule, or replaces its `thresholds`, `channels`, and `message`, and returns the rule. The response status is `201` when the request creates the rule and `200` when it replaces one.

- The service evaluates the rule at once, so a threshold that spend in the current budget window has already reached fires right away. A threshold already recorded for this budget window, derived budget, and limit doesn't fire again. The evaluation runs after the rule is stored, so if it fails, retrying the same request completes it.
- Omitting `message` or sending `null` restores the built-in wording. An omitted `managed_by` resets to `{}`.
- Removing a threshold or channel keeps the firings and deliveries already recorded, and pending deliveries are still sent.
- If a listed channel doesn't exist in the organization, the request fails with `400`, and `invalid_parameters` names `channels[i].id` with the rule `missing_reference`.
- If `message` has an unknown placeholder or a `{{` without a closing `}}`, the request fails with `400`. It fails the same way when `message` uses `{{entity.field}}` or `{{entity.value}}` on a budget without `each`.
- If the budget is an exemption, the request fails with `400`. If the organization has no budget with this identifier that the caller can see, or the identifier isn't a valid UUID, the request fails with `404`.

## Path parameters

- `budgetId` string, uuid, required

## Request body

- object
  - `thresholds` AICostNotificationThreshold[], required: The shares of the limit at which the rule fires. Each threshold fires at most once per budget window, derived budget, and limit, and changing the limit lets the thresholds fire again. 1 to 10 thresholds, each with a different `percent`.
    - `percent` integer, required: The share of the limit, as a whole percent. A value above 100 fires on spend beyond the limit. 1 to 1000.
  - `channels` object[]: The channels that receive the rule's alerts. At most 10 channels, each listed once. Reads return them ordered by channel name. Defaults to `[]`.
    - `id` string, uuid, required: The identifier of one of the organization's notification channels.
  - `message` object, nullable: The wording of the rule's alerts on every channel, or `null` for the built-in wording. `subject` and `body` can contain placeholders, such as `{{budget.name}}`. A placeholder is `{{`, optional whitespace, a name from the list below, optional whitespace, and `}}`. There's no escaping, and a lone `}}` is text. Each alert fills the placeholders with its own values. Amounts appear in US dollars, such as `$4,125.50`. - `{{budget.name}}`: the budget's name. - `{{budget.url}}`: a link to the budget in Konnect. - `{{threshold}}`: the threshold that was crossed, such as `80%`. - `{{limit}}`: the limit that spend is measured against. With `each`, the limit of one derived budget. - `{{spend}}`: the spend so far in the budget window. - `{{percent}}`: the spend as a share of the limit, such as `82.51%`. - `{{remaining}}`: what is left of the limit, never below `$0.00`. - `{{projected}}`: where spend ends the budget window at the current pace, as an amount and a share of the limit. - `{{period}}`: the budget window, in the time zone of its anchor. - `{{period.start}}`: when the budget window started. - `{{period.end}}`: when the budget window ends and the budget resets. - `{{period.remaining}}`: how long is left in the budget window when the alert is sent, in its largest whole unit, such as `8 days` or `12 minutes`. Under a minute, it's `less than a minute`, and after the window ends, `no time`. - `{{entity.field}}`: the `each` field as a noun, such as `group`, `user` for `subject`, or `env tag` for `tags.env`. - `{{entity.value}}`: the value whose derived budget crossed the threshold. A Kong Identity principal or a consumer shows as its display name when the service can resolve it. Any other value, such as a Kong Identity group or team, shows as it is. `{{entity.field}}` and `{{entity.value}}` work only on a budget with `each`. Defaults to `null`.
    - `subject` string, required: The subject line of the rule's alerts, as plain text that can contain placeholders such as `{{budget.name}}`. A single line of 1 to 200 characters after the server removes leading and trailing whitespace.
    - `body` string, required: The text of the rule's alerts, as plain text that can contain placeholders such as `{{budget.name}}`. Blank lines separate paragraphs. 1 to 2000 characters after the server removes leading and trailing whitespace.
  - `managed_by` ManagedBy: Identifies the tool that manages this resource, such as `{"tool": "terraform-provider-konnect"}`. The service stores the value and never acts on it. An omitted value on replacement resets to `{}`.

## Response `200`

The notification rule after the replacement.

- AICostNotificationRule
  - `budget` AICostBudgetReference, required: The budget the rule belongs to.
    - `id` string, uuid, required: The `id` of the budget, which the budget operations take as `budgetId`.
  - `thresholds` AICostNotificationThreshold[], required: The shares of the limit at which the rule fires. Each threshold fires at most once per budget window, derived budget, and limit, and changing the limit lets the thresholds fire again. Ordered by `percent`, lowest first.
    - `percent` integer, required: The share of the limit, as a whole percent. A value above 100 fires on spend beyond the limit. 1 to 1000.
  - `channels` object[], required: The channels that receive the rule's alerts. At most 10 channels, each listed once. Reads return them ordered by channel name.
    - `id` string, uuid, required: The identifier of one of the organization's notification channels.
  - `message` object, nullable, required: The wording of the rule's alerts, or `null` when the rule uses the built-in wording.
    - `subject` string, required: The subject line of the rule's alerts, as plain text that can contain placeholders such as `{{budget.name}}`.
    - `body` string, required: The text of the rule's alerts, as plain text that can contain placeholders such as `{{budget.name}}`. Blank lines separate paragraphs.
  - `managed_by` ManagedBy, required: Identifies the tool that manages this resource, such as `{"tool": "terraform-provider-konnect"}`. The service stores the value and never acts on it.
  - `created_at` string, date-time, required: An ISO-8601 timestamp representation of entity creation date.
  - `updated_at` string, date-time, required: An ISO-8601 timestamp representation of entity update date.

## Other responses

- `201`: The created notification rule.
- `400`: The request body is invalid. `invalid_parameters` names each invalid field, such as a listed channel that doesn't exist. An exemption also fails with this status, with `invalid_parameters` naming `budgetId`.
- `401`: The request has no valid access token. The token is missing, malformed, or expired, or it fails another check, and the response doesn't say which.
- `403`: The access token is valid, but its principal lacks the permission this operation requires. For an operation on one resource, the response doesn't reveal whether that resource exists.
- `404`: The organization has no budget with this identifier that the caller can see.

## Changes

- **2026-11-20** `757a21fb79f2`: 3 info
  - added the new optional request property `managed_by`
  - added the required property `managed_by` to the response with the `200` status
  - added the required property `managed_by` to the response with the `201` status
- **2026-11-05** `f018071a4515`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/kong/apis/konnect-api/changes/v1/ai-cost-management/budgets/:budgetId/notification-rule/put.md)

---

[API](https://skmtc.dev/kong/apis/konnect-api.md) - [All operations](https://skmtc.dev/kong/apis/konnect-api/llms.txt) - [OpenAPI document](https://skmtc.dev/kong/apis/konnect-api/revisions/5da43f6209ea?raw)
