Use the REST API to create, configure, and delete deployment environments.
For more information about environments, see Managing environments for deployment. To manage environment secrets, see REST API endpoints for GitHub Actions Secrets.
Environments, environment secrets, and deployment protection rules are available in public repositories for all current GitHub plans. They are not available on legacy plans, such as Bronze, Silver, or Gold. For access to environments, environment secrets, and deployment branches in private or internal repositories, you must use GitHub Pro, GitHub Team, or GitHub Enterprise. If you are on a GitHub Free, GitHub Pro, or GitHub Team plan, other deployment protection rules, such as a wait timer or required reviewers, are only available for public repositories.
Note
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.
GET /repos/{owner}/{repo}/environments
Lists the environments for a repository.
Anyone with read access to the repository can use this endpoint.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with a private repository.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
per_page (integer)
The number of results per page (max 100). For more information, see "Using pagination in the REST API."
Default: 30
page (integer)
The page number of the results to fetch. For more information, see "Using pagination in the REST API."
Default: 1
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/environments
Response schema (Status: 200):
total_count: integerenvironments: array of Environment:
id: required, integer, format: int64node_id: required, stringname: required, stringurl: required, stringhtml_url: required, stringcreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timeprotection_rules: array of items:
id: required, integernode_id: required, stringtype: required, stringwait_timer: integerid: required, integernode_id: required, stringprevent_self_review: booleantype: required, stringreviewers: array of objects:
type: string, enum: User, Teamreviewer: any of:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringid: required, integernode_id: required, stringname: required, stringslug: required, stringdescription: required, string or nullprivacy: stringnotification_setting: stringpermission: required, stringpermissions: objecturl: required, string, format: urihtml_url: required, string, format: urimembers_url: required, stringrepositories_url: required, string, format: uritype: required, string, enum: enterprise, organizationaccess_source: string, enum: direct, organization, enterpriseorganization_id: integerenterprise_id: integerparent: required, any of:
id: required, integernode_id: required, stringtype: required, stringdeployment_branch_policy: object or null:
protected_branches: required, booleancustom_branch_policies: required, booleanGET /repos/{owner}/{repo}/environments/{environment_name}
Note
To get information about name patterns that branches must match in order to deploy to this environment, see "Get a deployment branch policy."
Anyone with read access to the repository can use this endpoint.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with a private repository.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
environment_name (string) (required)
The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/environments/ENVIRONMENT_NAME
Response schema (Status: 200):
id: required, integer, format: int64node_id: required, stringname: required, stringurl: required, stringhtml_url: required, stringcreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timeprotection_rules: array of items:
id: required, integernode_id: required, stringtype: required, stringwait_timer: integerid: required, integernode_id: required, stringprevent_self_review: booleantype: required, stringreviewers: array of objects:
type: string, enum: User, Teamreviewer: any of:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringid: required, integernode_id: required, stringname: required, stringslug: required, stringdescription: required, string or nullprivacy: stringnotification_setting: stringpermission: required, stringpermissions: object:
pull: required, booleantriage: required, booleanpush: required, booleanmaintain: required, booleanadmin: required, booleanurl: required, string, format: urihtml_url: required, string, format: urimembers_url: required, stringrepositories_url: required, string, format: uritype: required, string, enum: enterprise, organizationaccess_source: string, enum: direct, organization, enterpriseorganization_id: integerenterprise_id: integerparent: required, any of:
id: required, integernode_id: required, stringurl: required, string, format: urimembers_url: required, stringname: required, stringdescription: required, string or nullpermission: required, stringprivacy: stringnotification_setting: stringhtml_url: required, string, format: urirepositories_url: required, string, format: urislug: required, stringldap_dn: stringtype: required, string, enum: enterprise, organizationorganization_id: integerenterprise_id: integerid: required, integernode_id: required, stringtype: required, stringdeployment_branch_policy: object or null:
protected_branches: required, booleancustom_branch_policies: required, booleanPUT /repos/{owner}/{repo}/environments/{environment_name}
Create or update an environment with protection rules, such as required reviewers. For more information about environment protection rules, see "Environments."
Note
To create or update name patterns that branches must match in order to deploy to this environment, see "Deployment branch policies."
Note
To create or update secrets for an environment, see "GitHub Actions secrets."
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
environment_name (string) (required)
The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.
wait_timer (integer)
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).
prevent_self_review (boolean)
Whether or not a user who created the job is prevented from approving their own job.
reviewers (array of objects or null)
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.
type (string)User, Teamid (integer)deployment_branch_policy (object or null)
The type of deployment branch policy for this environment. To allow all branches to deploy, set to null.
protected_branches (boolean) (required)custom_branch_policies (boolean) (required)200 - OK
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
Request:
curl -L \
-X PUT \
https://api.github.com/repos/OWNER/REPO/environments/ENVIRONMENT_NAME \
-d '{
"wait_timer": 30,
"prevent_self_review": false,
"reviewers": [
{
"type": "User",
"id": 1
},
{
"type": "Team",
"id": 1
}
],
"deployment_branch_policy": {
"protected_branches": false,
"custom_branch_policies": true
}
}'
Response schema (Status: 200):
Same response schema as Get an environment.
DELETE /repos/{owner}/{repo}/environments/{environment_name}
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
environment_name (string) (required)
The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.
Request:
curl -L \
-X DELETE \
https://api.github.com/repos/OWNER/REPO/environments/ENVIRONMENT_NAME
Response schema (Status: 204):