REST API endpoints for rules

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 all organization repository rulesets

GET /orgs/{org}/rulesets

Get all the repository rulesets for an organization.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/orgs/ORG/rulesets

Response schema (Status: 200):

Array of Repository ruleset:

Create an organization repository ruleset

POST /orgs/{org}/rulesets

Create a repository ruleset for an organization.

Parameters

Headers

Path and query parameters

Body parameters

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

HTTP response status codes

Code examples

Example

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):

Get an organization repository ruleset

GET /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.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

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.

Update an organization repository ruleset

PUT /orgs/{org}/rulesets/{ruleset_id}

Update a ruleset for an organization.

Parameters

Headers

Path and query parameters

Body parameters

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

HTTP response status codes

Code examples

Example

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 an organization repository ruleset

DELETE /orgs/{org}/rulesets/{ruleset_id}

Delete a ruleset for an organization.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X DELETE \
  https://api.github.com/orgs/ORG/rulesets/RULESET_ID

Response schema (Status: 204):

Get organization ruleset history

GET /orgs/{org}/rulesets/{ruleset_id}/history

Get the history of an organization ruleset.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/orgs/ORG/rulesets/RULESET_ID/history

Response schema (Status: 200):

Array of Ruleset version:

Get organization ruleset version

GET /orgs/{org}/rulesets/{ruleset_id}/history/{version_id}

Get a version of an organization ruleset.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/orgs/ORG/rulesets/RULESET_ID/history/VERSION_ID

Response schema (Status: 200):