{"meta":{"title":"Points de terminaison d’API REST pour les environnements de déploiement","intro":"Utilisez l’API REST pour créer, configurer et supprimer des environnements de déploiement.","product":"API REST","breadcrumbs":[{"href":"/fr/rest","title":"API REST"},{"href":"/fr/rest/deployments","title":"Déploiements"},{"href":"/fr/rest/deployments/environments","title":"Environnements"}],"documentType":"article"},"body":"# Points de terminaison d’API REST pour les environnements de déploiement\n\nUtilisez l’API REST pour créer, configurer et supprimer des environnements de déploiement.\n\n## À propos des environnements de déploiement\n\nPour plus d’informations sur les environnements, consultez [Gestion des environnements pour le déploiement](/fr/actions/deployment/targeting-different-environments/using-environments-for-deployment). Pour gérer les secrets d’environnement, consultez [Points d'accès d’API REST pour les secrets GitHub Actions](/fr/rest/actions/secrets).\n\nLes environnements, les secrets d’environnement et les règles de protection de déploiement sont disponibles dans les référentiels publics pour tous les plans actuels GitHub . Ils ne sont pas disponibles dans des anciens forfaits, tels que Bronze, Argent ou Or. Pour accéder aux environnements, aux secrets d’environnement et aux branches de déploiement dans des référentiels privés ou internes, vous devez utiliser GitHub Pro, GitHub Teamou GitHub Enterprise.\nSi vous êtes sur un plan GitHub Free, GitHub Pro, ou GitHub Team, d’autres règles de protection de déploiement, telles qu’un compte à rebours ou des approbateurs requis, sont uniquement disponibles pour les dépôts publics.\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## List environments\n\n```\nGET /repos/{owner}/{repo}/environments\n```\n\nLists the environments for a repository.\nAnyone with read access to the repository can use this endpoint.\nOAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with a private repository.\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* **`owner`** (string) (required)\n  The account owner of the repository. The name is not case sensitive.\n\n* **`repo`** (string) (required)\n  The name of the repository without the .git extension. The name is not case sensitive.\n\n* **`per_page`** (integer)\n  The number of results per page (max 100). For more information, see \"Using pagination in the REST API.\"\n  Default: `30`\n\n* **`page`** (integer)\n  The page number of the results to fetch. For more information, see \"Using pagination in the REST API.\"\n  Default: `1`\n\n### HTTP response status codes\n\n* **200** - OK\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/repos/OWNER/REPO/environments\n```\n\n**Response schema (Status: 200):**\n\n* `total_count`: integer\n* `environments`: array of `Environment`:\n  * `id`: required, integer, format: int64\n  * `node_id`: required, string\n  * `name`: required, string\n  * `url`: required, string\n  * `html_url`: required, string\n  * `created_at`: required, string, format: date-time\n  * `updated_at`: required, string, format: date-time\n  * `protection_rules`: array of object\n  * `deployment_branch_policy`: object or null:\n    * `protected_branches`: required, boolean\n    * `custom_branch_policies`: required, boolean\n\n## Get an environment\n\n```\nGET /repos/{owner}/{repo}/environments/{environment_name}\n```\n\nNote\n\nTo get information about name patterns that branches must match in order to deploy to this environment, see \"Get a deployment branch policy.\"\n\nAnyone with read access to the repository can use this endpoint.\nOAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with a private repository.\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* **`owner`** (string) (required)\n  The account owner of the repository. The name is not case sensitive.\n\n* **`repo`** (string) (required)\n  The name of the repository without the .git extension. The name is not case sensitive.\n\n* **`environment_name`** (string) (required)\n  The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.\n\n### HTTP response status codes\n\n* **200** - OK\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/repos/OWNER/REPO/environments/ENVIRONMENT_NAME\n```\n\n**Response schema (Status: 200):**\n\n* `id`: required, integer, format: int64\n* `node_id`: required, string\n* `name`: required, string\n* `url`: required, string\n* `html_url`: required, string\n* `created_at`: required, string, format: date-time\n* `updated_at`: required, string, format: date-time\n* `protection_rules`: array of object\n* `deployment_branch_policy`: object or null:\n  * `protected_branches`: required, boolean\n  * `custom_branch_policies`: required, boolean\n\n## Create or update an environment\n\n```\nPUT /repos/{owner}/{repo}/environments/{environment_name}\n```\n\nCreate or update an environment with protection rules, such as required reviewers. For more information about environment protection rules, see \"Environments.\"\nNote\n\nTo create or update name patterns that branches must match in order to deploy to this environment, see \"Deployment branch policies.\"\n\nNote\n\nTo create or update secrets for an environment, see \"GitHub Actions secrets.\"\n\nOAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.\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* **`owner`** (string) (required)\n  The account owner of the repository. The name is not case sensitive.\n\n* **`repo`** (string) (required)\n  The name of the repository without the .git extension. The name is not case sensitive.\n\n* **`environment_name`** (string) (required)\n  The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.\n\n#### Body parameters\n\n* **`wait_timer`** (integer)\n  The amount of time to delay a job after the job is initially triggered. The time (in minutes) must be an integer between 0 and 43,200 (30 days).\n\n* **`prevent_self_review`** (boolean)\n  Whether or not a user who created the job is prevented from approving their own job.\n\n* **`reviewers`** (array of objects or null)\n  The people or teams that may review jobs that reference the environment. You can list up to six users or teams as reviewers. The reviewers must have at least read access to the repository. Only one of the required reviewers needs to approve the job for it to proceed.\n  * **`type`** (string)\n    The type of reviewer.\n    Can be one of: `User`, `Team`\n  * **`id`** (integer)\n    The id of the user or team who can review the deployment\n\n* **`deployment_branch_policy`** (object or null)\n  The type of deployment branch policy for this environment. To allow all branches to deploy, set to null.\n  * **`protected_branches`** (boolean) (required)\n    Whether only branches with branch protection rules can deploy to this environment. If protected\\_branches is true, custom\\_branch\\_policies must be false; if protected\\_branches is false, custom\\_branch\\_policies must be true.\n  * **`custom_branch_policies`** (boolean) (required)\n    Whether only branches that match the specified name patterns can deploy to this environment.  If custom\\_branch\\_policies is true, protected\\_branches must be false; if custom\\_branch\\_policies is false, protected\\_branches must be true.\n\n### HTTP response status codes\n\n* **200** - OK\n\n* **422** - Validation error when the environment name is invalid or when protected\\_branches and custom\\_branch\\_policies in deployment\\_branch\\_policy are set to the same value\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X PUT \\\n  https://api.github.com/repos/OWNER/REPO/environments/ENVIRONMENT_NAME \\\n  -d '{\n  \"wait_timer\": 30,\n  \"prevent_self_review\": false,\n  \"reviewers\": [\n    {\n      \"type\": \"User\",\n      \"id\": 1\n    },\n    {\n      \"type\": \"Team\",\n      \"id\": 1\n    }\n  ],\n  \"deployment_branch_policy\": {\n    \"protected_branches\": false,\n    \"custom_branch_policies\": true\n  }\n}'\n```\n\n**Response schema (Status: 200):**\n\nSame response schema as [Get an environment](#get-an-environment).\n\n## Delete an environment\n\n```\nDELETE /repos/{owner}/{repo}/environments/{environment_name}\n```\n\nOAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.\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* **`owner`** (string) (required)\n  The account owner of the repository. The name is not case sensitive.\n\n* **`repo`** (string) (required)\n  The name of the repository without the .git extension. The name is not case sensitive.\n\n* **`environment_name`** (string) (required)\n  The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.\n\n### HTTP response status codes\n\n* **204** - Default response\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X DELETE \\\n  https://api.github.com/repos/OWNER/REPO/environments/ENVIRONMENT_NAME\n```\n\n**Response schema (Status: 204):**"}