Skip to content

GitHub: Get all repository rulesets

GitHub repos.reposGetRepoRulesets: arguments, response, policy and SDK examples.

← Repos operations · Get started

Operation github.repos_get_repo_rulesets

Provider route: GET /repos/{owner}/{repo}/rulesets. Alter supplies the connection’s credentials and routing.

Install @alter-ai/sdk @alter-ai/github with npm, or alter-sdk-github with pip. Supply your connected customer’s grant ID and the arguments described below.

import { App } from "@alter-ai/sdk";
import { GitHubIntegration } from "@alter-ai/github";
async function execute(input: Parameters<GitHubIntegration["repos"]["reposGetRepoRulesets"]>[0]) {
const app = new App({ apiKey: process.env.ALTER_API_KEY! });
try {
const provider = new GitHubIntegration(app, { grantId: process.env.PROVIDER_GRANT_ID! });
const call = await provider.repos.reposGetRepoRulesets(input);
const result = await call.wait();
return result.bodyJson();
} finally {
await app.close();
}
}
import os
from alter_sdk import App
from alter_sdk_github import GitHubIntegration
async def execute(arguments):
async with App(api_key=os.environ["ALTER_API_KEY"]) as app:
provider = GitHubIntegration(app, {"grant_id": os.environ["PROVIDER_GRANT_ID"]})
call = await provider.repos.repos_get_repo_rulesets(arguments)
result = await call.wait()
return result.body_json()
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
pathobjectRequired within parentAdditional keys: not allowed
path.ownerstringRequired within parent
path.repostringRequired within parent
queryobjectOptionalAdditional keys: not allowed
query.per_pageintegerOptionalDefault: 30
query.pageintegerOptionalDefault: 1
query.includes_parentsbooleanOptionalDefault: true
query.targetsstringOptional

Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.

FieldTypePresenceDescription and constraints
$arrayRoot
$[]ModelEach itemExpand Get a repository ruleset — response body

Referenced models: Get a repository ruleset — response body

35 more schemas are linked from the tables above, on the schema pages.

Get a repository ruleset — response body
FieldTypePresenceDescription and constraints
$objectRootA set of rules to apply when specified conditions are met.
_linksobjectOptional
_links.htmlJSONOptional
_links.html (anyOf 1)objectAlternative
_links.html (anyOf 1).hrefstringOptionalThe html URL of the ruleset
_links.html (anyOf 2)nullAlternative
_links.selfobjectOptional
_links.self.hrefstringOptionalThe URL of the ruleset
bypass_actorsarrayOptionalThe actors that can bypass the rules in this ruleset
bypass_actors[]ModelEach itemExpand Get a repository ruleset — response body — bypass actors item
conditionsJSONOptional
conditions (anyOf 1)JSONAlternative
conditions (anyOf 1) (anyOf 1)ModelAlternativeExpand Create a repository ruleset — request body — body conditions
conditions (anyOf 1) (anyOf 2)ModelAlternativeExpand Get a repository ruleset — response body — conditions value Organization ruleset conditions
conditions (anyOf 2)nullAlternative
created_atstringOptionalFormat: date-time
current_user_can_bypassstringOptionalThe bypass type of the user making the API request for this ruleset. This field is only returned when
querying the repository-level endpoint.
Known values: always, pull_requests_only, never, exempt
enforcementstringRequired within parentThe enforcement level of the ruleset. `evaluate` allows admins to test rules before enforcing them. Admins can view insights on the Rule Insights page (`evaluate` is only available with GitHub Enterprise).
Known values: disabled, active, evaluate
idJSONRequired within parent
id (anyOf 1)integerAlternativeThe ID of the ruleset
id (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
namestringRequired within parentThe name of the ruleset
node_idstringOptional
rulesarrayOptional
rules[]ModelEach itemExpand Get a repository ruleset — response body — rules item
sourcestringRequired within parentThe name of the source
source_typestringOptionalThe type of the source of the ruleset
Known values: Repository, Organization, Enterprise
targetstringOptionalThe target of the ruleset
Known values: branch, tag, push, repository
updated_atstringOptionalFormat: date-time

Referenced models: Get a repository ruleset — response body — conditions value Organization ruleset conditions, Get a repository ruleset — response body — rules item, Get a repository ruleset — response body — bypass actors item, Create a repository ruleset — request body — body conditions

Get a repository ruleset — response body — conditions value Organization ruleset conditions
FieldTypePresenceDescription and constraints
$objectRootConditions for an organization ruleset.
The branch and tag rulesets conditions object should contain both `repository_name` and `ref_name` properties, or both `repository_id` and `ref_name` properties, or both `repository_property` and `ref_name` properties.
The push rulesets conditions object does not require the `ref_name` property.
For repository policy rulesets, the conditions object should only contain the `repository_name`, the `repository_id`, or the `repository_property`.
$ (anyOf 1)objectAlternativeConditions to target repositories by name and refs by name
$ (anyOf 1) (allOf 1)ModelAll variants applyExpand Create a repository ruleset — request body — body conditions
$ (anyOf 1) (allOf 2)ModelAll variants applyExpand Create an organization Actions policy — request body — body conditions repository name, workflow path Repository ruleset conditions for repository names
$ (anyOf 2)objectAlternativeConditions to target repositories by id and refs by name
$ (anyOf 2) (allOf 1)ModelAll variants applyExpand Create a repository ruleset — request body — body conditions
$ (anyOf 2) (allOf 2)ModelAll variants applyExpand Get a repository Actions policy — response body — conditions value Organization Actions policy conditions repository id, workflow path Repository ruleset conditions for repository I Ds
$ (anyOf 3)objectAlternativeConditions to target repositories by property and refs by name
$ (anyOf 3) (allOf 1)ModelAll variants applyExpand Create a repository ruleset — request body — body conditions
$ (anyOf 3) (allOf 2)ModelAll variants applyExpand Get a repository Actions policy — response body — conditions value Organization Actions policy conditions repository property, workflow path Repository ruleset conditions for repository properties

Referenced models: Create a repository ruleset — request body — body conditions, Get a repository Actions policy — response body — conditions value Organization Actions policy conditions repository id, workflow path Repository ruleset conditions for repository I Ds, Create an organization Actions policy — request body — body conditions repository name, workflow path Repository ruleset conditions for repository names, Get a repository Actions policy — response body — conditions value Organization Actions policy conditions repository property, workflow path Repository ruleset conditions for repository properties

Get a repository ruleset — response body — bypass actors item
FieldTypePresenceDescription and constraints
$objectRootAn actor that can bypass rules in a ruleset
actor_idJSONOptional
actor_id (anyOf 1)JSONAlternative
actor_id (anyOf 1) (anyOf 1)integerAlternativeThe ID of the actor that can bypass a ruleset. Required for `Integration`, `RepositoryRole`, `Team`, and `User` actor types. If `actor_type` is `OrganizationAdmin`, `actor_id` is ignored. If `actor_type` is `DeployKey`, this should be null. `OrganizationAdmin` is not applicable for personal repositories.
actor_id (anyOf 1) (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
actor_id (anyOf 2)nullAlternative
actor_typestringRequired within parentThe type of actor that can bypass a ruleset.
Known values: Integration, OrganizationAdmin, RepositoryRole, Team, DeployKey, User
bypass_modestringOptionalWhen the specified actor can bypass the ruleset. `pull_request` means that an actor can only bypass rules on pull requests. `pull_request` is not applicable for the `DeployKey` actor type. Also, `pull_request` is only applicable to branch rulesets. When `bypass_mode` is `exempt`, rules will not be run for that actor and a bypass audit entry will not be created.
Known values: always, pull_request, exempt
Default: always
Create a repository ruleset — request body — body conditions
FieldTypePresenceDescription and constraints
$objectRootParameters for a repository ruleset ref name condition
ref_nameobjectOptional
ref_name.excludearrayOptionalArray of ref names or patterns to exclude. The condition will not pass if any of these patterns match.
ref_name.exclude[]stringEach item
ref_name.includearrayOptionalArray of ref names or patterns to include. One of these patterns must match for the condition to pass. Also accepts `~DEFAULT_BRANCH` to include the default branch or `~ALL` to include all branches.
ref_name.include[]stringEach item
Get a repository Actions policy — response body — conditions value Organization Actions policy conditions repository id, workflow path Repository ruleset conditions for repository I Ds
FieldTypePresenceDescription and constraints
$objectRootParameters for a repository ID condition
repository_idobjectRequired within parent
repository_id.repository_idsarrayOptionalThe repository IDs that the ruleset applies to. One of these IDs must match for the condition to pass.
repository_id.repository_ids[]JSONEach item
repository_id.repository_ids[] (anyOf 1)integerAlternative
repository_id.repository_ids[] (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
Create an organization Actions policy — request body — body conditions repository name, workflow path Repository ruleset conditions for repository names
FieldTypePresenceDescription and constraints
$objectRootParameters for a repository name condition
repository_nameobjectRequired within parent
repository_name.excludearrayOptionalArray of repository names or patterns to exclude. The condition will not pass if any of these patterns match.
repository_name.exclude[]stringEach item
repository_name.includearrayOptionalArray of repository names or patterns to include. One of these patterns must match for the condition to pass. Also accepts `~ALL` to include all repositories.
repository_name.include[]stringEach item
repository_name.protectedbooleanOptionalWhether renaming of target repositories is prevented.

SDK function policy ID: github.repos_get_repo_rulesets. Catalog operation: repos/get-repo-rulesets. Rules can name either ID; function rules distinguish managed calls and conservatively cover raw calls sharing the route. Existing grant permissions and policy rules apply. wait() returns an immediate result or waits for a required approval; it never approves the request itself. Persist the approval ID to resume after a restart.

Provider errors retain their response; JSON decoding raises ProviderAPIError for provider failures. ManagedOperationError identifies contract/input/retention errors. See error handling and provider-specific behavior. Sensitive input may be refused before approval storage. A decoding error never resubmits a write.

Pinned headers: {"X-GitHub-Api-Version": "2026-03-10", "User-Agent": "Alter", "Accept": "application/vnd.github+json"}

Official provider source

Report an issue with this page

Necessary

Required for sign-in, security, authorization, and remembering your choices.

Always active

Analytics

Helps us understand which product and documentation features are useful.

Performance diagnostics

Uses performance tracing and privacy-masked session replay to diagnose problems.

You can change these choices at any time from Cookie settings.