Skip to main content
Skip to content
REST API 现已开始进行版本化。 有关详细信息,请参阅“关于 API 版本控制”。

Budgets

使用 REST API 获取预算信息。

重要

下面的请求正文架构缺少必填字段。 当 budget_scope 为 user 时,还必须包含一个 user 字段,并将其设置为该预算适用的 GitHub 用户名。 如果省略此字段,API 将 HTTP 400: Missing required fields: budget_entity_name返回 。 对于用户作用域预算,budget_entity_name 可以为空字符串。

以下示例创建一个用户范围的预算,该预算将单个用户的每月 CopilotAI credits 限制为 30 美元:

{
  "budget_amount": 30,
  "prevent_further_usage": true,
  "budget_scope": "user",
  "budget_entity_name": "",
  "budget_type": "BundlePricing",
  "budget_product_sku": "ai_credits",
  "budget_alerting": {
    "will_alert": false,
    "alert_recipients": []
  },
  "user": "USERNAME"
}

Get all budgets

Gets budgets for an enterprise. Enterprise owners and billing managers can view all budgets, and organization administrators can view budgets scoped to organizations and repositories they administer. A custom role holder with fine-grained read access to enterprise billing can view non-repository budgets; repository-scoped budgets require the organization administrator permissions described above. An installation access token for a GitHub App installed on the enterprise with read access to enterprise billing can list all budgets in the enterprise. Each page returns up to 100 budgets.

“Get all budgets”的细粒度访问令牌

此端点支持以下精细令牌类型:

细粒度令牌必须具有以下权限集: