{"meta":{"title":"Budgets","intro":"Utilisez l’API REST pour obtenir des informations budgétaires.","product":"API REST","breadcrumbs":[{"href":"/fr/rest","title":"API REST"},{"href":"/fr/rest/billing","title":"Facturation"},{"href":"/fr/rest/billing/budgets","title":"Budgets"}],"documentType":"article"},"body":"# Budgets\n\nUtilisez l’API REST pour obtenir des informations budgétaires.\n\n> [!IMPORTANT]\n> Le schéma du corps de la requête ci-dessous ne contient pas de champ obligatoire. Lorsque `budget_scope` est `user`, vous devez également inclure un champ `user` défini sur le nom d’utilisateur GitHub auquel le budget s’applique. Si vous omettez ce champ, l’API retourne `HTTP 400: Missing required fields: budget_entity_name`. Pour les budgets délimités par l’utilisateur, `budget_entity_name` il peut s’agir d’une chaîne vide.\n\nL’exemple suivant crée un budget défini au niveau de l’utilisateur qui limite les CopilotAI credits d’un seul utilisateur à 30 USD par mois :\n\n```json\n{\n  \"budget_amount\": 30,\n  \"prevent_further_usage\": true,\n  \"budget_scope\": \"user\",\n  \"budget_entity_name\": \"\",\n  \"budget_type\": \"BundlePricing\",\n  \"budget_product_sku\": \"ai_credits\",\n  \"budget_alerting\": {\n    \"will_alert\": false,\n    \"alert_recipients\": []\n  },\n  \"user\": \"USERNAME\"\n}\n```\n\n> [!NOTE]\n> Most endpoints use `Authorization: Bearer <YOUR-TOKEN>` and `Accept: application/vnd.github+json` headers, plus `X-GitHub-Api-Version: 2026-03-10`. Curl examples below omit these standard headers for brevity.\n\n## Get all budgets for an organization\n\n```\nGET /organizations/{org}/settings/billing/budgets\n```\n\nGets all budgets for an organization. The authenticated user must be an organization admin or billing manager.\nEach page returns up to 100 budgets.\n\n### Parameters\n\n#### Headers\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n- **`org`** (string) (required)\n  The organization name. The name is not case sensitive.\n\n- **`page`** (integer)\n  The page number of the results to fetch.\n  Default: `1`\n\n- **`per_page`** (integer)\n  The number of results per page (max 100).\n  Default: `10`\n\n- **`scope`** (string)\n  Filter budgets by scope type.\n\norganization: Budgets scoped to the organization.\nrepository: Budgets scoped to a repository.\nmulti_user_customer: Universal budgets that apply to all users in the organization.\nuser: Budgets scoped to an individual user.\n  Can be one of: `enterprise`, `organization`, `repository`, `cost_center`, `multi_user_customer`, `user`\n\n- **`user`** (string)\n  Filter consumed amount details for budgets by the specified user login.\n\n### HTTP response status codes\n\n- **200** - Response when getting all budgets\n\n- **403** - Forbidden\n\n- **404** - Resource not found\n\n- **500** - Internal Error\n\n### Code examples\n\n#### Example 1: Status Code 200\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/organizations/ORG/settings/billing/budgets\n```\n\n**Response schema (Status: 200):**\n\n* `budgets`: required, array of objects:\n  * `id`: required, string\n  * `budget_type`: required, one of:\n    * **string, enum: `SkuPricing`**\n    * **string, enum: `ProductPricing`**\n  * `budget_amount`: required, integer\n  * `prevent_further_usage`: required, boolean\n  * `budget_scope`: required, string, enum: `enterprise`, `organization`, `repository`, `cost_center`, `multi_user_customer`, `multi_user_cost_center`, `user`\n  * `budget_entity_name`: string\n  * `user`: string\n  * `consumed_amount`: number\n  * `budget_product_sku`: required, string\n  * `budget_alerting`: required, object:\n    * `will_alert`: required, boolean\n    * `alert_recipients`: required, array of string\n  * `expires_at`: string, format: date\n* `user`: string\n* `effective_budget`: object:\n  * `id`: required, string\n  * `budget_amount`: required, integer\n  * `consumed_amount`: required, number\n* `has_next_page`: boolean\n* `total_count`: integer\n\n#### Example 2: Status Code 200\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/organizations/ORG/settings/billing/budgets\n```\n\n**Response schema (Status: 200):**\n\n* `budgets`: required, array of objects:\n  * `id`: required, string\n  * `budget_type`: required, one of:\n    * **string, enum: `SkuPricing`**\n    * **string, enum: `ProductPricing`**\n  * `budget_amount`: required, integer\n  * `prevent_further_usage`: required, boolean\n  * `budget_scope`: required, string, enum: `enterprise`, `organization`, `repository`, `cost_center`, `multi_user_customer`, `multi_user_cost_center`, `user`\n  * `budget_entity_name`: string\n  * `user`: string\n  * `consumed_amount`: number\n  * `budget_product_sku`: required, string\n  * `budget_alerting`: required, object:\n    * `will_alert`: required, boolean\n    * `alert_recipients`: required, array of string\n  * `expires_at`: string, format: date\n* `user`: string\n* `effective_budget`: object:\n  * `id`: required, string\n  * `budget_amount`: required, integer\n  * `consumed_amount`: required, number\n* `has_next_page`: boolean\n* `total_count`: integer\n\n## Create a budget for an organization\n\n```\nPOST /organizations/{org}/settings/billing/budgets\n```\n\nCreates a new budget for an organization. The authenticated user must be an\norganization admin or billing manager.\n\n### Parameters\n\n#### Headers\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n- **`org`** (string) (required)\n  The organization name. The name is not case sensitive.\n\n#### Body parameters\n\n- **`budget_amount`** (integer)\n  The budget amount in whole dollars. For license-based products, this represents the number of licenses.\n\n- **`prevent_further_usage`** (boolean)\n  Whether to prevent additional spending once the budget is exceeded. For user and multi_user_customer scopes, this must be true.\n\n- **`budget_alerting`** (object)\n  - **`will_alert`** (boolean)\n    Whether alerts are enabled for this budget. Rejected for user-scope as alerting is always disabled for them.\n  - **`alert_recipients`** (array of strings)\n    Array of user login names who will receive alerts. Rejected for user-scope as alerting is always disabled for them.\n\n- **`budget_scope`** (string)\n  The scope of the budget for this organization.\n\norganization: Apply the budget to the organization.\nrepository: Apply the budget to a specific repository in the organization.\nmulti_user_customer: Apply a universal budget to all users in the organization.\nuser: Apply the budget to a single user in the organization.\n\nuser and multi_user_customer scopes are only supported when\nbudget_product_sku is ai_credits or premium_requests.\n  Can be one of: `organization`, `repository`, `multi_user_customer`, `user`\n\n- **`budget_entity_name`** (string)\n  The name of the entity to apply the budget to\n  Default: ``\n\n- **`budget_type`** (string)\n  The type of pricing model used by the budget. Determines how budget_product_sku is interpreted.\n\nBundlePricing: Covers all AI credit SKUs. Set budget_product_sku to ai_credits.\nProductPricing: Covers all SKUs that belong to a product. Set budget_product_sku to a product such as actions or packages.\nSkuPricing: Covers a single, specific SKU. Set budget_product_sku to a SKU such as actions_linux.\n\n- **`budget_product_sku`** (string)\n  A single product or SKU that will be covered in the budget\n\n- **`user`** (string)\n  The username of the user for user scope budgets. This field is required when budget_scope is user.\n\n- **`expires_at`** (string)\n  The date the budget will expire in YYYY-MM-DD format. Only dates in the future are accepted.\nIf not provided, the budget will not expire.\nOnly supported for budgets with budget_scope of user\n\n### HTTP response status codes\n\n- **200** - Budget created successfully\n\n- **400** - Bad Request\n\n- **401** - Requires authentication\n\n- **403** - Insufficient permissions\n\n- **404** - Feature not enabled or organization not found\n\n- **422** - Validation failed, or the endpoint has been spammed.\n\n- **500** - Internal server error\n\n### Code examples\n\n#### Create organization budget example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X POST \\\n  https://api.github.com/organizations/ORG/settings/billing/budgets \\\n  -d '{\n  \"budget_amount\": 500,\n  \"prevent_further_usage\": true,\n  \"budget_scope\": \"organization\",\n  \"budget_entity_name\": \"\",\n  \"budget_type\": \"ProductPricing\",\n  \"budget_product_sku\": \"actions\",\n  \"budget_alerting\": {\n    \"will_alert\": false,\n    \"alert_recipients\": []\n  }\n}'\n```\n\n**Response schema (Status: 200):**\n\n* `message`: required, string\n* `budget`: required, object:\n  * `id`: string\n  * `budget_scope`: string, enum: `enterprise`, `organization`, `repository`, `cost_center`, `multi_user_customer`, `multi_user_cost_center`, `user`\n  * `budget_entity_name`: string\n  * `budget_amount`: integer, minimum: 0\n  * `prevent_further_usage`: boolean\n  * `budget_product_sku`: string\n  * `budget_type`: one of:\n    * **string, enum: `ProductPricing`**\n    * **string, enum: `SkuPricing`**\n  * `budget_alerting`: object:\n    * `will_alert`: boolean\n    * `alert_recipients`: array of string\n  * `expires_at`: string, format: date\n\n## Get a budget by ID for an organization\n\n```\nGET /organizations/{org}/settings/billing/budgets/{budget_id}\n```\n\nGets a budget by ID. The authenticated user must be an organization admin or billing manager.\n\n### Parameters\n\n#### Headers\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n- **`org`** (string) (required)\n  The organization name. The name is not case sensitive.\n\n- **`budget_id`** (string) (required)\n  The ID corresponding to the budget.\n\n### HTTP response status codes\n\n- **200** - Response when updating a budget\n\n- **400** - Bad Request\n\n- **403** - Forbidden\n\n- **404** - Resource not found\n\n- **500** - Internal Error\n\n- **503** - Service unavailable\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/organizations/ORG/settings/billing/budgets/BUDGET_ID\n```\n\n**Response schema (Status: 200):**\n\n* `id`: required, string\n* `budget_scope`: required, string, enum: `enterprise`, `organization`, `repository`, `cost_center`, `multi_user_customer`, `multi_user_cost_center`, `user`\n* `budget_entity_name`: required, string\n* `user`: string\n* `budget_amount`: required, integer\n* `prevent_further_usage`: required, boolean\n* `budget_product_sku`: required, string\n* `budget_type`: required, one of:\n  * **string, enum: `ProductPricing`**\n  * **string, enum: `SkuPricing`**\n* `budget_alerting`: required, object:\n  * `will_alert`: boolean\n  * `alert_recipients`: array of string\n\n## Update a budget for an organization\n\n```\nPATCH /organizations/{org}/settings/billing/budgets/{budget_id}\n```\n\nUpdates an existing budget for an organization. The authenticated user must be an organization admin or billing manager.\n\n### Parameters\n\n#### Headers\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n- **`org`** (string) (required)\n  The organization name. The name is not case sensitive.\n\n- **`budget_id`** (string) (required)\n  The ID corresponding to the budget.\n\n#### Body parameters\n\n- **`budget_amount`** (integer)\n  The budget amount in whole dollars. For license-based products, this represents the number of licenses.\n\n- **`prevent_further_usage`** (boolean)\n  Whether to prevent additional spending once the budget is exceeded. For budgets with user or multi_user_customer scope, this must remain true.\n\n- **`budget_alerting`** (object)\n  - **`will_alert`** (boolean)\n    Whether alerts are enabled for this budget. Ignored for user-scopes as alerting is always disabled for them.\n  - **`alert_recipients`** (array of strings)\n    Array of user login names who will receive alerts. Ignored for user-scopes as alerting is always disabled for them.\n\n- **`budget_scope`** (string)\n  The scope of the budget for this organization.\n\norganization: Apply the budget to the organization.\nrepository: Apply the budget to a specific repository in the organization.\nmulti_user_customer: Apply a universal budget to all users in the organization.\nuser: Apply the budget to a single user in the organization.\n  Can be one of: `enterprise`, `organization`, `repository`, `cost_center`, `multi_user_customer`, `user`\n\n- **`budget_entity_name`** (string)\n  The name of the entity to apply the budget to\n\n- **`budget_type`** (string)\n  The type of pricing model used by the budget. Determines how budget_product_sku is interpreted.\n\nBundlePricing: Covers all AI credit SKUs. Set budget_product_sku to ai_credits.\nProductPricing: Covers all SKUs that belong to a product. Set budget_product_sku to a product such as actions or packages.\nSkuPricing: Covers a single, specific SKU. Set budget_product_sku to a SKU such as actions_linux.\n\n- **`budget_product_sku`** (string)\n  A single product or SKU that will be covered in the budget\n\n- **`user`** (string)\n  The username of the user for user scope budgets.\n\n- **`expires_at`** (string or null or integer)\n  The date the budget will expire in YYYY-MM-DD format. Only dates in the future are accepted.\nIf not set, the budget will not expire. Setting to null or 0 will remove the expiration date from a budget if set.\nOnly supported for budgets with budget_scope of user\n\n### HTTP response status codes\n\n- **200** - Budget updated successfully\n\n- **400** - Bad Request\n\n- **401** - Requires authentication\n\n- **403** - Forbidden\n\n- **404** - Budget not found or feature not enabled\n\n- **422** - Validation failed, or the endpoint has been spammed.\n\n- **500** - Internal server error\n\n### Code examples\n\n#### Update budget example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X PATCH \\\n  https://api.github.com/organizations/ORG/settings/billing/budgets/BUDGET_ID \\\n  -d '{\n  \"prevent_further_usage\": false,\n  \"budget_amount\": 10,\n  \"budget_alerting\": {\n    \"will_alert\": false,\n    \"alert_recipients\": []\n  }\n}'\n```\n\n**Response schema (Status: 200):**\n\n* `message`: required, string\n* `budget`: required, object:\n  * `id`: string\n  * `budget_scope`: string, enum: `enterprise`, `organization`, `repository`, `cost_center`, `multi_user_customer`, `multi_user_cost_center`, `user`\n  * `budget_entity_name`: string\n  * `user`: string\n  * `consumed_amount`: number\n  * `budget_amount`: integer, minimum: 0\n  * `prevent_further_usage`: boolean\n  * `budget_product_sku`: string\n  * `budget_type`: one of:\n    * **string, enum: `ProductPricing`**\n    * **string, enum: `SkuPricing`**\n  * `budget_alerting`: object:\n    * `will_alert`: boolean\n    * `alert_recipients`: array of string\n  * `expires_at`: string, format: date\n\n## Delete a budget for an organization\n\n```\nDELETE /organizations/{org}/settings/billing/budgets/{budget_id}\n```\n\nDeletes a budget by ID for an organization. The authenticated user must be an organization admin or billing manager.\n\n### Parameters\n\n#### Headers\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n- **`org`** (string) (required)\n  The organization name. The name is not case sensitive.\n\n- **`budget_id`** (string) (required)\n  The ID corresponding to the budget.\n\n### HTTP response status codes\n\n- **200** - Response when deleting a budget\n\n- **400** - Bad Request\n\n- **403** - Forbidden\n\n- **404** - Resource not found\n\n- **500** - Internal Error\n\n- **503** - Service unavailable\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X DELETE \\\n  https://api.github.com/organizations/ORG/settings/billing/budgets/BUDGET_ID\n```\n\n**Response schema (Status: 200):**\n\n* `message`: required, string\n* `id`: required, string"}