How can I check the state of the "Require branches to be up to date before merging" check for a Pull Request

Is there a way to get the result of the “Require branches to be up to date before merging” branch protection check for a pull request using the API (v3 or GraphQl)? My repo has this check enabled for pull requests based on master. It would be nice to be able to know if a branch is blocked from being merged because of this check - i.e. if the Pull Request UI says “This branch is out-of-date with the base branch” and the Merge button is disabled as a result.

:wave: @sfpetersen––Great question!

Our Get a pull request REST API endpoint includes a mergeable_state field in its response. The available values returned by the mergeable_state field are documented in the MergeStateStatus GraphQL documentation, which will be updated if the values change in the future. It doesn’t require an API preview header to access and can be considered a field suitable for consumers to determine the mergeable state of a pull request.

You may notice that this field’s possible values aren’t currently documented within that endpoint’s documentation. We’ve raised this point with our documentation team in an internal tracking issue, though we don’t have a timeline around when that will be updated.

Also, it might be worth sharing that there’s an alternative method to check the mergeability of pull requests using the mergeable boolean value if you only need to check whether a pull request is able to be merged, rather than a status. I hope this helps!