POST/api/orgs/{org_id}/spend-alerts

支出アラートを作成する

org_monthly_spendは組織の当月の支出がthreshold_nano_usdに達するとメールを送ります。budget_fractionは予算が上限のthreshold_fractionに達するとメールを送ります。それぞれのkindは専用のフィールドだけを受け付けます。組織管理者またはプロビジョニングキーが必要です。

認証: AuthorizationヘッダーにBearer形式のAPIキー

パスパラメーター

  • org_idstring必須

    お客様の組織ID(uuid)。GET /api/whoamiで取得できます。

リクエストボディ

  • kindenum必須
    "org_monthly_spend""budget_fraction"
  • threshold_nano_usdinteger | null

    整数のnano-USD。

  • budget_idstring | null
  • threshold_fractionnumber | null

    予算の上限に対する割合。0.8は80%です。

  • notify_emailstring必須

レスポンス

  • 201

    アラート。

    レスポンス
    • alert_idstring必須
    • kindenum必須
      "org_monthly_spend""budget_fraction"
    • threshold_nano_usdinteger | null必須
    • budget_idstring | null必須
    • threshold_fractionnumber | null必須
    • notify_emailstring必須
    • created_atstring必須
    • last_eventobject | null必須
      いずれか

      object

      • periodstring必須

        YYYY-MM。

      • fired_atstring必須
      • measured_nano_usdinteger必須
      • threshold_nano_usdinteger必須
      • delivered_atstring | null必須
      • delivery_errorstring | null必須
  • 401

    APIキーがない、不明、または失効しています。

    レスポンス
    • errorstring必須

      人が読めるメッセージ。

    • codestring

      エンドポイントが定義している場合の、安定した機械可読の理由(例:pro_required)。

    • actionstring

      エンドポイントが定義している場合の、安定した対処アクション。

    • detailsobject

      呼び出し元が対処するために必要な、顧客に提示して安全な文字列情報(推奨される識別子など)。

  • 403

    キーがプロビジョニングキーではない(推論キーは読み取りを含めて拒否されます)か、顧客プランキーです。

    レスポンス
    • errorstring必須

      人が読めるメッセージ。

    • codestring

      エンドポイントが定義している場合の、安定した機械可読の理由(例:pro_required)。

    • actionstring

      エンドポイントが定義している場合の、安定した対処アクション。

    • detailsobject

      呼び出し元が対処するために必要な、顧客に提示して安全な文字列情報(推奨される識別子など)。

  • 404

    不明な組織または予算です。

    レスポンス
    • errorstring必須

      人が読めるメッセージ。

    • codestring

      エンドポイントが定義している場合の、安定した機械可読の理由(例:pro_required)。

    • actionstring

      エンドポイントが定義している場合の、安定した対処アクション。

    • detailsobject

      呼び出し元が対処するために必要な、顧客に提示して安全な文字列情報(推奨される識別子など)。

  • 409

    同一のアラートがすでにあります。

    レスポンス
    • errorstring必須

      人が読めるメッセージ。

    • codestring

      エンドポイントが定義している場合の、安定した機械可読の理由(例:pro_required)。

    • actionstring

      エンドポイントが定義している場合の、安定した対処アクション。

    • detailsobject

      呼び出し元が対処するために必要な、顧客に提示して安全な文字列情報(推奨される識別子など)。

  • 422

    kindに合わないフィールド、またはボディの検証に失敗しました。

リクエスト

curl -X POST 'https://api.experientiallabs.ai/api/orgs/3f6c2a1e-8b7d-4c2a-9e51-6a0d4b2f7c10/spend-alerts' \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
  "kind": "budget_fraction",
  "budget_id": "c4a2e8f1-7b3d-4e9a-8c15-3f0d6b2a9e71",
  "threshold_fraction": 0.8,
  "notify_email": "finance@acme.example"
}'

レスポンス

{
  "alert_id": "3c5e7a9c-1e3b-4d5f-8a0c-2e4a6c8e0b69",
  "kind": "budget_fraction",
  "threshold_nano_usd": null,
  "budget_id": "c4a2e8f1-7b3d-4e9a-8c15-3f0d6b2a9e71",
  "threshold_fraction": 0.8,
  "notify_email": "finance@acme.example",
  "created_at": "2026-11-22T16:10:03Z",
  "last_event": null
}

https://api.experientiallabs.ai/api/orgs/3f6c2a1e-8b7d-4c2a-9e51-6a0d4b2f7c10/spend-alerts