Skip to content

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.

API method documentation

owner
required
string

The account owner of the repository. The name is not case sensitive.

repo
required
string

The name of the repository without the .git extension. The name is not case sensitive.

branch
required
string

The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

per_page
integer
default: 30

The number of results per page (max 100). For more information, see “Using pagination in the REST API.”

page
integer
default: 1

The page number of the results to fetch. For more information, see “Using pagination in the REST API.”

Response

Media type application/json
Array<object>
One of:
Repository Rule

A repository rule with ruleset details.

object
type
required
string
Allowed values: creation
ruleset_source_type

The type of source for the ruleset that includes this rule.

string
Allowed values: Repository Organization
ruleset_source

The name of the source of the ruleset that includes this rule.

string
ruleset_id

The ID of the ruleset that includes this rule.

integer
Examples
Example default
[
{
"type": "commit_message_pattern",
"ruleset_source_type": "Repository",
"ruleset_source": "monalisa/my-repo",
"ruleset_id": 42,
"parameters": {
"operator": "starts_with",
"pattern": "issue"
}
},
{
"type": "commit_author_email_pattern",
"ruleset_source_type": "Organization",
"ruleset_source": "my-org",
"ruleset_id": 73,
"parameters": {
"operator": "contains",
"pattern": "github"
}
}
]