Skip to content
Primary navigation

Update organization spend alert

admin.organization.spend_alerts.update(stralert_id, SpendAlertUpdateParams**kwargs) -> OrganizationSpendAlert
POST/organization/spend_alerts/{alert_id}

Updates an organization spend alert.

ParametersExpand Collapse
alert_id: str
currency: Literal["USD"]

The currency for the threshold amount.

interval: Literal["month"]

The time interval for evaluating spend against the threshold.

notification_channel: NotificationChannel

Email notification settings for a spend alert.

recipients: Sequence[str]

Email addresses that receive the spend alert notification.

type: Literal["email"]

The notification channel type. Currently only email is supported.

subject_prefix: Optional[str]

Optional subject prefix for alert emails.

threshold_amount: int

The alert threshold amount, in cents.

minimum0
ReturnsExpand Collapse
class OrganizationSpendAlert: …

Represents a spend alert configured at the organization level.

id: str

The identifier, which can be referenced in API endpoints.

currency: Literal["USD"]

The currency for the threshold amount.

interval: Literal["month"]

The time interval for evaluating spend against the threshold.

notification_channel: NotificationChannel

Email notification settings for a spend alert.

recipients: List[str]

Email addresses that receive the spend alert notification.

type: Literal["email"]

The notification channel type. Currently only email is supported.

subject_prefix: Optional[str]

Optional subject prefix for alert emails.

object: Literal["organization.spend_alert"]

The object type, which is always organization.spend_alert.

threshold_amount: int

The alert threshold amount, in cents.

Update organization spend alert

import os
from openai import OpenAI

client = OpenAI(
    admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"),  # This is the default and can be omitted
)
organization_spend_alert = client.admin.organization.spend_alerts.update(
    alert_id="alert_id",
    currency="USD",
    interval="month",
    notification_channel={
        "recipients": ["string"],
        "type": "email",
    },
    threshold_amount=0,
)
print(organization_spend_alert.id)
{
    "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"
    }
}