Skip to content
Primary navigation

Update organization spend alert

admin.organization.spend_alerts.update(alert_id, **kwargs) -> OrganizationSpendAlert { id, currency, interval, 3 more }
POST/organization/spend_alerts/{alert_id}

Updates an organization spend alert.

ParametersExpand Collapse
alert_id: String
currency: :USD

The currency for the threshold amount.

interval: :month

The time interval for evaluating spend against the threshold.

notification_channel: NotificationChannel{ recipients, type, subject_prefix}

Email notification settings for a spend alert.

recipients: Array[String]

Email addresses that receive the spend alert notification.

type: :email

The notification channel type. Currently only email is supported.

subject_prefix: String

Optional subject prefix for alert emails.

threshold_amount: Integer

The alert threshold amount, in cents.

minimum0
ReturnsExpand Collapse
class OrganizationSpendAlert { id, currency, interval, 3 more }

Represents a spend alert configured at the organization level.

id: String

The identifier, which can be referenced in API endpoints.

currency: :USD

The currency for the threshold amount.

interval: :month

The time interval for evaluating spend against the threshold.

notification_channel: NotificationChannel{ recipients, type, subject_prefix}

Email notification settings for a spend alert.

recipients: Array[String]

Email addresses that receive the spend alert notification.

type: :email

The notification channel type. Currently only email is supported.

subject_prefix: String

Optional subject prefix for alert emails.

object: :"organization.spend_alert"

The object type, which is always organization.spend_alert.

threshold_amount: Integer

The alert threshold amount, in cents.

Update organization spend alert

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

organization_spend_alert = openai.admin.organization.spend_alerts.update(
  "alert_id",
  currency: :USD,
  interval: :month,
  notification_channel: {recipients: ["string"], type: :email},
  threshold_amount: 0
)

puts(organization_spend_alert)
{
    "id": "alert_abc123",
    "object": "organization.spend_alert",
    "threshold_amount": 150000,
    "currency": "USD",
    "interval": "month",
    "notification_channel": {
        "type": "email",
        "recipients": ["finance@example.com"],
        "subject_prefix": "OpenAI spend alert"
    }
}
Returns Examples
{
    "id": "alert_abc123",
    "object": "organization.spend_alert",
    "threshold_amount": 150000,
    "currency": "USD",
    "interval": "month",
    "notification_channel": {
        "type": "email",
        "recipients": ["finance@example.com"],
        "subject_prefix": "OpenAI spend alert"
    }
}