apicheats.dev github/llms.txt Raw .md
PUT

PUT /repos/{owner}/{repo}/environments/{environment_name} — GitHub API

GitHub token (required); https://api.github.com

GitHub API

Create or update an environment

Base URL
https://api.github.com
Auth
Authorization: Bearer <GITHUB_API_KEY>
Last verified
2026-10-20 · upstream hash matched
Actions Try in browser→
Agents: curl -H "Accept: text/markdown" this URL
→ 371 tokens · Vary: Accept

Critical gotchas

GitHub recommends an Accept: application/vnd.github+json header and an explicit X-GitHub-Api-Version header.

Fine-grained tokens only authorize repositories and permissions selected when the token is created.

cURL

curl -X PUT 'https://api.github.com/repos/example-owner/example-repo/environments/example-environment-name' \  -H "Authorization: Bearer $GITHUB_TOKEN" \  -H 'Accept: application/vnd.github+json' \  -H 'X-GitHub-Api-Version: 2026-03-10' \  -H 'Content-Type: application/json' \  -d '{}'

Parameters

Name In Type Required Description
owner path string Yes The account owner of the repository. The name is not case sensitive.
repo path string Yes The name of the repository without the `.git` extension. The name is not case sensitive.
environment_name path 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`.
wait_timer body 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).
prevent_self_review body boolean No Whether or not a user who created the job is prevented from approving their own job.
reviewers body object[] 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.
deployment_branch_policy body object No The type of deployment branch policy for this environment. To allow all branches to deploy, set to `null`.

Response 200 OK

{
  "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
    }
  ],
  "deployment_branch_policy": {
    "protected_branches": true,
    "custom_branch_policies": true
  }
}
Get a free GitHub API key → sponsored

Affiliate link - we may earn a commission, at no extra cost to you.