Skip to content
For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
Primary navigation
Theme

List organization spend alerts

client.Admin.Organization.SpendAlerts.List(ctx, query) (*ConversationCursorPage[OrganizationSpendAlert], error)
GET
/organization/spend_alerts

Lists organization spend alerts.

List organization spend alerts

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  page, err := client.Admin.Organization.SpendAlerts.List(context.TODO(), openai.AdminOrganizationSpendAlertListParams{

  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}
Response example
{
    "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
}
Parameters
query AdminOrganizationSpendAlertListParams
After param.Field[string]
Optional

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

Before param.Field[string]
Optional

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

Limit param.Field[int64]
Optional

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

minimum0
maximum100

Sort order for the returned spend alerts.

Returns
type OrganizationSpendAlert struct{…}

Represents a spend alert configured at the organization level.

ID string

The identifier, which can be referenced in API endpoints.

Currency OrganizationSpendAlertCurrency

The currency for the threshold amount.

Interval OrganizationSpendAlertInterval

The time interval for evaluating spend against the threshold.

NotificationChannel OrganizationSpendAlertNotificationChannel

Email notification settings for a spend alert.

Object OrganizationSpendAlert

The object type, which is always organization.spend_alert.

ThresholdAmount int64

The alert threshold amount, in cents.

Returns Examples
Response example
{
    "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
}