Use the REST API to manage rulesets for organizations. Organization rulesets control how people can interact with selected branches and tags in repositories in an organization.
Note
Most endpoints use Authorization: Bearer <YOUR-TOKEN> and Accept: application/vnd.github+json headers, plus X-GitHub-Api-Version: 2026-03-10. Curl examples below omit these standard headers for brevity.
GET /orgs/{org}/rulesets
Get all the repository rulesets for an organization.
accept (string)application/vnd.github+json is recommended.org (string) (required)
The organization name. The name is not case sensitive.
per_page (integer)
The number of results per page (max 100). For more information, see "Using pagination in the REST API."
Default: 30
page (integer)
The page number of the results to fetch. For more information, see "Using pagination in the REST API."
Default: 1
targets (string)
A comma-separated list of rule targets to filter by.
If provided, only rulesets that apply to the specified targets will be returned.
For example, branch,tag,push.
200 - OK
404 - Resource not found
500 - Internal Error
Request:
curl -L \
-X GET \
https://api.github.com/orgs/ORG/rulesets
Response schema (Status: 200):
Array of Repository ruleset:
id: required, integername: required, stringtarget: string, enum: branch, tag, push, repositorysource_type: string, enum: Repository, Organization, Enterprisesource: required, stringenforcement: required, string, enum: disabled, active, evaluatebypass_actors: array of Repository Ruleset Bypass Actor:
actor_id: integer or nullactor_type: required, string, enum: Integration, OrganizationAdmin, RepositoryRole, Team, DeployKey, Userbypass_mode: string, enum: always, pull_request, exempt, default: "always"current_user_can_bypass: string, enum: always, pull_requests_only, never, exemptnode_id: string_links: object:
self: object:
href: stringhtml: object or null:
href: stringconditions: any of:
ref_name: object:
include: array of stringexclude: array of stringrules: array of objectcreated_at: string, format: date-timeupdated_at: string, format: date-timePOST /orgs/{org}/rulesets
Create a repository ruleset for an organization.
accept (string)application/vnd.github+json is recommended.org (string) (required)name (string) (required)
The name of the ruleset.
target (string)
The target of the ruleset
Default: branch
Can be one of: branch, tag, push, repository
enforcement (string) (required)
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).
Can be one of: disabled, active, evaluate
bypass_actors (array of objects)
The actors that can bypass the rules in this ruleset
actor_id (integer or null)actor_type (string) (required)Integration, OrganizationAdmin, RepositoryRole, Team, DeployKey, Userbypass_mode (string)alwaysalways, pull_request, exemptconditions (object)
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.
repository_name_and_ref_name (object)ref_name (object)
include (array of strings)exclude (array of strings)repository_name (object) (required)
include (array of strings)exclude (array of strings)protected (boolean)repository_id_and_ref_name (object)ref_name (object)
include (array of strings)exclude (array of strings)repository_id (object) (required)
repository_ids (array of integers)repository_property_and_ref_name (object)ref_name (object)
include (array of strings)exclude (array of strings)repository_property (object) (required)
include (array of objects)name (string) (required)property_values (array of strings) (required)source (string)custom, systemexclude (array of objects)name (string) (required)property_values (array of strings) (required)source (string)custom, systemrules (array of objects)
An array of rules within the ruleset.
creation (object)type (string) (required)creationupdate (object)type (string) (required)updateparameters (object)
update_allows_fetch_and_merge (boolean) (required)deletion (object)type (string) (required)deletionrequired_linear_history (object)type (string) (required)required_linear_historyrequired_deployments (object)type (string) (required)required_deploymentsparameters (object)
required_deployment_environments (array of strings) (required)required_signatures (object)type (string) (required)required_signaturespull_request (object)type (string) (required)pull_requestparameters (object)
allowed_merge_methods (array of strings)dismiss_stale_reviews_on_push (boolean) (required)dismissal_restriction (object)allowed_actors (array of objects)id (integer) (required)type (string) (required)User, Team, IntegrationInstallation, RepositoryRoleenabled (boolean) (required)require_code_owner_review (boolean) (required)require_last_push_approval (boolean) (required)required_approving_review_count (integer) (required)required_review_thread_resolution (boolean) (required)required_reviewers (array of objects)required_reviewers is in beta and subject to change.
A collection of reviewers and associated file patterns. Each reviewer has a list of file patterns which determine the files that reviewer is required to review.
- file_patterns (array of strings) (required)
Array of file patterns. Pull requests which change matching files must be approved by the specified team. File patterns use fnmatch syntax.
- minimum_approvals (integer) (required)
Minimum number of approvals required from the specified team. If set to zero, the team will be added to the pull request but approval is optional.
- reviewer (object) (required)
A required reviewing team
- id (integer) (required)
ID of the reviewer which must review changes to matching files.
- type (string) (required)
The type of the reviewer
Can be one of: Team
required_status_checks (object)type (string) (required)required_status_checksparameters (object)
do_not_enforce_on_create (boolean)required_status_checks (array of objects) (required)context (string) (required)integration_id (integer)strict_required_status_checks_policy (boolean) (required)non_fast_forward (object)type (string) (required)non_fast_forwardcommit_message_pattern (object)type (string) (required)commit_message_patternparameters (object)
name (string)negate (boolean)operator (string) (required)starts_with, ends_with, contains, regexpattern (string) (required)commit_author_email_pattern (object)type (string) (required)commit_author_email_patternparameters (object)
name (string)negate (boolean)operator (string) (required)starts_with, ends_with, contains, regexpattern (string) (required)committer_email_pattern (object)type (string) (required)committer_email_patternparameters (object)
name (string)negate (boolean)operator (string) (required)starts_with, ends_with, contains, regexpattern (string) (required)branch_name_pattern (object)type (string) (required)branch_name_patternparameters (object)
name (string)negate (boolean)operator (string) (required)starts_with, ends_with, contains, regexpattern (string) (required)tag_name_pattern (object)type (string) (required)tag_name_patternparameters (object)
name (string)negate (boolean)operator (string) (required)starts_with, ends_with, contains, regexpattern (string) (required)file_path_restriction (object)type (string) (required)file_path_restrictionparameters (object)
restricted_file_paths (array of strings) (required)max_file_path_length (object)type (string) (required)max_file_path_lengthparameters (object)
max_file_path_length (integer) (required)file_extension_restriction (object)type (string) (required)file_extension_restrictionparameters (object)
restricted_file_extensions (array of strings) (required)max_file_size (object)type (string) (required)max_file_sizeparameters (object)
max_file_size (integer) (required)workflows (object)type (string) (required)workflowsparameters (object)
do_not_enforce_on_create (boolean)workflows (array of objects) (required)path (string) (required)ref (string)repository_id (integer) (required)sha (string)code_scanning (object)type (string) (required)code_scanningparameters (object)
code_scanning_tools (array of objects) (required)alerts_threshold (string) (required)none, errors, errors_and_warnings, allsecurity_alerts_threshold (string) (required)none, critical, high_or_higher, medium_or_higher, alltool (string) (required)copilot_code_review (object)type (string) (required)copilot_code_reviewparameters (object)
review_draft_pull_requests (boolean)review_on_push (boolean)201 - Created
404 - Resource not found
422 - Validation failed, or the endpoint has been spammed.
500 - Internal Error
Request:
curl -L \
-X POST \
https://api.github.com/orgs/ORG/rulesets \
-d '{
"name": "super cool ruleset",
"target": "branch",
"enforcement": "active",
"bypass_actors": [
{
"actor_id": 234,
"actor_type": "Team",
"bypass_mode": "always"
}
],
"conditions": {
"ref_name": {
"include": [
"refs/heads/main",
"refs/heads/master"
],
"exclude": [
"refs/heads/dev*"
]
},
"repository_name": {
"include": [
"important_repository",
"another_important_repository"
],
"exclude": [
"unimportant_repository"
],
"protected": true
}
},
"rules": [
{
"type": "commit_author_email_pattern",
"parameters": {
"operator": "contains",
"pattern": "github"
}
}
]
}'
Response schema (Status: 201):
id: required, integername: required, stringtarget: string, enum: branch, tag, push, repositorysource_type: string, enum: Repository, Organization, Enterprisesource: required, stringenforcement: required, string, enum: disabled, active, evaluatebypass_actors: array of Repository Ruleset Bypass Actor:
actor_id: integer or nullactor_type: required, string, enum: Integration, OrganizationAdmin, RepositoryRole, Team, DeployKey, Userbypass_mode: string, enum: always, pull_request, exempt, default: "always"current_user_can_bypass: string, enum: always, pull_requests_only, never, exemptnode_id: string_links: object:
self: object:
href: stringhtml: object or null:
href: stringconditions: any of:
ref_name: object:
include: array of stringexclude: array of stringrules: array of objectcreated_at: string, format: date-timeupdated_at: string, format: date-timeGET /orgs/{org}/rulesets/{ruleset_id}
Get a repository ruleset for an organization.
Note: To prevent leaking sensitive information, the bypass_actors property is only returned if the user
making the API request has write access to the ruleset.
accept (string)application/vnd.github+json is recommended.org (string) (required)
The organization name. The name is not case sensitive.
ruleset_id (integer) (required)
The ID of the ruleset.
200 - OK
404 - Resource not found
500 - Internal Error
Request:
curl -L \
-X GET \
https://api.github.com/orgs/ORG/rulesets/RULESET_ID
Response schema (Status: 200):
Same response schema as Create an organization repository ruleset.
PUT /orgs/{org}/rulesets/{ruleset_id}
Update a ruleset for an organization.
accept (string)application/vnd.github+json is recommended.org (string) (required)
The organization name. The name is not case sensitive.
ruleset_id (integer) (required)
The ID of the ruleset.
name (string)
The name of the ruleset.
target (string)
The target of the ruleset
Can be one of: branch, tag, push, repository
enforcement (string)
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).
Can be one of: disabled, active, evaluate
bypass_actors (array of objects)
The actors that can bypass the rules in this ruleset
actor_id (integer or null)actor_type (string) (required)Integration, OrganizationAdmin, RepositoryRole, Team, DeployKey, Userbypass_mode (string)alwaysalways, pull_request, exemptconditions (object)
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.
repository_name_and_ref_name (object)ref_name (object)
include (array of strings)exclude (array of strings)repository_name (object) (required)
include (array of strings)exclude (array of strings)protected (boolean)repository_id_and_ref_name (object)ref_name (object)
include (array of strings)exclude (array of strings)repository_id (object) (required)
repository_ids (array of integers)repository_property_and_ref_name (object)ref_name (object)
include (array of strings)exclude (array of strings)repository_property (object) (required)
include (array of objects)name (string) (required)property_values (array of strings) (required)source (string)custom, systemexclude (array of objects)name (string) (required)property_values (array of strings) (required)source (string)custom, systemrules (array of objects)
An array of rules within the ruleset.
creation (object)type (string) (required)creationupdate (object)type (string) (required)updateparameters (object)
update_allows_fetch_and_merge (boolean) (required)deletion (object)type (string) (required)deletionrequired_linear_history (object)type (string) (required)required_linear_historyrequired_deployments (object)type (string) (required)required_deploymentsparameters (object)
required_deployment_environments (array of strings) (required)required_signatures (object)type (string) (required)required_signaturespull_request (object)type (string) (required)pull_requestparameters (object)
allowed_merge_methods (array of strings)dismiss_stale_reviews_on_push (boolean) (required)dismissal_restriction (object)allowed_actors (array of objects)id (integer) (required)type (string) (required)User, Team, IntegrationInstallation, RepositoryRoleenabled (boolean) (required)require_code_owner_review (boolean) (required)require_last_push_approval (boolean) (required)required_approving_review_count (integer) (required)required_review_thread_resolution (boolean) (required)required_reviewers (array of objects)required_reviewers is in beta and subject to change.
A collection of reviewers and associated file patterns. Each reviewer has a list of file patterns which determine the files that reviewer is required to review.
- file_patterns (array of strings) (required)
Array of file patterns. Pull requests which change matching files must be approved by the specified team. File patterns use fnmatch syntax.
- minimum_approvals (integer) (required)
Minimum number of approvals required from the specified team. If set to zero, the team will be added to the pull request but approval is optional.
- reviewer (object) (required)
A required reviewing team
- id (integer) (required)
ID of the reviewer which must review changes to matching files.
- type (string) (required)
The type of the reviewer
Can be one of: Team
required_status_checks (object)type (string) (required)required_status_checksparameters (object)
do_not_enforce_on_create (boolean)required_status_checks (array of objects) (required)context (string) (required)integration_id (integer)strict_required_status_checks_policy (boolean) (required)non_fast_forward (object)type (string) (required)non_fast_forwardcommit_message_pattern (object)type (string) (required)commit_message_patternparameters (object)
name (string)negate (boolean)operator (string) (required)starts_with, ends_with, contains, regexpattern (string) (required)commit_author_email_pattern (object)type (string) (required)commit_author_email_patternparameters (object)
name (string)negate (boolean)operator (string) (required)starts_with, ends_with, contains, regexpattern (string) (required)committer_email_pattern (object)type (string) (required)committer_email_patternparameters (object)
name (string)negate (boolean)operator (string) (required)starts_with, ends_with, contains, regexpattern (string) (required)branch_name_pattern (object)type (string) (required)branch_name_patternparameters (object)
name (string)negate (boolean)operator (string) (required)starts_with, ends_with, contains, regexpattern (string) (required)tag_name_pattern (object)type (string) (required)tag_name_patternparameters (object)
name (string)negate (boolean)operator (string) (required)starts_with, ends_with, contains, regexpattern (string) (required)file_path_restriction (object)type (string) (required)file_path_restrictionparameters (object)
restricted_file_paths (array of strings) (required)max_file_path_length (object)type (string) (required)max_file_path_lengthparameters (object)
max_file_path_length (integer) (required)file_extension_restriction (object)type (string) (required)file_extension_restrictionparameters (object)
restricted_file_extensions (array of strings) (required)max_file_size (object)type (string) (required)max_file_sizeparameters (object)
max_file_size (integer) (required)workflows (object)type (string) (required)workflowsparameters (object)
do_not_enforce_on_create (boolean)workflows (array of objects) (required)path (string) (required)ref (string)repository_id (integer) (required)sha (string)code_scanning (object)type (string) (required)code_scanningparameters (object)
code_scanning_tools (array of objects) (required)alerts_threshold (string) (required)none, errors, errors_and_warnings, allsecurity_alerts_threshold (string) (required)none, critical, high_or_higher, medium_or_higher, alltool (string) (required)copilot_code_review (object)type (string) (required)copilot_code_reviewparameters (object)
review_draft_pull_requests (boolean)review_on_push (boolean)200 - OK
404 - Resource not found
422 - Validation failed, or the endpoint has been spammed.
500 - Internal Error
Request:
curl -L \
-X PUT \
https://api.github.com/orgs/ORG/rulesets/RULESET_ID \
-d '{
"name": "super cool ruleset",
"target": "branch",
"enforcement": "active",
"bypass_actors": [
{
"actor_id": 234,
"actor_type": "Team",
"bypass_mode": "always"
}
],
"conditions": {
"ref_name": {
"include": [
"refs/heads/main",
"refs/heads/master"
],
"exclude": [
"refs/heads/dev*"
]
},
"repository_name": {
"include": [
"important_repository",
"another_important_repository"
],
"exclude": [
"unimportant_repository"
],
"protected": true
}
},
"rules": [
{
"type": "commit_author_email_pattern",
"parameters": {
"operator": "contains",
"pattern": "github"
}
}
]
}'
Response schema (Status: 200):
Same response schema as Create an organization repository ruleset.
DELETE /orgs/{org}/rulesets/{ruleset_id}
Delete a ruleset for an organization.
accept (string)application/vnd.github+json is recommended.org (string) (required)
The organization name. The name is not case sensitive.
ruleset_id (integer) (required)
The ID of the ruleset.
204 - No Content
404 - Resource not found
500 - Internal Error
Request:
curl -L \
-X DELETE \
https://api.github.com/orgs/ORG/rulesets/RULESET_ID
Response schema (Status: 204):
GET /orgs/{org}/rulesets/{ruleset_id}/history
Get the history of an organization ruleset.
accept (string)application/vnd.github+json is recommended.org (string) (required)
The organization name. The name is not case sensitive.
per_page (integer)
The number of results per page (max 100). For more information, see "Using pagination in the REST API."
Default: 30
page (integer)
The page number of the results to fetch. For more information, see "Using pagination in the REST API."
Default: 1
ruleset_id (integer) (required)
The ID of the ruleset.
200 - OK
404 - Resource not found
500 - Internal Error
Request:
curl -L \
-X GET \
https://api.github.com/orgs/ORG/rulesets/RULESET_ID/history
Response schema (Status: 200):
Array of Ruleset version:
version_id: required, integeractor: required, object:
id: integertype: stringupdated_at: required, string, format: date-timeGET /orgs/{org}/rulesets/{ruleset_id}/history/{version_id}
Get a version of an organization ruleset.
accept (string)application/vnd.github+json is recommended.org (string) (required)
The organization name. The name is not case sensitive.
ruleset_id (integer) (required)
The ID of the ruleset.
version_id (integer) (required)
The ID of the version
200 - OK
404 - Resource not found
500 - Internal Error
Request:
curl -L \
-X GET \
https://api.github.com/orgs/ORG/rulesets/RULESET_ID/history/VERSION_ID
Response schema (Status: 200):
version_id: required, integeractor: required, object:
id: integertype: stringupdated_at: required, string, format: date-timestate: required, object