{% extends "docs/base.html" %} {% block docs_content %}

Get pull protection

Fetch the branch protection status of a pull request.

Endpoints

GET /api/v1/teams/{team_slug}/repos/{repo_slug}/pulls/{number}/protection
GET /api/v1/users/{username}/repos/{repo_slug}/pulls/{number}/protection
Authenticated

Usage

curl --header "Authorization: Bearer $PEARING_API_TOKEN" \
  "$PEARING_API_URL/v1/teams/platform/repos/website/pulls/42/protection"

Success

200 OK with the protection status for the pull. Each matching branch protection rule is evaluated independently. The top-level status is ok, pending, or failed. When merge_blocked is true, the pull cannot be merged until the blocking conditions are resolved.

{
  "pull_number": 42,
  "target_ref": "main",
  "status": "pending",
  "merge_blocked": true,
  "merge_blocked_reason": "0/1 approvals recorded.",
  "rules": [
    {
      "branch_pattern": "main",
      "status": "pending",
      "approvers": ["alice"],
      "checks": [
        {
          "label": "approvals",
          "status": "pending",
          "detail": "0/1 approvals recorded."
        },
        {
          "label": "single_commit",
          "status": "ok",
          "detail": "Not required."
        },
        {
          "label": "fast_forward",
          "status": "ok",
          "detail": "Fast-forward merge is available."
        },
        {
          "label": "owner_merge",
          "status": "ok",
          "detail": "Not required."
        }
      ]
    }
  ]
}

Errors

Common auth errors are documented on the API overview page.

{% endblock %}