Search code examples
githubgithub-api

Do not allow bypassing the above settings via github api


Is it possible to set Do not allow bypassing the above settings to true with API? Can't find it in the docs https://docs.github.com/en/enterprise-server@3.8/rest/branches/branch-protection and the server response returns no such property


Solution

  • You can use the below to enable "Do not allow bypassing the above settings" setting

    curl -L \
     -X PUT \
     -H "Accept: application/vnd.github+json" \
     -H "Authorization: Bearer <YOUR_GITHUB_TOKEN>" \
     -H "X-GitHub-Api-Version: 2022-11-28" \
     https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection \
     -d '{
     "required_status_checks": null,
     "enforce_admins": true,
     "required_pull_request_reviews": null,
     "restrictions": null,
    }'