GitHub: Get a repository ruleset
GitHub repos.reposGetRepoRuleset: arguments, response, policy and SDK examples.
← Repos operations · Get started
Operation github.repos_get_repo_ruleset
Provider route: GET /repos/{owner}/{repo}/rulesets/{ruleset_id}. Alter supplies the connection’s credentials and routing.
Call through Alter
Section titled “Call through Alter”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"]["reposGetRepoRuleset"]>[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.reposGetRepoRuleset(input); const result = await call.wait(); return result.bodyJson(); } finally { await app.close(); }}import osfrom alter_sdk import Appfrom 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_ruleset(arguments) result = await call.wait() return result.body_json()| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Additional keys: not allowed |
path | object | Required within parent | Additional keys: not allowed |
path.owner | string | Required within parent | |
path.repo | string | Required within parent | |
path.ruleset_id | integer | Required within parent | |
query | object | Optional | Additional keys: not allowed |
query.includes_parents | boolean | Optional | Default: true |
Response
Section titled “Response”Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | Model | Root | Expand Get a repository ruleset — response body |
Referenced models: Get a repository ruleset — response body
Schemas
Section titled “Schemas”35 more schemas are linked from the tables above, on the schema pages.
Get a repository ruleset — response body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | A set of rules to apply when specified conditions are met. |
_links | object | Optional | |
_links.html | JSON | Optional | |
_links.html (anyOf 1) | object | Alternative | |
_links.html (anyOf 1).href | string | Optional | The html URL of the ruleset |
_links.html (anyOf 2) | null | Alternative | |
_links.self | object | Optional | |
_links.self.href | string | Optional | The URL of the ruleset |
bypass_actors | array | Optional | The actors that can bypass the rules in this ruleset |
bypass_actors[] | Model | Each item | Expand Get a repository ruleset — response body — bypass actors item |
conditions | JSON | Optional | |
conditions (anyOf 1) | JSON | Alternative | |
conditions (anyOf 1) (anyOf 1) | Model | Alternative | Expand Create a repository ruleset — request body — body conditions |
conditions (anyOf 1) (anyOf 2) | Model | Alternative | Expand Get a repository ruleset — response body — conditions value Organization ruleset conditions |
conditions (anyOf 2) | null | Alternative | |
created_at | string | Optional | Format: date-time |
current_user_can_bypass | string | Optional | The 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 |
enforcement | string | Required within parent | The 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 |
id | JSON | Required within parent | |
id (anyOf 1) | integer | Alternative | The ID of the ruleset |
id (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
name | string | Required within parent | The name of the ruleset |
node_id | string | Optional | |
rules | array | Optional | |
rules[] | Model | Each item | Expand Get a repository ruleset — response body — rules item |
source | string | Required within parent | The name of the source |
source_type | string | Optional | The type of the source of the ruleset Known values: Repository, Organization, Enterprise |
target | string | Optional | The target of the ruleset Known values: branch, tag, push, repository |
updated_at | string | Optional | Format: 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
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Conditions 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) | object | Alternative | Conditions to target repositories by name and refs by name |
$ (anyOf 1) (allOf 1) | Model | All variants apply | Expand Create a repository ruleset — request body — body conditions |
$ (anyOf 1) (allOf 2) | Model | All variants apply | Expand Create an organization Actions policy — request body — body conditions repository name, workflow path Repository ruleset conditions for repository names |
$ (anyOf 2) | object | Alternative | Conditions to target repositories by id and refs by name |
$ (anyOf 2) (allOf 1) | Model | All variants apply | Expand Create a repository ruleset — request body — body conditions |
$ (anyOf 2) (allOf 2) | Model | All variants apply | Expand 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) | object | Alternative | Conditions to target repositories by property and refs by name |
$ (anyOf 3) (allOf 1) | Model | All variants apply | Expand Create a repository ruleset — request body — body conditions |
$ (anyOf 3) (allOf 2) | Model | All variants apply | Expand 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
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | An actor that can bypass rules in a ruleset |
actor_id | JSON | Optional | |
actor_id (anyOf 1) | JSON | Alternative | |
actor_id (anyOf 1) (anyOf 1) | integer | Alternative | The 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) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
actor_id (anyOf 2) | null | Alternative | |
actor_type | string | Required within parent | The type of actor that can bypass a ruleset. Known values: Integration, OrganizationAdmin, RepositoryRole, Team, DeployKey, User |
bypass_mode | string | Optional | When 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
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Parameters for a repository ruleset ref name condition |
ref_name | object | Optional | |
ref_name.exclude | array | Optional | Array of ref names or patterns to exclude. The condition will not pass if any of these patterns match. |
ref_name.exclude[] | string | Each item | |
ref_name.include | array | Optional | Array 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[] | string | Each 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
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Parameters for a repository ID condition |
repository_id | object | Required within parent | |
repository_id.repository_ids | array | Optional | The repository IDs that the ruleset applies to. One of these IDs must match for the condition to pass. |
repository_id.repository_ids[] | JSON | Each item | |
repository_id.repository_ids[] (anyOf 1) | integer | Alternative | |
repository_id.repository_ids[] (anyOf 2) | string | Alternative | Pattern: ^-?[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
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Parameters for a repository name condition |
repository_name | object | Required within parent | |
repository_name.exclude | array | Optional | Array of repository names or patterns to exclude. The condition will not pass if any of these patterns match. |
repository_name.exclude[] | string | Each item | |
repository_name.include | array | Optional | Array 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[] | string | Each item | |
repository_name.protected | boolean | Optional | Whether renaming of target repositories is prevented. |
Policy, approvals and errors
Section titled “Policy, approvals and errors”SDK function policy ID: github.repos_get_repo_ruleset. Catalog operation: repos/get-repo-ruleset. 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"}