---
title: "Get rules for a branch"
method: GET
path: "/repos/{owner}/{repo}/rules/branches/{branch}"
tags: ["repos"]
---

# Get rules for a branch

`GET /repos/{owner}/{repo}/rules/branches/{branch}`

Returns all active rules that apply to the specified branch. The branch does not need to exist; rules that would apply
to a branch with that name will be returned. All active rules that apply will be returned, regardless of the level
at which they are configured (e.g. repository or organization). Rules in rulesets with "evaluate" or "disabled"
enforcement statuses are not returned.

## Path parameters

- `owner` string, required
- `repo` string, required
- `branch` string, required

## Query parameters

- `per_page` integer
- `page` integer

## Response `200`

Response

- RepositoryRuleDetailed[]
  - union — A repository rule with ruleset details.
    - object — User-defined metadata to store domain-specific information limited to 8 keys with scalar values.
      - `type` 'creation', required
      - `ruleset_source_type` 'Repository' | 'Organization' — The type of source for the ruleset that includes this rule.
      - `ruleset_source` string — The name of the source of the ruleset that includes this rule.
      - `ruleset_id` integer — The ID of the ruleset that includes this rule.
    - object — User-defined metadata to store domain-specific information limited to 8 keys with scalar values.
      - `type` 'update', required
      - `parameters` object
        - `update_allows_fetch_and_merge` boolean, required — Branch can pull changes from its upstream repository
      - `ruleset_source_type` 'Repository' | 'Organization' — The type of source for the ruleset that includes this rule.
      - `ruleset_source` string — The name of the source of the ruleset that includes this rule.
      - `ruleset_id` integer — The ID of the ruleset that includes this rule.
    - object — User-defined metadata to store domain-specific information limited to 8 keys with scalar values.
      - `type` 'deletion', required
      - `ruleset_source_type` 'Repository' | 'Organization' — The type of source for the ruleset that includes this rule.
      - `ruleset_source` string — The name of the source of the ruleset that includes this rule.
      - `ruleset_id` integer — The ID of the ruleset that includes this rule.
    - object — User-defined metadata to store domain-specific information limited to 8 keys with scalar values.
      - `type` 'required_linear_history', required
      - `ruleset_source_type` 'Repository' | 'Organization' — The type of source for the ruleset that includes this rule.
      - `ruleset_source` string — The name of the source of the ruleset that includes this rule.
      - `ruleset_id` integer — The ID of the ruleset that includes this rule.
    - object — User-defined metadata to store domain-specific information limited to 8 keys with scalar values.
      - `type` 'merge_queue', required
      - `parameters` object
        - `check_response_timeout_minutes` integer, required — Maximum time for a required status check to report a conclusion. After this much time has elapsed, checks that have not reported a conclusion will be assumed to have failed
        - `grouping_strategy` 'ALLGREEN' | 'HEADGREEN', required — When set to ALLGREEN, the merge commit created by merge queue for each PR in the group must pass all required checks to merge. When set to HEADGREEN, only the commit at the head of the merge group, i.e. the commit containing changes from all of the PRs in the group, must pass its required checks to merge.
        - `max_entries_to_build` integer, required — Limit the number of queued pull requests requesting checks and workflow runs at the same time.
        - `max_entries_to_merge` integer, required — The maximum number of PRs that will be merged together in a group.
        - `merge_method` 'MERGE' | 'SQUASH' | 'REBASE', required — Method to use when merging changes from queued pull requests.
        - `min_entries_to_merge` integer, required — The minimum number of PRs that will be merged together in a group.
        - `min_entries_to_merge_wait_minutes` integer, required — The time merge queue should wait after the first PR is added to the queue for the minimum group size to be met. After this time has elapsed, the minimum group size will be ignored and a smaller group will be merged.
      - `ruleset_source_type` 'Repository' | 'Organization' — The type of source for the ruleset that includes this rule.
      - `ruleset_source` string — The name of the source of the ruleset that includes this rule.
      - `ruleset_id` integer — The ID of the ruleset that includes this rule.
    - object — User-defined metadata to store domain-specific information limited to 8 keys with scalar values.
      - `type` 'required_deployments', required
      - `parameters` object
        - `required_deployment_environments` string[], required — The environments that must be successfully deployed to before branches can be merged.
      - `ruleset_source_type` 'Repository' | 'Organization' — The type of source for the ruleset that includes this rule.
      - `ruleset_source` string — The name of the source of the ruleset that includes this rule.
      - `ruleset_id` integer — The ID of the ruleset that includes this rule.
    - object — User-defined metadata to store domain-specific information limited to 8 keys with scalar values.
      - `type` 'required_signatures', required
      - `ruleset_source_type` 'Repository' | 'Organization' — The type of source for the ruleset that includes this rule.
      - `ruleset_source` string — The name of the source of the ruleset that includes this rule.
      - `ruleset_id` integer — The ID of the ruleset that includes this rule.
    - object — User-defined metadata to store domain-specific information limited to 8 keys with scalar values.
      - `type` 'pull_request', required
      - `parameters` object
        - `allowed_merge_methods` string[] — Array of allowed merge methods. Allowed values include `merge`, `squash`, and `rebase`. At least one option must be enabled.
        - `dismiss_stale_reviews_on_push` boolean, required — New, reviewable commits pushed will dismiss previous pull request review approvals.
        - `dismissal_restriction` RepositoryRuleParamsDismissalRestriction — Specify people, teams, or apps allowed to dismiss pull request reviews.
          - `allowed_actors` RepositoryRuleParamsActor[] — Specify people, teams, or apps allowed to dismiss pull request reviews.
            - `id` integer, required — ID of the actor that can dismiss reviews.
            - `type` 'User' | 'Team' | 'IntegrationInstallation' | 'RepositoryRole', required — The type of the actor
          - `enabled` boolean, required — Whether to restrict review dismissal to specific actors.
        - `require_code_owner_review` boolean, required — Require an approving review in pull requests that modify files that have a designated code owner.
        - `require_last_push_approval` boolean, required — Whether the most recent reviewable push must be approved by someone other than the person who pushed it.
        - `required_approving_review_count` integer, required — The number of approving reviews that are required before a pull request can be merged.
        - `required_review_thread_resolution` boolean, required — All conversations on code must be resolved before a pull request can be merged.
        - `required_reviewers` RepositoryRuleParamsRequiredReviewerConfiguration[] — > [!NOTE] > `required_reviewers` is in beta and subject to change. A collection of reviewers and associated file patterns. Each reviewer has a list of file patterns which determine the files that reviewer is required to review.
          - `file_patterns` string[], required — Array of file patterns. Pull requests which change matching files must be approved by the specified team. File patterns use fnmatch syntax.
          - `minimum_approvals` integer, required — Minimum number of approvals required from the specified team. If set to zero, the team will be added to the pull request but approval is optional.
          - `reviewer` RepositoryRuleParamsReviewer, required — A required reviewing team
            - `id` integer, required — ID of the reviewer which must review changes to matching files.
            - `type` 'Team', required — The type of the reviewer
      - `ruleset_source_type` 'Repository' | 'Organization' — The type of source for the ruleset that includes this rule.
      - `ruleset_source` string — The name of the source of the ruleset that includes this rule.
      - `ruleset_id` integer — The ID of the ruleset that includes this rule.
    - object — User-defined metadata to store domain-specific information limited to 8 keys with scalar values.
      - `type` 'required_status_checks', required
      - `parameters` object
        - `do_not_enforce_on_create` boolean — Allow repositories and branches to be created if a check would otherwise prohibit it.
        - `required_status_checks` RepositoryRuleParamsStatusCheckConfiguration[], required — Status checks that are required.
          - `context` string, required — The status check context name that must be present on the commit.
          - `integration_id` integer — The optional integration ID that this status check must originate from.
        - `strict_required_status_checks_policy` boolean, required — Whether pull requests targeting a matching branch must be tested with the latest code. This setting will not take effect unless at least one status check is enabled.
      - `ruleset_source_type` 'Repository' | 'Organization' — The type of source for the ruleset that includes this rule.
      - `ruleset_source` string — The name of the source of the ruleset that includes this rule.
      - `ruleset_id` integer — The ID of the ruleset that includes this rule.
    - object — User-defined metadata to store domain-specific information limited to 8 keys with scalar values.
      - `type` 'non_fast_forward', required
      - `ruleset_source_type` 'Repository' | 'Organization' — The type of source for the ruleset that includes this rule.
      - `ruleset_source` string — The name of the source of the ruleset that includes this rule.
      - `ruleset_id` integer — The ID of the ruleset that includes this rule.
    - object — User-defined metadata to store domain-specific information limited to 8 keys with scalar values.
      - `type` 'commit_message_pattern', required
      - `parameters` object
        - `name` string — How this rule appears when configuring it.
        - `negate` boolean — If true, the rule will fail if the pattern matches.
        - `operator` 'starts_with' | 'ends_with' | 'contains' | 'regex', required — The operator to use for matching.
        - `pattern` string, required — The pattern to match with.
      - `ruleset_source_type` 'Repository' | 'Organization' — The type of source for the ruleset that includes this rule.
      - `ruleset_source` string — The name of the source of the ruleset that includes this rule.
      - `ruleset_id` integer — The ID of the ruleset that includes this rule.
    - object — User-defined metadata to store domain-specific information limited to 8 keys with scalar values.
      - `type` 'commit_author_email_pattern', required
      - `parameters` object
        - `name` string — How this rule appears when configuring it.
        - `negate` boolean — If true, the rule will fail if the pattern matches.
        - `operator` 'starts_with' | 'ends_with' | 'contains' | 'regex', required — The operator to use for matching.
        - `pattern` string, required — The pattern to match with.
      - `ruleset_source_type` 'Repository' | 'Organization' — The type of source for the ruleset that includes this rule.
      - `ruleset_source` string — The name of the source of the ruleset that includes this rule.
      - `ruleset_id` integer — The ID of the ruleset that includes this rule.
    - object — User-defined metadata to store domain-specific information limited to 8 keys with scalar values.
      - `type` 'committer_email_pattern', required
      - `parameters` object
        - `name` string — How this rule appears when configuring it.
        - `negate` boolean — If true, the rule will fail if the pattern matches.
        - `operator` 'starts_with' | 'ends_with' | 'contains' | 'regex', required — The operator to use for matching.
        - `pattern` string, required — The pattern to match with.
      - `ruleset_source_type` 'Repository' | 'Organization' — The type of source for the ruleset that includes this rule.
      - `ruleset_source` string — The name of the source of the ruleset that includes this rule.
      - `ruleset_id` integer — The ID of the ruleset that includes this rule.
    - object — User-defined metadata to store domain-specific information limited to 8 keys with scalar values.
      - `type` 'branch_name_pattern', required
      - `parameters` object
        - `name` string — How this rule appears when configuring it.
        - `negate` boolean — If true, the rule will fail if the pattern matches.
        - `operator` 'starts_with' | 'ends_with' | 'contains' | 'regex', required — The operator to use for matching.
        - `pattern` string, required — The pattern to match with.
      - `ruleset_source_type` 'Repository' | 'Organization' — The type of source for the ruleset that includes this rule.
      - `ruleset_source` string — The name of the source of the ruleset that includes this rule.
      - `ruleset_id` integer — The ID of the ruleset that includes this rule.
    - object — User-defined metadata to store domain-specific information limited to 8 keys with scalar values.
      - `type` 'tag_name_pattern', required
      - `parameters` object
        - `name` string — How this rule appears when configuring it.
        - `negate` boolean — If true, the rule will fail if the pattern matches.
        - `operator` 'starts_with' | 'ends_with' | 'contains' | 'regex', required — The operator to use for matching.
        - `pattern` string, required — The pattern to match with.
      - `ruleset_source_type` 'Repository' | 'Organization' — The type of source for the ruleset that includes this rule.
      - `ruleset_source` string — The name of the source of the ruleset that includes this rule.
      - `ruleset_id` integer — The ID of the ruleset that includes this rule.
    - object — User-defined metadata to store domain-specific information limited to 8 keys with scalar values.
      - `type` 'workflows', required
      - `parameters` object
        - `do_not_enforce_on_create` boolean — Allow repositories and branches to be created if a check would otherwise prohibit it.
        - `workflows` RepositoryRuleParamsWorkflowFileReference[], required — Workflows that must pass for this rule to pass.
          - `path` string, required — The path to the workflow file
          - `ref` string — The ref (branch or tag) of the workflow file to use
          - `repository_id` integer, required — The ID of the repository where the workflow is defined
          - `sha` string — The commit SHA of the workflow file to use
      - `ruleset_source_type` 'Repository' | 'Organization' — The type of source for the ruleset that includes this rule.
      - `ruleset_source` string — The name of the source of the ruleset that includes this rule.
      - `ruleset_id` integer — The ID of the ruleset that includes this rule.
    - object — User-defined metadata to store domain-specific information limited to 8 keys with scalar values.
      - `type` 'code_scanning', required
      - `parameters` object
        - `code_scanning_tools` RepositoryRuleParamsCodeScanningTool[], required — Tools that must provide code scanning results for this rule to pass.
          - `alerts_threshold` 'none' | 'errors' | 'errors_and_warnings' | 'all', required — The severity level at which code scanning results that raise alerts block a reference update. For more information on alert severity levels, see "[About code scanning alerts](https://docs.github.com/code-security/code-scanning/managing-code-scanning-alerts/about-code-scanning-alerts#about-alert-severity-and-security-severity-levels)."
          - `security_alerts_threshold` 'none' | 'critical' | 'high_or_higher' | 'medium_or_higher' | 'all', required — The severity level at which code scanning results that raise security alerts block a reference update. For more information on security severity levels, see "[About code scanning alerts](https://docs.github.com/code-security/code-scanning/managing-code-scanning-alerts/about-code-scanning-alerts#about-alert-severity-and-security-severity-levels)."
          - `tool` string, required — The name of a code scanning tool
      - `ruleset_source_type` 'Repository' | 'Organization' — The type of source for the ruleset that includes this rule.
      - `ruleset_source` string — The name of the source of the ruleset that includes this rule.
      - `ruleset_id` integer — The ID of the ruleset that includes this rule.
    - object — User-defined metadata to store domain-specific information limited to 8 keys with scalar values.
      - `type` 'copilot_code_review', required
      - `parameters` object
        - `review_draft_pull_requests` boolean — Copilot automatically reviews draft pull requests before they are marked as ready for review.
        - `review_on_push` boolean — Copilot automatically reviews each new push to the pull request.
      - `ruleset_source_type` 'Repository' | 'Organization' — The type of source for the ruleset that includes this rule.
      - `ruleset_source` string — The name of the source of the ruleset that includes this rule.
      - `ruleset_id` integer — The ID of the ruleset that includes this rule.
    - object — User-defined metadata to store domain-specific information limited to 8 keys with scalar values.
      - `type` 'license_compliance_scanning', required
      - `ruleset_source_type` 'Repository' | 'Organization' — The type of source for the ruleset that includes this rule.
      - `ruleset_source` string — The name of the source of the ruleset that includes this rule.
      - `ruleset_id` integer — The ID of the ruleset that includes this rule.
    - object — User-defined metadata to store domain-specific information limited to 8 keys with scalar values.
      - `type` 'file_path_restriction', required
      - `parameters` object
        - `restricted_file_paths` string[], required — The file paths that are restricted from being pushed to the commit graph.
      - `ruleset_source_type` 'Repository' | 'Organization' — The type of source for the ruleset that includes this rule.
      - `ruleset_source` string — The name of the source of the ruleset that includes this rule.
      - `ruleset_id` integer — The ID of the ruleset that includes this rule.
    - object — User-defined metadata to store domain-specific information limited to 8 keys with scalar values.
      - `type` 'max_file_path_length', required
      - `parameters` object
        - `max_file_path_length` integer, required — The maximum amount of characters allowed in file paths.
      - `ruleset_source_type` 'Repository' | 'Organization' — The type of source for the ruleset that includes this rule.
      - `ruleset_source` string — The name of the source of the ruleset that includes this rule.
      - `ruleset_id` integer — The ID of the ruleset that includes this rule.
    - object — User-defined metadata to store domain-specific information limited to 8 keys with scalar values.
      - `type` 'file_extension_restriction', required
      - `parameters` object
        - `restricted_file_extensions` string[], required — The file extensions that are restricted from being pushed to the commit graph.
      - `ruleset_source_type` 'Repository' | 'Organization' — The type of source for the ruleset that includes this rule.
      - `ruleset_source` string — The name of the source of the ruleset that includes this rule.
      - `ruleset_id` integer — The ID of the ruleset that includes this rule.
    - object — User-defined metadata to store domain-specific information limited to 8 keys with scalar values.
      - `type` 'max_file_size', required
      - `parameters` object
        - `max_file_size` integer, required — The maximum file size allowed in megabytes. This limit does not apply to Git Large File Storage (Git LFS).
      - `ruleset_source_type` 'Repository' | 'Organization' — The type of source for the ruleset that includes this rule.
      - `ruleset_source` string — The name of the source of the ruleset that includes this rule.
      - `ruleset_id` integer — The ID of the ruleset that includes this rule.

---

[API](https://skmtc.net/github/apis/github-v3-rest-api.md) · [All operations](https://skmtc.net/github/apis/github-v3-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/github/github-v3-rest-api/versions/a367f7028301/schema)
