Skip to content
Primary navigation

List organization spend alerts

client.admin.organization.spendAlerts.list(SpendAlertListParams { after, before, limit, order } query?, RequestOptionsoptions?): ConversationCursorPage<OrganizationSpendAlert { id, currency, interval, 3 more } >
GET/organization/spend_alerts

Lists organization spend alerts.

ParametersExpand Collapse
query: SpendAlertListParams { after, before, limit, order }
after?: string

Cursor for pagination. Provide the ID of the last spend alert from the previous response to fetch the next page.

before?: string

Cursor for pagination. Provide the ID of the first spend alert from the previous response to fetch the previous page.

limit?: number

A limit on the number of spend alerts to return. Defaults to 20.

minimum0
maximum100
order?: "asc" | "desc"

Sort order for the returned spend alerts.

One of the following:
"asc"
"desc"
ReturnsExpand Collapse
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 | null

Optional subject prefix for alert emails.

object: "organization.spend_alert"

The object type, which is always organization.spend_alert.

threshold_amount: number

The alert threshold amount, in cents.

List organization spend alerts

import OpenAI from 'openai';

const client = new OpenAI({
  adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted
});

// Automatically fetches more pages as needed.
for await (const organizationSpendAlert of client.admin.organization.spendAlerts.list()) {
  console.log(organizationSpendAlert.id);
}
{
    "object": "list",
    "data": [
        {
            "id": "alert_abc123",
            "object": "organization.spend_alert",
            "threshold_amount": 100000,
            "currency": "USD",
            "interval": "month",
            "notification_channel": {
                "type": "email",
                "recipients": ["finance@example.com"],
                "subject_prefix": "OpenAI spend alert"
            }
        }
    ],
    "first_id": "alert_abc123",
    "last_id": "alert_abc123",
    "has_more": false
}
Returns Examples
{
    "object": "list",
    "data": [
        {
            "id": "alert_abc123",
            "object": "organization.spend_alert",
            "threshold_amount": 100000,
            "currency": "USD",
            "interval": "month",
            "notification_channel": {
                "type": "email",
                "recipients": ["finance@example.com"],
                "subject_prefix": "OpenAI spend alert"
            }
        }
    ],
    "first_id": "alert_abc123",
    "last_id": "alert_abc123",
    "has_more": false
}