Skip to content
Primary navigation

Retrieve organization spend alert

client.Admin.Organization.SpendAlerts.Get(ctx, alertID) (*OrganizationSpendAlert, error)
GET/organization/spend_alerts/{alert_id}

Retrieves an organization spend alert.

ParametersExpand Collapse
alertID string
ReturnsExpand Collapse
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.

Recipients []string

Email addresses that receive the spend alert notification.

Type Email

The notification channel type. Currently only email is supported.

SubjectPrefix stringOptional

Optional subject prefix for alert emails.

Object OrganizationSpendAlert

The object type, which is always organization.spend_alert.

ThresholdAmount int64

The alert threshold amount, in cents.

Retrieve organization spend alert

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"),
  )
  organizationSpendAlert, err := client.Admin.Organization.SpendAlerts.Get(context.TODO(), "alert_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", organizationSpendAlert.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"
    }
}