Skip to content

Every rule that holds for a branch (or a tag, with target tag) of a repository, from every ruleset that targets it, the repository's and its workspace's: each with its type, parameters and applies_to, and the ruleset_id, ruleset_name, level and enforcement it comes from.

GET/repos/{owner}/{name}/rules/branches/{branch}

Active rules come first, then those of rulesets in evaluate. rulesets lists the rulesets with who may bypass each. A branch name with slashes is URL-encoded in the path.

A branch with slashes in its name is URL-encoded as one segment: /rules/branches/release%2F1.x. Add ?target=tag for a tag.

  • Authentication: Optional. Public data can be read without a token; send one to see what is private.
  • MCP tool: repository with action branch_rules, and the same inputs
  • Scope: An access token needs repo:read.
Name Type Required Description
owner string Yes The workspace that owns the repository.
name string Yes The repository’s name.
branch string Yes The branch (or tag) name, such as main or release/1.x.
Name Type Required Description
target string No branch (the default) or tag. One of branch, tag.
curl https://api.g1t.sh/repos/flagon-io/hello/rules/branches/main \
-H "Authorization: Bearer $G1T_TOKEN"

A successful request answers 200 with:

{
"name": "main",
"target": "branch",
"default_branch": true,
"rules": [
{
"type": "deletion",
"parameters": {},
"applies_to": "everyone",
"ruleset_id": "rs_01kq3a8b9c0d1e2f3g4h5j6k7m",
"ruleset_name": "Protect main",
"level": "repository",
"enforcement": "active"
},
{
"type": "non_fast_forward",
"parameters": {},
"applies_to": "everyone",
"ruleset_id": "rs_01kq3a8b9c0d1e2f3g4h5j6k7m",
"ruleset_name": "Protect main",
"level": "repository",
"enforcement": "active"
},
{
"type": "pull_request",
"parameters": {
"required_approvals": 1,
"count_agent_approvals": true,
"dismiss_stale_reviews_on_push": true,
"require_code_owner_review": true,
"require_last_push_approval": false,
"allowed_merge_methods": []
},
"applies_to": "everyone",
"ruleset_id": "rs_01kq3a8b9c0d1e2f3g4h5j6k7m",
"ruleset_name": "Protect main",
"level": "repository",
"enforcement": "active"
},
{
"type": "required_status_checks",
"parameters": {
"checks": [
{
"context": "CI",
"integration": "actions"
}
],
"strict": true,
"paths": [],
"allow_bypass_on_merge": false
},
"applies_to": "everyone",
"ruleset_id": "rs_01kq3a8b9c0d1e2f3g4h5j6k7m",
"ruleset_name": "Protect main",
"level": "repository",
"enforcement": "active"
},
{
"type": "merge_window",
"parameters": {
"time_zone": "-05:00",
"windows": [
{
"days": [
"mon",
"tue",
"wed",
"thu"
],
"start": "09:00",
"end": "17:00"
}
],
"freezes": [
{
"start": "2026-12-20T00:00:00Z",
"end": "2027-01-04T00:00:00Z",
"reason": "Holidays"
}
],
"exceptions": []
},
"applies_to": "everyone",
"ruleset_id": "rs_01kq3b2c3d4e5f6g7h8j9k0m1n",
"ruleset_name": "Release freeze",
"level": "workspace",
"enforcement": "evaluate"
}
],
"rulesets": [
{
"id": "rs_01kq3a8b9c0d1e2f3g4h5j6k7m",
"name": "Protect main",
"level": "repository",
"enforcement": "active",
"bypass_actors": [
{
"kind": "role",
"value": "admin",
"mode": "pull_requests"
}
]
},
{
"id": "rs_01kq3b2c3d4e5f6g7h8j9k0m1n",
"name": "Release freeze",
"level": "workspace",
"enforcement": "evaluate",
"bypass_actors": [
{
"kind": "team",
"value": "flagon-io/release",
"mode": "always"
}
]
}
]
}

A failed request answers with one of these statuses and a body like {"error": {"code": "not_found", "message": "Repository not found."}}. See errors.

Status Code When
401 unauthenticated A token is required, or the one sent is not valid.
403 forbidden The token is valid but not allowed to do this, such as a member-only change or an agent token outside its repository.
404 not_found It does not exist, or you cannot see it.
422 invalid The input is not valid. message says which field and why.