budgets

Create or replace a notification rule

Changed on

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.
put/v1/ai-cost-management/budgets/{budgetId}/notification-rule

Request

  • Base URL
    https://global.api.konghq.com
  • Auth
    • HTTP bearer
    • or HTTP bearer
    • or HTTP bearer
    • or HTTP bearer

Path parameters

budgetId, string uuid required

The id of the budget.

Request body

object required
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.

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 [].

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.

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 {}.

Example request

{
  "managed_by": {
    "owner": "terraform"
  }
}

Response

The notification rule after the replacement.

AICostNotificationRule required
budget, AICostBudgetReference required

The budget the rule belongs to.

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.

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.

message, object nullable required

The wording of the rule's alerts, or null when the rule uses the built-in wording.

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.

Example response

{
  "managed_by": {
    "owner": "terraform"
  },
  "created_at": "2022-11-04T20:10:06.927Z",
  "updated_at": "2022-11-04T20:10:06.927Z"
}

Changes

    • info

      added the new optional request property managed_by

    • info

      added the required property managed_by to the response with the status

    • info

      added the required property managed_by to the response with the status