GitHub: Create an organization repository ruleset
GitHub repos.reposCreateOrgRuleset: arguments, response, policy and SDK examples.
← Repos operations · Get started
Operation github.repos_create_org_ruleset
Provider route: POST /orgs/{org}/rulesets. 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"]["reposCreateOrgRuleset"]>[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.reposCreateOrgRuleset(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_create_org_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.org | string | Required within parent | |
body | object | Required within parent | |
body.bypass_actors | array | Optional | The actors that can bypass the rules in this ruleset |
body.bypass_actors[] | Model | Each item | Expand Create a repository ruleset — request body — body bypass actors item |
body.conditions | Model | Optional | Expand Create an organization repository ruleset — request body — body conditions |
body.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). One of: disabled, active, evaluate |
body.name | string | Required within parent | The name of the ruleset. |
body.rules | array | Optional | An array of rules within the ruleset. |
body.rules[] | Model | Each item | Expand Create an organization repository ruleset — request body — body rules item |
body.target | string | Optional | The target of the ruleset Default: branch One of: branch, tag, push, repository |
Referenced models: Create an organization repository ruleset — request body — body rules item, Create an organization repository ruleset — request body — body conditions, Create a repository ruleset — request body — body bypass actors item
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”73 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
Create an organization repository ruleset — request body — body rules item
Referenced models: Create a repository ruleset — request body — body rules item branch name pattern, Create a repository ruleset — request body — body rules item code scanning, Create a repository ruleset — request body — body rules item commit author email pattern, Create a repository ruleset — request body — body rules item commit message pattern, Create a repository ruleset — request body — body rules item committer email pattern, Create a repository ruleset — request body — body rules item copilot code review, Create a repository ruleset — request body — body rules item creation, Create a repository ruleset — request body — body rules item deletion, Create a repository ruleset — request body — body rules item file extension restriction, Create a repository ruleset — request body — body rules item file path restriction, Create a repository ruleset — request body — body rules item max file path length, Create a repository ruleset — request body — body rules item max file size, Create a repository ruleset — request body — body rules item non fast forward, Create a repository ruleset — request body — body rules item pull request, Create a repository ruleset — request body — body rules item required deployments, Create a repository ruleset — request body — body rules item required linear history, Create a repository ruleset — request body — body rules item required signatures, Create a repository ruleset — request body — body rules item required status checks, Create a repository ruleset — request body — body rules item tag name pattern, Create a repository ruleset — request body — body rules item update, Create a repository ruleset — request body — body rules item workflows
Policy, approvals and errors
Section titled “Policy, approvals and errors”SDK function policy ID: github.repos_create_org_ruleset. Catalog operation: repos/create-org-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"}