PUT /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.

Servers

Path parameters

Name Type Required Description
repo String Yes

The name of the repository without the .git extension. The name is not case sensitive.

environment_name String Yes

The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.

owner String Yes

The account owner of the repository. The name is not case sensitive.

Request headers

Name Type Required Description
Content-Type String Yes The media type of the request body.

Default value: "application/json"

Request body fields

Name Type Required Description
wait_timer Integer No

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).

reviewers[] Array No

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.

reviewers[].id Integer No

The id of the user or team who can review the deployment

reviewers[].type String No

The type of reviewer.

Possible values:

  • "Team"
  • "User"
deployment_branch_policy Object No

The type of deployment branch policy for this environment. To allow all branches to deploy, set to null.

deployment_branch_policy.custom_branch_policies Boolean Yes

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.

deployment_branch_policy.protected_branches Boolean Yes

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.

prevent_self_review Boolean No

Whether or not a user who created the job is prevented from approving their own job.

How to start integrating

  1. Add HTTP Task to your workflow definition.
  2. Search for the API you want to integrate with and click on the name.
    • This loads the API reference documentation and prepares the Http request settings.
  3. Click Test request to test run your request to the API and see the API's response.