Sample - GitHub REST API
PATCH/repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks

Update status check protection

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

Updating required status checks requires admin or owner permissions to the repository and branch protection to be enabled.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

3 parameters · 3 body fields
ownerstringrequired
The account owner of the repository. The name is not case sensitive.
repostringrequired
The name of the repository without the `.git` extension. The name is not case sensitive.
branchstringrequired
The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql).
strictbooleanoptional
Require branches to be up to date before merging.
contextsarray<string>deprecatedoptional
**Closing down notice**: The list of status checks to require in order to merge into this branch. If any of these checks have recently been set by a particular GitHub App, they will be required to come from that app in future for the branch to merge. Use `checks` instead of `contexts` for more fine-grained control.
checksarray<object>optional
The list of status checks to require in order to merge into this branch.

3 status codes
200Response
urlstringrequired
strictbooleanrequired
contextsarray<string>required
checksarray<object>required
contexts_urlstringrequired
404Resource not found
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
422Validation failed, or the endpoint has been spammed.
messagestringrequired
documentation_urlstringrequired
errorsarray<object>optional

Error handling

A 404 is returned: Resource not found. A 422 is returned: Validation failed, or the endpoint has been spammed.