预算
使用 REST API 获取预算信息。
获取组织的所有预算
注意
此端点处于公开预览阶段,可能会更改。
获取组织的所有预算。认证用户必须是组织管理员或计费管理员。每页最多返回 10 条预算。
针对“获取组织的所有预算”的细粒度访问令牌
此端点支持以下细粒度令牌类型:
细粒度令牌必须具备以下权限集
- 组织的 “Administration” 权限(读取)
“获取组织的所有预算”的参数
| 名称, 类型, 描述 |
|---|
accept string建议设置为 |
| 名称, 类型, 描述 |
|---|
org string 必需组织名称。该名称不区分大小写。 |
| 名称, 类型, 描述 |
|---|
page integer要获取的结果页码。 默认值: |
per_page integer每页的结果数量(最大 10)。 默认: |
scope 字符串按范围类型过滤预算。 可以是以下之一: |
“获取组织的所有预算”的 HTTP 响应状态码
| 状态码 | 描述 |
|---|---|
200 | 获取所有预算时的响应 |
403 | 禁止 (Forbidden) |
404 | 未找到资源 |
500 | 内部错误 |
“获取组织的所有预算”的代码示例
请求示例
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/organizations/ORG/settings/billing/budgets获取所有预算时的响应
状态: 200{ "budgets": [ { "id": "2066deda-923f-43f9-88d2-62395a28c0cdd", "budget_type": "ProductPricing", "budget_product_skus": [ "actions" ], "budget_scope": "enterprise", "budget_amount": 1000, "prevent_further_usage": true, "budget_alerting": { "will_alert": true, "alert_recipients": [ "enterprise-admin", "billing-manager" ] } }, { "id": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "budget_type": "SkuPricing", "budget_product_skus": [ "actions_linux" ], "budget_scope": "organization", "budget_amount": 500, "prevent_further_usage": false, "budget_alerting": { "will_alert": true, "alert_recipients": [ "org-owner" ] } }, { "id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "budget_type": "ProductPricing", "budget_product_skus": [ "packages" ], "budget_scope": "cost_center", "budget_amount": 250, "prevent_further_usage": true, "budget_alerting": { "will_alert": false, "alert_recipients": [] } } ], "has_next_page": false, "total_count": 3 }按 ID 获取组织的预算
注意
此端点处于公开预览阶段,可能会更改。
按 ID 获取预算。认证用户必须是组织管理员或计费管理员。
针对“按 ID 获取组织的预算”的细粒度访问令牌
此端点支持以下细粒度令牌类型:
细粒度令牌必须具备以下权限集
- 组织的 “Administration” 权限(读取)
“按 ID 获取组织的预算”的参数
| 名称, 类型, 描述 |
|---|
accept string建议设置为 |
| 名称, 类型, 描述 |
|---|
org string 必需组织名称。该名称不区分大小写。 |
budget_id string 必填对应预算的 ID。 |
“按 ID 获取组织的预算”的 HTTP 响应状态码
| 状态码 | 描述 |
|---|---|
200 | 更新预算时的响应 |
400 | 错误的请求 |
403 | 禁止 (Forbidden) |
404 | 未找到资源 |
500 | 内部错误 |
503 | 服务不可用 |
“按 ID 获取组织的预算”的代码示例
请求示例
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/organizations/ORG/settings/billing/budgets/BUDGET_ID更新预算时的响应
状态: 200{ "id": "2066deda-923f-43f9-88d2-62395a28c0cdd", "budget_type": "ProductPricing", "budget_product_sku": "actions_linux", "budget_scope": "repository", "budget_entity_name": "example-repo-name", "budget_amount": 0, "prevent_further_usage": true, "budget_alerting": { "will_alert": true, "alert_recipients": [ "mona", "lisa" ] } }更新组织的预算
注意
此端点处于公开预览阶段,可能会更改。
更新组织中已有的预算。认证用户必须是组织管理员或计费管理员。
针对“更新组织的预算”的细粒度访问令牌
此端点支持以下细粒度令牌类型:
细粒度令牌必须具备以下权限集
- 组织的 “Administration” 权限(写入)
“更新组织的预算”的参数
| 名称, 类型, 描述 |
|---|
accept string建议设置为 |
| 名称, 类型, 描述 |
|---|
org string 必需组织名称。该名称不区分大小写。 |
budget_id string 必填对应预算的 ID。 |
| 名称, 类型, 描述 | |||
|---|---|---|---|
budget_amount integer预算金额(整数美元)。对于基于许可证的产品,这代表许可证的数量。 | |||
prevent_further_usage boolean预算超出后是否阻止进一步支出 | |||
budget_alerting object | |||
|
| 名称, 类型, 描述 |
|---|
will_alert boolean是否为此预算启用警报 |
alert_recipients array of strings将收到警报的用户登录名数组 |
budget_scope string预算的范围
可以是以下之一: enterprise, organization, repository, cost_center
budget_entity_name string要将预算应用于的实体名称
budget_type string预算的定价类型
budget_product_sku string预算中将覆盖的单个产品或 SKU
“更新组织的预算”的 HTTP 响应状态码
| 状态码 | 描述 |
|---|---|
200 | 预算更新成功 |
400 | 错误的请求 |
401 | 需要身份验证 |
403 | 禁止 (Forbidden) |
404 | 未找到预算或未启用此功能 |
422 | 验证失败,或端点已被滥用。 |
500 | 内部服务器错误 |
“更新组织的预算”的代码示例
请求示例
curl -L \ -X PATCH \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/organizations/ORG/settings/billing/budgets/BUDGET_ID \ -d '{"prevent_further_usage":false,"budget_amount":10,"budget_alerting":{"will_alert":false,"alert_recipients":[]}}'预算更新成功
状态: 200{ "message": "Budget successfully updated.", "budget": { "id": "2066deda-923f-43f9-88d2-62395a28c0cdd", "budget_type": "ProductPricing", "budget_product_sku": "actions_linux", "budget_scope": "repository", "budget_entity_name": "org-name/example-repo-name", "budget_amount": 0, "prevent_further_usage": true, "budget_alerting": { "will_alert": true, "alert_recipients": [ "mona", "lisa" ] } } }删除组织的预算
注意
此端点处于公开预览阶段,可能会更改。
按 ID 删除组织的预算。认证用户必须是组织管理员或计费管理员。
针对“删除组织的预算”的细粒度访问令牌
此端点支持以下细粒度令牌类型:
细粒度令牌必须具备以下权限集
- 组织的 “Administration” 权限(写入)
“删除组织的预算”的参数
| 名称, 类型, 描述 |
|---|
accept string建议设置为 |
| 名称, 类型, 描述 |
|---|
org string 必需组织名称。该名称不区分大小写。 |
budget_id string 必填对应预算的 ID。 |
“删除组织的预算”的 HTTP 响应状态码
| 状态码 | 描述 |
|---|---|
200 | 删除预算时的响应 |
400 | 错误的请求 |
403 | 禁止 (Forbidden) |
404 | 未找到资源 |
500 | 内部错误 |
503 | 服务不可用 |
“删除组织的预算”的代码示例
请求示例
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/organizations/ORG/settings/billing/budgets/BUDGET_ID删除预算时的响应
状态: 200{ "message": "Budget successfully deleted.", "budget_id": "2c1feb79-3947-4dc8-a16e-80cbd732cc0b" }