Skip to content
Primary navigation

Update organization spend alert

OrganizationSpendAlert admin().organization().spendAlerts().update(SpendAlertUpdateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
POST/organization/spend_alerts/{alert_id}

Updates an organization spend alert.

ParametersExpand Collapse
SpendAlertUpdateParams params
Optional<String> alertId
Currency currency

The currency for the threshold amount.

USD("USD")
Interval interval

The time interval for evaluating spend against the threshold.

MONTH("month")
NotificationChannel notificationChannel

Email notification settings for a spend alert.

List<String> recipients

Email addresses that receive the spend alert notification.

JsonValue; type "email"constant"email"constant

The notification channel type. Currently only email is supported.

Optional<String> subjectPrefix

Optional subject prefix for alert emails.

long thresholdAmount

The alert threshold amount, in cents.

minimum0
ReturnsExpand Collapse
class OrganizationSpendAlert:

Represents a spend alert configured at the organization level.

String id

The identifier, which can be referenced in API endpoints.

Currency currency

The currency for the threshold amount.

Interval interval

The time interval for evaluating spend against the threshold.

NotificationChannel notificationChannel

Email notification settings for a spend alert.

List<String> recipients

Email addresses that receive the spend alert notification.

JsonValue; type "email"constant"email"constant

The notification channel type. Currently only email is supported.

Optional<String> subjectPrefix

Optional subject prefix for alert emails.

JsonValue; object_ "organization.spend_alert"constant"organization.spend_alert"constant

The object type, which is always organization.spend_alert.

long thresholdAmount

The alert threshold amount, in cents.

Update organization spend alert

package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.spendalerts.OrganizationSpendAlert;
import com.openai.models.admin.organization.spendalerts.SpendAlertUpdateParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        SpendAlertUpdateParams params = SpendAlertUpdateParams.builder()
            .alertId("alert_id")
            .currency(SpendAlertUpdateParams.Currency.USD)
            .interval(SpendAlertUpdateParams.Interval.MONTH)
            .notificationChannel(SpendAlertUpdateParams.NotificationChannel.builder()
                .addRecipient("string")
                .build())
            .thresholdAmount(0L)
            .build();
        OrganizationSpendAlert organizationSpendAlert = client.admin().organization().spendAlerts().update(params);
    }
}
{
    "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"
    }
}