Skip to content

Read a branch's protection config

Check what protection, if any, currently governs a branch.

get_branch_protection { "owner": "<owner>", "repo": "<repo>", "branch": "<branch>" }
{
"requiredStatusChecks": { "strict": true, "contexts": ["ci / build"] },
"enforceAdmins": true,
"requiredApprovingReviewCount": 1
}

requiredStatusChecks is null if no status checks are required. requiredApprovingReviewCount is null if the branch has no required PR reviews configured at all.

GitHub’s underlying endpoint 404s when a branch isn’t protected. The tool surfaces this as a github_api_error — that’s the expected signal for “unprotected,” not a failure to diagnose.

This tool only sees classic branch protection. A branch can also be governed by rulesets, which are read separately — see list-repo-rulesets.md.