v50

latestOpenAPI 3.0.3MITraw.githubusercontent.com2023-11-288093493.9 MB
repos

Create or update an environment

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

You must authenticate using an access token with the repo scope to use this endpoint. GitHub Apps must have the administration:write permission for the repository to use this endpoint.

put/repos/{owner}/{repo}/environments/{environment_name}

Path parameters

ownerstring required

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

repostring required

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

environment_namestring 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 body

wait_timerinteger

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

Example request

{
  "wait_timer": 30,
  "reviewers": [
    {
      "type": "User",
      "id": 4532992
    }
  ]
}

Response

Response

idinteger required

The id of the environment.

node_idstring required
namestring required

The name of the environment.

urlstring required
html_urlstring required
created_atstring date-time required

The time that the environment was created, in ISO 8601 format.

updated_atstring date-time required

The time that the environment was last updated, in ISO 8601 format.

Example response

{
  "id": 56780428,
  "node_id": "MDExOkVudmlyb25tZW50NTY3ODA0Mjg=",
  "name": "staging",
  "url": "https://api.github.com/repos/github/hello-world/environments/staging",
  "html_url": "https://github.com/github/hello-world/deployments/activity_log?environments_filter=staging",
  "created_at": "2020-11-23T22:00:40Z",
  "updated_at": "2020-11-23T22:00:40Z",
  "protection_rules": [
    {
      "id": 3515,
      "node_id": "MDQ6R2F0ZTM1MTU=",
      "type": "wait_timer",
      "wait_timer": 30
    }
  ]
}