Github API can't update required status checks of protected branch

I am an owner of my org repositories and I have more than a thousand of it, so I write automation scripts with API calls to manage GitHub repository settings. The following is an example of the issue:

I have a github repository which has branch protection settings for relase branch:

“url”: “”,
“required_pull_request_reviews”: {
“url”: “”,
“dismiss_stale_reviews”: false,
“require_code_owner_reviews”: false,
“required_approving_review_count”: 1
“enforce_admins”: {
“url”: “”,
“enabled”: false

I ran the following command to update required status checks of protected branch:

curl -sS -X PATCH “$GITHUB_API/repos/mdsol/go-cd-test/branches/release/protection/required_status_checks” -H “Authorization: token $TRAVIS_TOKEN” -H “Accept: application/vnd.github.luke-cage-preview+json” -d ‘{“strict”:false,“contexts”:[“GoCD”]}’

but it returned:
“message”: “Required status checks not enabled”,
“documentation_url”: “


I searched the documents and can’t find anything helpful to enable “Required status checks” through API calls. Do you have any ideas and suggestions? Thanks!

I don’t want to use “-X PUT” because I want to keep existing branch protection rules and they are very diverse in repositories.

Hi @tonyzwei,

This post was moved to a different board that fits your topic of discussion a bit better. This means you’ll get better engagement on your post, and it keeps our community organized so users can more easily find information.

As you’ll notice, your topic is now here in the GitHub API board. No action is needed on your part; you can continue the conversation as normal here.


Hi Tony,

As you found out, you will need to enable the required status checks via the Update Branch Protection API Endpoint first.

You will have to extract the current configuration first with the Get Branch Protection API Endpoint.